metasploit-framework/lib/msf/base/simple/exploit.rb

63 lines
1.1 KiB
Ruby
Raw Normal View History

require 'msf/base'
module Msf
module Simple
###
#
# Exploit
# -------
#
# A simplified exploit wrapper.
#
###
module Exploit
include Module
#
# Wraps the exploitation process
#
def self.exploit_simple(exploit, opts)
target_idx = opts['Target'].to_i || exploit.default_target
# Make sure parameters are valid.
if (opts['Payload'] == nil)
raise MissingPayloadError,
"You must specify a payload.", caller
end
if (target_idx == nil)
raise MissingTargetError,
"You must select a target.", caller
end
# Start it up
driver = ExploitDriver.new(exploit.framework)
# Initialize the driver instance
driver.exploit = exploit
driver.target_idx = target_idx
driver.payload = exploit.framework.modules.create(opts['Payload'])
# Force the payload to share the exploit's datastore
driver.payload.share_datastore(driver.exploit.datastore)
# Let's rock this party
session = driver.run
return session
end
#
# Calls the class method
#
def exploit_simple(opts)
Msf::Simple::Exploit.exploit_simple(self, opts)
end
end
end
end