Skip to content

Commit

Permalink
refactor(web/ez-http): 优化代码结构,消除警告 (#10)
Browse files Browse the repository at this point in the history
* feat(web/ez-http): 添加构建文件和题目信息

* ci(web/ez-http): 添加工作流文件

* fix(web/ez-http): 使用 `HTTP_X_FORWARDED_FOR` 判断来源 IP

* refactor(web/ez-http): 优化代码结构,消除警告
  • Loading branch information
13m0n4de authored Sep 5, 2024
1 parent 8fb2b6c commit e7c5e58
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions challenges/web/ez_http/build/html/index.php
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
<?php

if (strpos($_SERVER['HTTP_X_FORWARDED_FOR'], "127") === 0) {
if ($_SERVER["HTTP_REFERER"] === "genshin.edu.cn") {
if ($_SERVER["HTTP_USER_AGENT"] === "svuctf") {
echo "flag在小饼干里!";
setcookie("flag", file_get_contents("/flag"));
} else {
echo "请使用 svuctf 浏览器!";
}
} else {
echo "不是 genshin.edu.cn 来的我不要";
}
} else {
$forwardedFor = $_SERVER['HTTP_X_FORWARDED_FOR'] ?? null;
$referer = $_SERVER["HTTP_REFERER"] ?? null;
$userAgent = $_SERVER["HTTP_USER_AGENT"] ?? null;

if ($forwardedFor === null || strpos($forwardedFor, "127") !== 0) {
echo "必须从本地访问!";
exit;
}

if ($referer !== "genshin.edu.cn") {
echo "不是 genshin.edu.cn 来的我不要";
exit;
}

if ($userAgent !== "svuctf") {
echo "请使用 svuctf 浏览器!";
exit;
}

echo "flag在小饼干里!";
setcookie("flag", file_get_contents("/flag"));

0 comments on commit e7c5e58

Please sign in to comment.