One of the techniques used by hackers to gain access to a database, is the 'SQL INJECTION . This technique consists in ' inject code into databases with the aim of generating an unexpected event, and gain access.
The injection attacks allow hackers to affect sensitive data and cause various problems such as disclosure of any personal data or the destruction of the waste and the possibility to become managers of their own server.
Try to imagine a query generated by a login page ;
SELECT * FROM users WHERE user_idLet's try to inject a string structured in password ;
= 'Admin' AND
password_id = 'pswd'
SELECT * FROM users WHERE user_idAs you can see the OR operator impose an equal and since it is always verified, we will get access.
= 'admin' AND
password_id = 'anything' OR 'x' = 'x'
Other strings that would be useful to try to test the security of our database;) are;
'or 1 = 1 -
' "or 1 = 1 -
'or 1 = 1 -
' or 0
= 0 # '"or 0 = 0 - 0 = 0 or
-
' or 0 = 0 #
'or' x '=' x
or 1 = 1 -
') or (' a '=' a not always easy to defend against such an attack because firewalls and similar devices provide protection against web attacks on a large scale, but given that the site should be accessible to the public, security systems allow access.
What a developer or an administrator can do to prevent this type of intrusion is to filter the characters before passing them to DBMS. Some of these are very sensitive;
+ - () =, '\u0026lt;> As well as filtering also reserved words in SQL based on your needs.