目录

MazeSec suo 设计流程

# 修改主机名

hostname="suo"
echo "$hostname" > /etc/hostname
cat >/etc/hosts <<EOF
127.0.0.1   localhost
127.0.1.1   $hostname
::1         localhost ip6-localhost ip6-loopback
EOF
hostname -F /etc/hostname
1
2
3
4
5
6
7
8

# 创建用户及修改密码

生成个 lanyangyang 用户的创建命令

name='lanyangyang'
pass=$(openssl rand -base64 18)
shell="\nRun:\naddgroup $name\nadduser -D -G $name -s /bin/bash -h /home/$name $name\necho \"$name:$pass\" | chpasswd"
echo -e "$shell"
1
2
3
4

创建 lanyangyang 用户并修改密码

addgroup lanyangyang
adduser -D -G lanyangyang -s /bin/bash -h /home/lanyangyang lanyangyang
echo "lanyangyang:2pezUxZE8hq2TKC2IdBTk7k0" | chpasswd
1
2
3

root 修改密码(这里从 rockyou 末尾提取,确保可以爆破哈希)

# 注意!!表示上一条命令的完整内容,双引号时会出现非预期行为
echo 'root:111111111111111' | chpasswd
1
2

# 部署 php twig

安装 composer

# 更新包索引
apk update

# 安装 PHP 和必要的扩展
apk add php81 php81-curl php81-openssl php81-mbstring php81-phar php81-zip php81-xml php81-tokenizer php81-session

# 安装 Composer
apk add composer

# 验证安装
composer --version
1
2
3
4
5
6
7
8
9
10
11

创建项目目录

# 进入网站目录
cd /var/www/html

# 创建项目目录结构
mkdir -p templates cache src
mkdir -p templates/layouts templates/pages templates/includes

# 设置缓存目录权限
chmod 777 cache
1
2
3
4
5
6
7
8
9

创建 composer.json 文件

# 创建 composer.json 文件
cat > composer.json << 'EOF'
{
    "name": "myproject/twig-site",
    "description": "Twig template project",
    "type": "project",
    "require": {
        "php": ">=7.4",
        "twig/twig": "^3.0"
    },
    "autoload": {
        "psr-4": {
            "App\\": "src/"
        }
    },
    "config": {
        "optimize-autoloader": true
    }
}
EOF

# 安装 Twig
composer install
# 或者
composer require twig/twig
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

deepseek 生成首页及模板

index.php

cat > /var/www/html/index.php << 'EOF'
<?php
ini_set('display_errors', 1);
error_reporting(E_ALL);

require_once __DIR__ . '/vendor/autoload.php';

use Twig\Loader\ArrayLoader;
use Twig\Environment;
use Twig\Extension\DebugExtension;

