@@ -16,7 +16,7 @@ def initialize(info={})
16
16
'Description' => %q{
17
17
This module zips a file or a directory. On Linux, it uses the zip command.
18
18
On Windows, it will try to use remote target's 7Zip if found. If not, it falls
19
- back to its own VBScript .
19
+ back to its Windows Scripting Host .
20
20
} ,
21
21
'License' => MSF_LICENSE ,
22
22
'Author' => [ 'sinn3r' ] ,
@@ -39,10 +39,12 @@ def has_7zip?
39
39
file? ( "#{ get_program_file_path } \\ 7-Zip\\ 7z.exe" )
40
40
end
41
41
42
- def vbs ( dest , src )
43
- vbs_file = File . read ( File . join ( Msf ::Config . data_directory , "post" , "zip" , "zip.vbs" ) )
44
- vbs_file << "WindowsZip \" #{ src } \" ,\" #{ dest } \" "
45
- vbs_file
42
+ def wsh_script ( dst , src )
43
+ script_file = File . read ( File . join ( Msf ::Config . data_directory , "post" , "zip" , "zip.js" ) )
44
+ src . gsub! ( "\\ " , "\\ \\ \\ " )
45
+ dst . gsub! ( "\\ " , "\\ \\ \\ " )
46
+ script_file << "zip(\" #{ src } \" ,\" #{ dst } \" );" . force_encoding ( "UTF-8" )
47
+ script_file
46
48
end
47
49
48
50
def find_pid_by_user ( username )
@@ -62,7 +64,7 @@ def steal_token
62
64
pid = find_pid_by_user ( current_user )
63
65
64
66
unless pid
65
- fail_with ( Failure ::Unknown , "Unable to find a PID for #{ current_user } to execute .vbs " )
67
+ fail_with ( Failure ::Unknown , "Unable to find a PID for #{ current_user } to execute WSH " )
66
68
end
67
69
68
70
print_status ( "Stealing token from PID #{ pid } for #{ current_user } " )
@@ -77,21 +79,21 @@ def steal_token
77
79
@token_stolen = true
78
80
end
79
81
80
- def upload_exec_vbs_zip
82
+ def upload_exec_wsh_script_zip
81
83
if is_system?
82
84
unless session
83
- print_error ( 'Unable to decompress with VBS technique without Meterpreter' )
85
+ print_error ( 'Unable to compress with WSH technique without Meterpreter' )
84
86
return
85
87
end
86
88
87
89
steal_token
88
90
end
89
91
90
- script = vbs ( datastore [ 'DESTINATION' ] , datastore [ 'SOURCE' ] )
91
- tmp_path = "#{ get_env ( 'TEMP' ) } \\ zip.vbs "
92
- print_status ( "VBS file uploaded to #{ tmp_path } " )
93
- write_file ( tmp_path , script )
94
- cmd_exec ( "wscript .exe #{ tmp_path } " )
92
+ script = wsh_script ( datastore [ 'DESTINATION' ] , datastore [ 'SOURCE' ] )
93
+ tmp_path = "#{ get_env ( 'TEMP' ) } \\ zip.js "
94
+ print_status ( "script file uploaded to #{ tmp_path } " )
95
+ write_file ( tmp_path , script . encode ( "UTF-16LE" ) )
96
+ cmd_exec ( "cscript .exe #{ tmp_path } " )
95
97
end
96
98
97
99
def do_7zip
@@ -110,8 +112,8 @@ def windows_zip
110
112
print_status ( "Compressing #{ datastore [ 'DESTINATION' ] } via 7zip" )
111
113
do_7zip
112
114
else
113
- print_status ( "Compressing #{ datastore [ 'DESTINATION' ] } via VBS " )
114
- upload_exec_vbs_zip
115
+ print_status ( "Compressing #{ datastore [ 'DESTINATION' ] } via WSH " )
116
+ upload_exec_wsh_script_zip
115
117
end
116
118
end
117
119
0 commit comments