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