forked from rapid7/metasploit-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathffautoregen.rb
108 lines (88 loc) · 2.16 KB
/
ffautoregen.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#
# $Id: $
# $Revision: $
#
module Msf
###
#
# This plugin reloads and re-executes a file-format exploit module once it has changed.
#
###
class Plugin::FFAutoRegen < Msf::Plugin
###
#
# This class implements a single edit command.
#
###
class FFAutoRegenCommandDispatcher
include Msf::Ui::Console::CommandDispatcher
#
# The dispatcher's name.
#
def name
"FFAutoRegen"
end
#
# Returns the hash of commands supported by this dispatcher.
#
def commands
{
"ffautoregen" => "Automatically regenerate the document when the exploti source changes"
}
end
#
# This method handles the command.
#
def cmd_ffautoregen(*args)
if (not active_module) or (not (path = active_module.file_path))
print_line("Error: No active module selected")
return nil
end
last = mt = File.stat(path).mtime
loop {
sleep(1)
mt = File.stat(path).mtime
if (mt != last)
last = mt
omod = active_module
nmod = framework.modules.reload_module(active_module)
if not nmod
print_line("Error: Failed to reload module, trying again on next change...")
next
end
active_module = nmod
jobify = false
payload = nmod.datastore['PAYLOAD']
encoder = nmod.datastore['ENCODER']
target = nmod.datastore['TARGET']
nop = nmod.datastore['NOP']
nmod.exploit_simple(
'Encoder' => encoder,
'Payload' => payload,
'Target' => target,
'Nop' => nop,
# 'OptionStr' => opt_str,
'LocalInput' => driver.input,
'LocalOutput' => driver.output,
'RunAsJob' => jobify)
end
}
end
end
def initialize(framework, opts)
super
# console dispatcher commands.
add_console_dispatcher(FFAutoRegenCommandDispatcher)
end
def cleanup
remove_console_dispatcher('FFAutoRegen')
end
def name
"ffautoregen"
end
def desc
"FileFormat AutoRegen Plugin"
end
protected
end
end