$loader = new ArrayLoader([
    'index' => '
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>HTTP 代理配置生成器</title>
    <style>
        /* 保持原有的CSS样式 */
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        body {
            font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            min-height: 100vh;
            display: flex;
            align-items: center;
            justify-content: center;
            color: #333;
        }
        .container {
            background: rgba(255, 255, 255, 0.95);
            backdrop-filter: blur(10px);
            border-radius: 20px;
            box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
            padding: 60px;
            max-width: 600px;
            width: 90%;
            animation: slideUp 0.6s ease-out;
        }
        @keyframes slideUp {
            from {
                opacity: 0;
                transform: translateY(30px);
            }
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }
        .header {
            text-align: center;
            margin-bottom: 40px;
        }
        .logo {
            width: 64px;
            height: 64px;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            border-radius: 16px;
            margin: 0 auto 20px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 28px;
            color: white;
            box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
        }
        h1 {
            font-size: 28px;
            font-weight: 700;
            color: #1a1a2e;
            margin-bottom: 8px;
            letter-spacing: -0.5px;
        }
        .subtitle {
            color: #6b7280;
            font-size: 14px;
            font-weight: 400;
        }
        .form-group {
            margin-bottom: 24px;
        }
        label {
            display: block;
            margin-bottom: 8px;
            font-weight: 600;
            color: #374151;
            font-size: 14px;
        }
        .input-wrapper {
            position: relative;
        }
        input[type="text"] {
            width: 100%;
            padding: 14px 16px;
            border: 2px solid #e5e7eb;
            border-radius: 12px;
            font-size: 15px;
            transition: all 0.3s ease;
            background: #f9fafb;
            color: #1f2937;
        }
        input[type="text"]:focus {
            outline: none;
            border-color: #667eea;
            background: #ffffff;
            box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
        }
        input[type="text"]::placeholder {
            color: #9ca3af;
        }
        .hint {
            margin-top: 6px;
            font-size: 12px;
            color: #6b7280;
        }
        button {
            width: 100%;
            padding: 16px;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            border: none;
            border-radius: 12px;
            font-size: 16px;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.3s ease;
            box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
        }
        button:hover {
            transform: translateY(-2px);
            box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
        }
        button:active {
            transform: translateY(0);
        }
        .result {
            margin-top: 30px;
            padding: 20px;
            background: #1f2937;
            border-radius: 12px;
            position: relative;
            display: {{ command ? "block" : "none" }};
        }
        .result-label {
            font-size: 12px;
            color: #9ca3af;
            text-transform: uppercase;
            letter-spacing: 0.5px;
            margin-bottom: 8px;
        }
        .result-code {
            font-family: "Menlo", "Monaco", "Courier New", monospace;
            font-size: 14px;
            color: #10b981;
            word-break: break-all;
            line-height: 1.6;
        }
        .copy-btn {
            position: absolute;
            top: 16px;
            right: 16px;
            background: rgba(255, 255, 255, 0.1);
            border: 1px solid rgba(255, 255, 255, 0.2);
            color: #9ca3af;
            padding: 6px 12px;
            border-radius: 6px;
            font-size: 12px;
            cursor: pointer;
            transition: all 0.2s;
        }
        .copy-btn:hover {
            background: rgba(255, 255, 255, 0.2);
            color: #fff;
        }
        .footer {
            text-align: center;
            margin-top: 30px;
            padding-top: 20px;
            border-top: 1px solid #e5e7eb;
        }
        .footer-text {
            font-size: 12px;
            color: #9ca3af;
        }
        .features {
            display: flex;
            justify-content: center;
            gap: 30px;
            margin-top: 20px;
            flex-wrap: wrap;
        }
        .feature {
            display: flex;
            align-items: center;
            gap: 8px;
            font-size: 13px;
            color: #6b7280;
        }
        .feature-icon {
            width: 20px;
            height: 20px;
            background: #d1fae5;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            color: #059669;
            font-size: 12px;
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="header">
            <div class="logo">⚡</div>
            <h1>代理配置生成器</h1>
            <p class="subtitle">快速生成 HTTP 代理隧道连接命令</p>
        </div>

        <form method="POST" action="">
            <div class="form-group">
                <label for="target">目标服务器地址</label>
                <div class="input-wrapper">
                    <input 
                        type="text" 
                        id="target" 
                        name="target" 
                        placeholder="例如: 192.168.1.100:8080 或 target.com" 
                        required
                        autocomplete="off"
                        value="{{ target|default("") }}"
                    >
                </div>
                <p class="hint">输入目标服务器的 IP 地址或域名,包含端口号(如果有)</p>
            </div>

            <button type="submit">生成连接命令</button>
        </form>

        {% if command %}
        <div class="result" id="resultBox">
            <div class="result-label">Generated Command</div>
            <button class="copy-btn" onclick="copyToClipboard()">复制</button>
            <div class="result-code" id="commandText">{{ command }}</div>
        </div>
        {% endif %}

        <div class="footer">
            <div class="features">
                <div class="feature">
                    <div class="feature-icon">✓</div>
                    <span>高性能传输</span>
                </div>
                <div class="feature">
                    <div class="feature-icon">✓</div>
                    <span>全双工模式</span>
                </div>
                <div class="feature">
                    <div class="feature-icon">✓</div>
                    <span>负载均衡支持</span>
                </div>
            </div>
            <p class="footer-text" style="margin-top: 20px;">
                © 2026 MazeSec. 仅供开发测试使用
            </p>
        </div>
    </div>

    <script>
        function copyToClipboard() {
            const commandText = document.getElementById(\'commandText\').innerText;
            navigator.clipboard.writeText(commandText).then(() => {
                const btn = document.querySelector(\'.copy-btn\');
                const originalText = btn.innerText;
                btn.innerText = \'已复制!\';
                btn.style.background = \'rgba(16, 185, 129, 0.2)\';
                btn.style.color = \'#10b981\';
                setTimeout(() => {
                    btn.innerText = originalText;
                    btn.style.background = \'rgba(255, 255, 255, 0.1)\';
                    btn.style.color = \'#9ca3af\';
                }, 2000);
            });
        }

        const input = document.getElementById(\'target\');
        input.addEventListener(\'focus\', function() {
            this.placeholder = \'\';
        });
        input.addEventListener(\'blur\', function() {
            if (!this.value) {
                this.placeholder = \'例如: 192.168.1.100:8080 或 target.com\';
            }
        });
    </script>
</body>
</html>
    '
]);

$twig = new Environment($loader, [
    'debug' => true,  
    'autoescape' => false,
    'cache' => false,     
]);

$twig->addExtension(new DebugExtension());

$command = '';
$target = '';

if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['target'])) {
    $target = $_POST['target'];
    
    try {
        $template_code = './suo5 -t http://' . $target . '/suo5.jsp';
        
        $dynamic_loader = new ArrayLoader([
            'dynamic' => $template_code
        ]);
        
        $dynamic_twig = new Environment($dynamic_loader, [
            'debug' => true,
            'autoescape' => false,
            'cache' => false
        ]);
        $dynamic_twig->addExtension(new DebugExtension());
        
        $command = $dynamic_twig->render('dynamic');
    } catch (Exception $e) {
        $command = "错误: " . $e->getMessage();
    }
}

