前言
phpstudy漏洞在当时的影响还是蛮大的,所以决定对phpstudy存在的漏洞进行解析复现。
一、phpStudy_2016-2018_RCE是什么
Phpstudy软件是国内的一款免费的PHP调试环境的程序集成包,通过集成Apache、PHP、MySQL、phpMyAdmin等多款软件一次性安装,无需配置即可直接安装使用,一键搭建。 其中2016、2018版本的phpstudy存在被黑客恶意篡改后形成的RCE漏洞。该漏洞可以直接远程执行系统命令。
二、漏洞存在的文件位置
后门代码存在于\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 \phpStudy\php\php-5.4.45\ext\php_xmlrpc.dll
phpStudy2018查看:
\PHPTutorial\PHP\PHP-5.2.17\ext\php_xmlrpc.dll \PHPTutorial\PHP\PHP-5.4.45\ext\php_xmlrpc.dll
三、漏洞分析
通过 IDA分析xmlrpc.dll发现,被植入危险函数eval()。  xmlrpc.dll中的初始化函数request_startup_func被篡改:当发起HTTP请求的数据包中包含“Accept-Encoding”字段时,就会进入黑客自定义的攻击流程。  当Accept-Encoding字段的信息为“compress,gzip”时,触发系统收集功能。  当Accept-Encoding字段的信息为“gzip,deflate”时,再进一步判断Accept-Charset字段,只有当Accept-Charset字段为一些特定字符时才会触发漏洞。
四、漏洞复现
环境搭建
虚拟机中安装phpstudy2016或者phpstudy2018,运行5.2.17或5.4.45版本。  能正常访问web站点。 
漏洞触发
开启BP代理,拦截数据流量。  重构HTTP请求包。 请求中添加一项参数 Accept-Charset:系统命令。  将系统命令代码进行Base64转码,如system(‘whoami’);  重放HTTP请求包。  写入一句话木马。   菜刀链接。 
总结
本文通过复现 phpstudy 的远程执行漏洞,在模拟漏洞攻击的过程中学习技术,锻炼思维。该漏洞可以直接执行系统命令,属于高危漏洞。 下一篇: phpstudy漏洞检测利用脚本(EXP)编写
|