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