Log the exploit name when the module raises an exception, helps track down bugs during automation
git-svn-id: file:///home/svn/framework3/trunk@7529 4d416f70-5f16-0410-b530-b9f4589650daunstable
parent
7fb9c4a791
commit
ba5da501bf
|
@ -58,13 +58,13 @@ module Exploit
|
|||
|
||||
# Trap and print errors here (makes them UI-independent)
|
||||
begin
|
||||
|
||||
|
||||
# Import options from the OptionStr or Option hash.
|
||||
exploit._import_extra_options(opts)
|
||||
|
||||
# Make sure parameters are valid.
|
||||
if (opts['Payload'] == nil)
|
||||
raise MissingPayloadError,
|
||||
raise MissingPayloadError,
|
||||
"You must specify a payload.", caller
|
||||
end
|
||||
|
||||
|
@ -107,7 +107,7 @@ module Exploit
|
|||
"You must select a target.", caller
|
||||
end
|
||||
|
||||
driver.target_idx = target_idx
|
||||
driver.target_idx = target_idx
|
||||
|
||||
# Set the payload and exploit's subscriber values
|
||||
driver.exploit.init_ui(opts['LocalInput'], opts['LocalOutput'])
|
||||
|
@ -129,10 +129,10 @@ module Exploit
|
|||
raise $!
|
||||
rescue ::Exception => e
|
||||
exploit.print_error("Exploit failed: #{e}")
|
||||
elog("Exploit failed: #{e}", 'core', LEV_0)
|
||||
dlog("Call stack:\n#{e.backtrace.join("\n")}", 'core', LEV_3)
|
||||
elog("Exploit failed (#{exploit.refname}): #{e}", 'core', LEV_0)
|
||||
dlog("Call stack:\n#{e.backtrace.join("\n")}", 'core', LEV_3)
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
#
|
||||
|
@ -171,10 +171,11 @@ module Exploit
|
|||
# Calls the class method.
|
||||
#
|
||||
def check_simple(opts)
|
||||
Msf::Simple::Exploit.check_simple(self, opts)
|
||||
Msf::Simple::Exploit.check_simple(self, opts)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -69,20 +69,20 @@ class ExploitDriver
|
|||
def validate
|
||||
# First, validate that a target has been selected
|
||||
if (target_idx == nil)
|
||||
raise MissingTargetError,
|
||||
raise MissingTargetError,
|
||||
"A payload cannot be selected until a target is specified.",
|
||||
caller
|
||||
end
|
||||
|
||||
# Next, validate that a payload has been selected
|
||||
if (payload == nil)
|
||||
raise MissingPayloadError,
|
||||
raise MissingPayloadError,
|
||||
"A payload has not been selected.", caller
|
||||
end
|
||||
|
||||
# Make sure the payload is compatible after all
|
||||
if (compatible_payload?(payload) == false)
|
||||
raise IncompatiblePayloadError.new(payload.refname),
|
||||
raise IncompatiblePayloadError.new(payload.refname),
|
||||
"Incompatible payload", caller
|
||||
end
|
||||
|
||||
|
@ -111,10 +111,10 @@ class ExploitDriver
|
|||
# - Cleans up the handler
|
||||
#
|
||||
def run
|
||||
|
||||
|
||||
# Set up the run context
|
||||
ctx = [ exploit, payload ]
|
||||
|
||||
|
||||
# First thing's first -- validate the state. Make sure all requirement
|
||||
# parameters are set, including those that are derived from the
|
||||
# datastore.
|
||||
|
@ -135,11 +135,11 @@ class ExploitDriver
|
|||
# like a good person.
|
||||
if (use_job or exploit.stance == Msf::Exploit::Stance::Passive)
|
||||
self.job_id = exploit.framework.jobs.start_bg_job(
|
||||
"Exploit: #{exploit.refname}",
|
||||
"Exploit: #{exploit.refname}",
|
||||
ctx,
|
||||
Proc.new { |ctx_| job_run_proc(ctx_) },
|
||||
Proc.new { |ctx_| job_cleanup_proc(ctx_) }
|
||||
)
|
||||
)
|
||||
else
|
||||
job_run_proc(ctx)
|
||||
job_cleanup_proc(ctx)
|
||||
|
@ -155,7 +155,7 @@ class ExploitDriver
|
|||
# The identifier of the job this exploit is launched as, if it's run as a
|
||||
# job.
|
||||
#
|
||||
attr_accessor :job_id
|
||||
attr_accessor :job_id
|
||||
attr_accessor :force_wait_for_session # :nodoc:
|
||||
|
||||
protected
|
||||
|
@ -168,7 +168,7 @@ protected
|
|||
def job_run_proc(ctx)
|
||||
begin
|
||||
exploit, payload = ctx
|
||||
|
||||
|
||||
# Set the exploit up the bomb
|
||||
exploit.setup
|
||||
|
||||
|
@ -182,9 +182,9 @@ protected
|
|||
(exploit.passive? == true) ? nil : payload.wfs_delay + exploit.wfs_delay)
|
||||
end
|
||||
rescue ::Exception
|
||||
|
||||
|
||||
exploit.print_error("Exploit failed: #{$!}")
|
||||
elog("Exploit failed: #{$!}", 'core', LEV_0)
|
||||
elog("Exploit failed (#{exploit.refname}): #{$!}", 'core', LEV_0)
|
||||
dlog("Call stack:\n#{$@.join("\n")}", 'core', LEV_3)
|
||||
|
||||
payload.stop_handler
|
||||
|
@ -198,10 +198,10 @@ protected
|
|||
#
|
||||
def job_cleanup_proc(ctx)
|
||||
exploit, payload = ctx
|
||||
|
||||
|
||||
# Ensure that, no matter what, clean up of the handler occurs
|
||||
payload.stop_handler
|
||||
|
||||
|
||||
# Allow the exploit to cleanup after itself, that messy bugger.
|
||||
exploit.cleanup
|
||||
end
|
||||
|
@ -209,3 +209,4 @@ protected
|
|||
end
|
||||
|
||||
end
|
||||
|
||||
|
|
|
@ -59,7 +59,7 @@ class Exploit
|
|||
if (code == Msf::Exploit::CheckCode::Vulnerable)
|
||||
stat = '[+]'
|
||||
end
|
||||
|
||||
|
||||
print_line(stat + ' ' + code[1])
|
||||
else
|
||||
print_error(
|
||||
|
@ -136,7 +136,7 @@ class Exploit
|
|||
rescue ::Interrupt
|
||||
raise $!
|
||||
rescue ::Exception => e
|
||||
print_error("Exploit failed: #{e.class} #{e}")
|
||||
print_error("Exploit failed (#{mod.refname}): #{e.class} #{e}")
|
||||
if(e.class.to_s != 'Msf::OptionValidateError')
|
||||
print_error("Call stack:")
|
||||
e.backtrace.each do |line|
|
||||
|
@ -148,7 +148,7 @@ class Exploit
|
|||
|
||||
# If we were given a session, let's see what we can do with it
|
||||
if (session)
|
||||
|
||||
|
||||
# If we aren't told to run in the background and the session can be
|
||||
# interacted with, start interacting with it by issuing the session
|
||||
# interaction command.
|
||||
|
@ -182,7 +182,7 @@ class Exploit
|
|||
self.mod = omod
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
self.mod.init_ui(driver.input, driver.output)
|
||||
cmd_check(*args)
|
||||
end
|
||||
|
@ -200,7 +200,7 @@ class Exploit
|
|||
|
||||
omod = self.mod
|
||||
self.mod = framework.modules.reload_module(mod)
|
||||
|
||||
|
||||
if(not self.mod)
|
||||
print_status("Failed to reload module: #{framework.modules.failed[omod.file_path]}")
|
||||
self.mod = omod
|
||||
|
@ -215,3 +215,4 @@ class Exploit
|
|||
end
|
||||
|
||||
end end end end
|
||||
|
||||
|
|
Loading…
Reference in New Issue