phpstudy后门文件检测及利用

2019.9.20得知非官网的一些下载站中的phpstudy版本存在后门文件,基于研究的目的,于是有了以下这文。复现使用5.4版本的,互联网随便下载了一个

0X00检测脚本(来源ChaMd5安全团队)

  • Linux
#! /bin/bash
# author: [email protected]
# http://pcat.cc

# trojan feature
trojan=@eval

function check_dir(){
    for file in `ls $1`
    do
        f2=$1"/"$file
        if [ -d $f2 ]
        then
            check_dir $f2
        # just check dll file
        elif [ "${file##*.}"x = "dll"x ]
        then
            strings $f2 |grep -q $trojan
            if [ $? == 0 ]
            then
                echo "===" $f2 "===="
                strings $f2 |grep $trojan
            fi
        fi
    done
}
# . stand for current directory
check_dir .
  • windows
# -*- coding:utf8 -*-
__author__='[email protected]'
__blog__='http://pcat.cc'

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 pcheck(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:
            pcheck(os.path.join(path, name))
        for name in dirs:
            pcheck(os.path.join(path, name))
    pass


if __name__ == '__main__':
    foo()

0X01检测后门示例

用windows系统的为例,在这里插入图片描述
运行脚本发现php_xmlrpc.dll存在问题
在这里插入图片描述
也可以直接打开,搜索关键字eval
在这里插入图片描述

0X02 利用

  • 使用exp成功弹出计算器(来源于圈子社区)
    在这里插入图片描述
    exp不对外公开,更多关注密圈

0X03 安全修补

为了减少系统已产生的后门带来的危险,可以继续做以下工作:

  • 不需要对外开放的端口同一关闭,或者做 IP 访问限制,防止已有后门继续和外界保持通讯
  • 对于所有访问请求的 URL 进行记录(可以通过 Apache 或 nginx 访问日志记录),定期分析所有的请求是否有异常情况
  • 去除后门或更新最新版本phpstudy

0X04 参考链接

  • https://mp.weixin.qq.com/s/dIDfgFxHlqenKRUSW7Oqkw

在这里插入图片描述

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章