echo $twig->render('index', [
    'command' => $command,
    'target' => htmlspecialchars($target)
]);
EOF
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

权限控制

# 设置权限
cd /var/www/html/
chown -R apache:apache /var/www/html/
chmod -R 755 /var/www/html/
chmod 777 /var/www/html/cache
1
2
3
4
5

# 安装 arp-scan

apk add arp-scan
1

# 添加两条 sudo 授权

cat << 'EOF' >> /etc/sudoers.d/apache
apache ALL=(lanyangyang) NOPASSWD:/bin/nice
EOF
cat << 'EOF' >> /etc/sudoers.d/lanyangyang
lanyangyang ALL=(ALL) NOPASSWD:/usr/bin/arp-scan
EOF
chmod 600 /etc/sudoers.d/*
1
2
3
4
5
6
7

# 放置flag

root@localhost:~# echo 'flag{user-da4e2b9944cf4d0389a894c8d718444f}' > /home/lanyangyang/user.txt
root@localhost:~# echo 'flag{root-8438726c502a452d997ba300afac30fe}' > /root/root.txt
1
2

# 防火墙配置

# 安装 iptables
apk add iptables iptables-openrc
1
2

配置防火墙

cat <<'EOF' > /tmp/firewall.sh
#!/bin/sh
set -e

# 清空规则
iptables -F
iptables -X

# 默认策略
iptables -P INPUT DROP
iptables -P OUTPUT DROP
iptables -P FORWARD DROP

# 已建立/相关连接
iptables -A INPUT  -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
iptables -A OUTPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT

# 回环
iptables -A INPUT  -i lo -j ACCEPT
iptables -A OUTPUT -o lo -j ACCEPT

# DNS
iptables -A OUTPUT -p udp --dport 53 -j ACCEPT
iptables -A OUTPUT -p tcp --dport 53 -j ACCEPT

# HTTP 80
iptables -A INPUT  -p tcp --dport 80 -j ACCEPT
iptables -A OUTPUT -p tcp --dport 80 -j ACCEPT

# 其他 TCP/UDP
iptables -A INPUT  -p tcp -j REJECT --reject-with tcp-reset
iptables -A OUTPUT -p tcp -j REJECT --reject-with tcp-reset
iptables -A INPUT  -p udp -j REJECT --reject-with icmp-port-unreachable
iptables -A OUTPUT -p udp -j REJECT --reject-with icmp-port-unreachable

# 1) 保存一份规则(给 local.d 用)
iptables-save > /etc/iptables/fw.rules

# 2) local.d 兜底:开机 restore(不依赖 iptables-openrc)
mkdir -p /etc/local.d
cat <<'EOR' > /etc/local.d/firewall.start
#!/bin/sh
[ -f /etc/iptables/fw.rules ] && iptables-restore < /etc/iptables/fw.rules
EOR
chmod +x /etc/local.d/firewall.start
rc-update add local boot >/dev/null 2>&1 || true

# 3) 可选:同时启用 iptables-openrc(双保险)
rc-service iptables start 2>/dev/null || true
rc-service iptables save || true
rc-update add iptables boot >/dev/null 2>&1 || true
EOF

chmod +x /tmp/firewall.sh
sh /tmp/firewall.sh && rm /tmp/firewall.sh
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
最后一次更新于: 2026/03/15, 19:20:22