Land #9324, AutoRunScript with resource scripts
commit
31042d4171
|
@ -302,11 +302,15 @@ class Meterpreter < Rex::Post::Meterpreter::Client
|
|||
##
|
||||
# :category: Msf::Session::Scriptable implementors
|
||||
#
|
||||
# Runs the meterpreter script in the context of a script container
|
||||
# Runs the Meterpreter script or resource file
|
||||
#
|
||||
def execute_file(full_path, args)
|
||||
o = Rex::Script::Meterpreter.new(self, full_path)
|
||||
o.run(args)
|
||||
# Infer a Meterpreter script by it having an .rb extension
|
||||
if File.extname(full_path) == ".rb"
|
||||
Rex::Script::Meterpreter.new(self, full_path).run(args)
|
||||
else
|
||||
console.load_resource(full_path)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
|
|
@ -164,13 +164,17 @@ module Scriptable
|
|||
else
|
||||
full_path = self.class.find_script_path(script_name)
|
||||
|
||||
# No path found? Weak.
|
||||
if full_path.nil?
|
||||
print_error("The specified script could not be found: #{script_name}")
|
||||
return true
|
||||
return
|
||||
end
|
||||
|
||||
begin
|
||||
execute_file(full_path, args)
|
||||
framework.events.on_session_script_run(self, full_path)
|
||||
rescue StandardError => e
|
||||
print_error("Could not execute #{script_name}: #{e.class} #{e}")
|
||||
end
|
||||
framework.events.on_session_script_run(self, full_path)
|
||||
execute_file(full_path, args)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -313,8 +313,6 @@ class Driver < Msf::Ui::Driver
|
|||
return
|
||||
end
|
||||
|
||||
self.active_resource = resource_file
|
||||
|
||||
# Process ERB directives first
|
||||
print_status "Processing #{path} for ERB directives."
|
||||
erb = ERB.new(resource_file)
|
||||
|
@ -362,8 +360,6 @@ class Driver < Msf::Ui::Driver
|
|||
run_single(line)
|
||||
end
|
||||
end
|
||||
|
||||
self.active_resource = nil
|
||||
end
|
||||
|
||||
#
|
||||
|
@ -507,10 +503,6 @@ class Driver < Msf::Ui::Driver
|
|||
# The active session associated with the driver.
|
||||
#
|
||||
attr_accessor :active_session
|
||||
#
|
||||
# The active resource file being processed by the driver
|
||||
#
|
||||
attr_accessor :active_resource
|
||||
|
||||
def stop
|
||||
framework.events.on_ui_stop()
|
||||
|
|
Loading…
Reference in New Issue