基本信息 题目名称:PHP签到 题目链接:[GCCCTF 2025]PHP签到 | NSSCTF 考点清单:robots.txt、PHP 绕过 解题思路 看到页面主题为 ROBOT HUB,第一时间想到 robots.txt,访问得到:
User-agent: * Disallow: /l34RNpHP.php 继续访问,获得下面的 php 代码:
<?php header('Content-Type: text/plain; charset=UTF-8'); if (!isset($_GET['user'], $_GET['token'], $_GET['sig'], $_GET['ts'], $_GET['nonce'])) { readfile(__FILE__); exit; } $user = (string)$_GET['user']; $token = (string)$_GET['token']; $sig = (string)$_GET['sig']; $ts = (int)$_GET['ts']; $nonce = (string)$_GET['nonce']; $xff = $_SERVER['HTTP_X_FORWARDED_FOR'] ?? ''; if (strpos($xff, '127.0.0.1') === false && strpos($xff, '::1') === false) { exit('hacker!'); } if (base64_decode($nonce) === false || !preg_match('/^[A-Za-z0-9+\/=]+$/', $nonce)) { exit('hacker!!'); } if (time() - $ts <= 60) { // ok } else { exit('expired!'); } if (strpos($user, 'admin') == false) { $key = $_COOKIE['authkey'] ?? 'NULL'; $mac = hash_hmac('md5', $user . $token . $ts, $key); if (substr($mac, 0, 6) == substr($sig, 0, 6)) { $stored_hash = '0e830400451993494058024219903391'; if (md5($token) == $stored_hash) { @readfile('/flag'); } else { exit('hacker!!!'); } } else { exit('hacker!!!!'); } } else { exit('blocked user'); } 程序要求传入五个 GET 参数:user、token、sig、ts、nonce。
...