File tree Expand file tree Collapse file tree 3 files changed +15
-15
lines changed Expand file tree Collapse file tree 3 files changed +15
-15
lines changed Original file line number Diff line number Diff line change @@ -302,11 +302,15 @@ def desc
302
302
##
303
303
# :category: Msf::Session::Scriptable implementors
304
304
#
305
- # Runs the meterpreter script in the context of a script container
305
+ # Runs the Meterpreter script or resource file
306
306
#
307
307
def execute_file ( full_path , args )
308
- o = Rex ::Script ::Meterpreter . new ( self , full_path )
309
- o . run ( args )
308
+ # Infer a Meterpreter script by it having an .rb extension
309
+ if File . extname ( full_path ) == ".rb"
310
+ Rex ::Script ::Meterpreter . new ( self , full_path ) . run ( args )
311
+ else
312
+ console . load_resource ( full_path )
313
+ end
310
314
end
311
315
312
316
Original file line number Diff line number Diff line change @@ -164,13 +164,17 @@ def execute_script(script_name, *args)
164
164
else
165
165
full_path = self . class . find_script_path ( script_name )
166
166
167
- # No path found? Weak.
168
167
if full_path . nil?
169
168
print_error ( "The specified script could not be found: #{ script_name } " )
170
- return true
169
+ return
170
+ end
171
+
172
+ begin
173
+ execute_file ( full_path , args )
174
+ framework . events . on_session_script_run ( self , full_path )
175
+ rescue StandardError => e
176
+ print_error ( "Could not execute #{ script_name } : #{ e . class } #{ e } " )
171
177
end
172
- framework . events . on_session_script_run ( self , full_path )
173
- execute_file ( full_path , args )
174
178
end
175
179
end
176
180
Original file line number Diff line number Diff line change @@ -313,8 +313,6 @@ def load_resource(path)
313
313
return
314
314
end
315
315
316
- self . active_resource = resource_file
317
-
318
316
# Process ERB directives first
319
317
print_status "Processing #{ path } for ERB directives."
320
318
erb = ERB . new ( resource_file )
@@ -362,8 +360,6 @@ def load_resource(path)
362
360
run_single ( line )
363
361
end
364
362
end
365
-
366
- self . active_resource = nil
367
363
end
368
364
369
365
#
@@ -507,10 +503,6 @@ def on_variable_unset(glob, var)
507
503
# The active session associated with the driver.
508
504
#
509
505
attr_accessor :active_session
510
- #
511
- # The active resource file being processed by the driver
512
- #
513
- attr_accessor :active_resource
514
506
515
507
def stop
516
508
framework . events . on_ui_stop ( )
You can’t perform that action at this time.
0 commit comments