Skip to content

Instantly share code, notes, and snippets.

@bka
Created March 18, 2011 12:57
Show Gist options
  • Save bka/876023 to your computer and use it in GitHub Desktop.
Save bka/876023 to your computer and use it in GitHub Desktop.
metasploit callbacks sample on_ui_command and on_module_run
module Msf
module Ui
module Console
class Driver < Msf::Ui::Driver
alias_method :old_unknown_command, :unknown_command
def unknown_command(method, line)
self.on_command_proc.call(line.strip) if self.on_command_proc
old_unknown_command(method,line)
end
end
end
end
end
module Msf
class Plugin::ConsoleUICallback < Msf::Plugin
class ModuleRunCallback
def on_module_run(instance)
puts "RPORT is: #{instance.datastore["RPORT"]}"
puts "run instance: #{instance.inspect}"
end
end
class UICallback
def on_ui_command(line)
puts "ui_command: #{line}"
end
end
def initialize(framework, opts)
super
framework.events.add_ui_subscriber(UICallback.new)
framework.events.add_general_subscriber(ModuleRunCallback.new)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment