commit 7df45e445352ab208570d6d0e1f5b46c98f4cfc2 Author: cnrenil Date: Mon Sep 9 17:16:59 2024 +0800 First Commit diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..2374b6c --- /dev/null +++ b/Dockerfile @@ -0,0 +1,6 @@ +FROM php:8.2-cli + +COPY _files/src /app +WORKDIR /app + +CMD [ "php", "-S", "0.0.0.0:80" ] diff --git a/_files/src/dump.pcap b/_files/src/dump.pcap new file mode 100644 index 0000000..f14ae42 Binary files /dev/null and b/_files/src/dump.pcap differ diff --git a/_files/src/index.html b/_files/src/index.html new file mode 100644 index 0000000..0adc574 --- /dev/null +++ b/_files/src/index.html @@ -0,0 +1,48 @@ + + + + + + 登录页面 + + + +

登录

+ +

+ +

+ + + + diff --git a/_files/src/server.php b/_files/src/server.php new file mode 100644 index 0000000..2d6e273 --- /dev/null +++ b/_files/src/server.php @@ -0,0 +1,40 @@ + '04f94c31-7845-469b-ba4e-1fdbabb511f4', // 用户名 => 密码 +]; + +// 从环境变量中读取 Flag,如果没有则使用默认值 +$flag = getenv('GZCTF_FLAG') ?: 'CTF{this_is_test_flag}'; + +// 异或加密函数 +function xor_encrypt($data, $key) { + $out = ''; + for ($i = 0; $i < strlen($data); $i++) { + $out .= $data[$i] ^ $key[$i % strlen($key)]; + } + return $out; +} + +// 处理 POST 请求 +if ($_SERVER['REQUEST_METHOD'] === 'POST') { + $username = $_POST['username'] ?? ''; + $encrypted_password = $_POST['password'] ?? ''; + $key = '1e72c059-3a93-4f6f-839e-aa0c0784cd29'; + + // 解密密码 + $password = xor_encrypt($encrypted_password, $key); + + // 验证用户 + if (isset($users[$username]) && $users[$username] === $password) { + // 登录成功,返回加密的 Flag + $encrypted_flag = xor_encrypt($flag, $key); + echo "登录成功!Flag: " . base64_encode($encrypted_flag); // 使用 Base64 编码以便于传输 + } else { + echo "用户名或密码错误!"; + } +} +?> +