add on_module_complete and on_module_error events
git-svn-id: file:///home/svn/framework3/trunk@8837 4d416f70-5f16-0410-b530-b9f4589650daunstable
parent
38fe469ce8
commit
efceaa84cf
|
@ -119,6 +119,7 @@ protected
|
||||||
# Clean up the module after the job completes.
|
# Clean up the module after the job completes.
|
||||||
#
|
#
|
||||||
def self.job_cleanup_proc(mod)
|
def self.job_cleanup_proc(mod)
|
||||||
|
mod.framework.events.on_module_complete(mod)
|
||||||
# Allow the exploit to cleanup after itself, that messy bugger.
|
# Allow the exploit to cleanup after itself, that messy bugger.
|
||||||
mod.cleanup
|
mod.cleanup
|
||||||
end
|
end
|
||||||
|
|
|
@ -27,6 +27,18 @@ module GeneralEventSubscriber
|
||||||
def on_module_run(instance)
|
def on_module_run(instance)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
#
|
||||||
|
# Called when a module finishes
|
||||||
|
#
|
||||||
|
def on_module_complete(instance)
|
||||||
|
end
|
||||||
|
|
||||||
|
#
|
||||||
|
# Called when a module raises an exception
|
||||||
|
#
|
||||||
|
def on_module_error(instance, exception)
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
###
|
###
|
||||||
|
|
|
@ -185,6 +185,7 @@ protected
|
||||||
end
|
end
|
||||||
rescue ::Exception
|
rescue ::Exception
|
||||||
|
|
||||||
|
exploit.framework.events.on_module_error(exploit, $!)
|
||||||
exploit.print_error("Exploit failed: #{$!}")
|
exploit.print_error("Exploit failed: #{$!}")
|
||||||
elog("Exploit failed (#{exploit.refname}): #{$!}", 'core', LEV_0)
|
elog("Exploit failed (#{exploit.refname}): #{$!}", 'core', LEV_0)
|
||||||
dlog("Call stack:\n#{$@.join("\n")}", 'core', LEV_3)
|
dlog("Call stack:\n#{$@.join("\n")}", 'core', LEV_3)
|
||||||
|
@ -204,6 +205,8 @@ protected
|
||||||
# Ensure that, no matter what, clean up of the handler occurs
|
# Ensure that, no matter what, clean up of the handler occurs
|
||||||
payload.stop_handler
|
payload.stop_handler
|
||||||
|
|
||||||
|
exploit.framework.events.on_module_complete(exploit)
|
||||||
|
|
||||||
# Allow the exploit to cleanup after itself, that messy bugger.
|
# Allow the exploit to cleanup after itself, that messy bugger.
|
||||||
exploit.cleanup
|
exploit.cleanup
|
||||||
end
|
end
|
||||||
|
|
|
@ -201,19 +201,35 @@ class FrameworkEventSubscriber
|
||||||
end
|
end
|
||||||
|
|
||||||
include GeneralEventSubscriber
|
include GeneralEventSubscriber
|
||||||
def on_module_run(instance)
|
|
||||||
|
#
|
||||||
|
# Generic handler for module events
|
||||||
|
#
|
||||||
|
def module_event(name, instance, opts={})
|
||||||
if framework.db.active
|
if framework.db.active
|
||||||
event = {
|
event = {
|
||||||
:workspace => framework.db.find_workspace(instance.workspace),
|
:workspace => framework.db.find_workspace(instance.workspace),
|
||||||
:name => "module_run",
|
:name => name,
|
||||||
:info => {
|
:info => {
|
||||||
:module_name => instance.fullname,
|
:module_name => instance.fullname,
|
||||||
:datastore => instance.datastore.to_h
|
}.merge(opts)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
report_event(event)
|
report_event(event)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
def on_module_run(instance)
|
||||||
|
opts = { :datastore => instance.datastore.to_h }
|
||||||
|
module_event('module_run', instance, opts)
|
||||||
|
end
|
||||||
|
|
||||||
|
def on_module_complete(instance)
|
||||||
|
module_event('module_complete', instance)
|
||||||
|
end
|
||||||
|
|
||||||
|
def on_module_error(instance, exception=nil)
|
||||||
|
module_event('module_error', instance, :exception => exception.to_s)
|
||||||
|
end
|
||||||
|
|
||||||
include ::Msf::UiEventSubscriber
|
include ::Msf::UiEventSubscriber
|
||||||
def on_ui_command(command)
|
def on_ui_command(command)
|
||||||
|
@ -238,6 +254,9 @@ class FrameworkEventSubscriber
|
||||||
#report_event(:name => "ui_start", :info => info)
|
#report_event(:name => "ui_start", :info => info)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
#
|
||||||
|
# Generic handler for session events
|
||||||
|
#
|
||||||
def session_event(name, session, opts={})
|
def session_event(name, session, opts={})
|
||||||
address = session.tunnel_peer[0, session.tunnel_peer.rindex(":") || session.tunnel_peer.length ]
|
address = session.tunnel_peer[0, session.tunnel_peer.rindex(":") || session.tunnel_peer.length ]
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue