39
Ever since I started an online project, I’ve been having problems with hacking, where someone is making direct entries into the database. This is what gave me the initiative to put in all the variables received through the method $_GET
and $_POST
. The functions:
$variavel = trim(strip_tags(mysqli_real_escape_string($conn, $_POST['recebe'])));
I used two programs to do scanner to analyze the site ('Acunetix' and 'Scrawlr'), where the first time returned vulnerable variables, but now I did the whole procedure in the same and now not more signal problem.
However, even so, the attacker still manages to hack the server, even though he is sure after checking all lines of code of the project..
Well, for starters, I’d say restore the latest backup, so you must have made one right before the attack. Check log files to see if you can find queries.
– Edilson
A simple question: Is your database server exposed to the internet or is it only accessible through your web server?
– Victor Stafusa
@Victorstafusa This is on the site, but is only accessed by Adms, but I know it is not so pq, by the panel on the site, when some data is inserted the script takes the account id, but when I see that there was attack and I check on the server itself is like '0', saying it wasn’t on account
– Pedro Quezado
Are you sure there’s no way to access the database directly other than through the application? Because if that happens, just have the login and password of the database and it’s over. By the way, have you changed the login and password of the database? If you haven’t changed yet, I recommend you do it urgently.
– Victor Stafusa
If your site has user information (email, login, password, etc.) and passwords are not properly encrypted, send an email alerting users to modify passwords from their personal email. Many users use the same email password in other services.
– Marcos Xavier
Don’t forget to always use Prepared statments that avoid too much of these problems.
– Jorge B.
Replace passwords, mainly from the database, put a new alias in the tables... change the name of the database, use placeholders in the Insert/ update methods, never pass input and update parameters by GET, preferably use a csrf token for POST by forms, so you validate the publication origin, for restful methods, use a token with type authorization Bearer Token
– Ivan Ferrer