Files

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

99 lines
2.2 KiB
Ruby
Raw Permalink Normal View History

module Msf
2013-09-30 13:47:53 -05:00
###
#
2023-01-30 12:25:46 +11:00
# This plugin reloads and re-executes a file-format exploit module once it has changed.
2013-09-30 13:47:53 -05:00
#
###
2023-01-30 12:25:46 +11:00
class Plugin::FFAutoRegen < Msf::Plugin
2013-09-30 13:47:53 -05:00
2023-01-30 12:25:46 +11:00
###
2013-09-30 13:47:53 -05:00
#
2023-01-30 12:25:46 +11:00
# This class implements a single edit command.
2013-09-30 13:47:53 -05:00
#
2023-01-30 12:25:46 +11:00
###
class FFAutoRegenCommandDispatcher
include Msf::Ui::Console::CommandDispatcher
#
# The dispatcher's name.
#
def name
'FFAutoRegen'
end
2013-09-30 13:47:53 -05:00
2023-01-30 12:25:46 +11:00
#
# Returns the hash of commands supported by this dispatcher.
#
def commands
{
'ffautoregen' => 'Automatically regenerate the document when the exploit source changes'
}
2013-09-30 13:47:53 -05:00
end
2023-01-30 12:25:46 +11:00
#
# This method handles the command.
#
def cmd_ffautoregen(*_args)
2023-01-30 13:05:34 +11:00
if !active_module || !(path = active_module.file_path)
2023-01-30 12:25:46 +11:00
print_line('Error: No active module selected')
return nil
end
last = mt = File.stat(path).mtime
2013-09-30 13:47:53 -05:00
2023-01-30 12:25:46 +11:00
loop do
sleep(1)
mt = File.stat(path).mtime
next unless (mt != last)
2013-09-30 13:47:53 -05:00
last = mt
nmod = framework.modules.reload_module(active_module)
2023-01-30 12:25:46 +11:00
if !nmod
print_line('Error: Failed to reload module, trying again on next change...')
2013-09-30 13:47:53 -05:00
next
end
2023-01-30 12:25:46 +11:00
jobify = false
2013-09-30 13:47:53 -05:00
payload = nmod.datastore['PAYLOAD']
encoder = nmod.datastore['ENCODER']
2023-01-30 12:25:46 +11:00
target = nmod.datastore['TARGET']
nop = nmod.datastore['NOP']
2013-09-30 13:47:53 -05:00
nmod.exploit_simple(
2023-01-30 12:25:46 +11:00
'Encoder' => encoder,
'Payload' => payload,
'Target' => target,
'Nop' => nop,
# 'OptionStr' => opt_str,
'LocalInput' => driver.input,
'LocalOutput' => driver.output,
'RunAsJob' => jobify
)
2013-09-30 13:47:53 -05:00
end
2023-01-30 12:25:46 +11:00
end
2013-09-30 13:47:53 -05:00
end
2023-01-30 12:25:46 +11:00
def initialize(framework, opts)
super
2013-09-30 13:47:53 -05:00
2023-01-30 12:25:46 +11:00
# console dispatcher commands.
add_console_dispatcher(FFAutoRegenCommandDispatcher)
end
2013-09-30 13:47:53 -05:00
2023-01-30 12:25:46 +11:00
def cleanup
remove_console_dispatcher('FFAutoRegen')
end
2013-09-30 13:47:53 -05:00
2023-01-30 12:25:46 +11:00
def name
'ffautoregen'
end
2023-01-30 12:25:46 +11:00
def desc
'This plugin reloads and re-executes a file-format exploit module once it has changed'
2023-01-30 12:25:46 +11:00
end
2023-01-30 12:25:46 +11:00
end
end