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
|
# File 'lib/msf/base/simple/evasion.rb', line 10
def self.run_simple(oevasion, opts, &block)
evasion = oevasion.replicant
begin
Msf::Simple::Framework.simplify_module(evasion)
yield(evasion) if block_given?
evasion.(opts)
if (opts['Payload'] == nil)
raise MissingPayloadError.new, 'A payload has not been selected.', caller
end
evasion.options.validate(evasion.datastore)
driver = EvasionDriver.new(evasion.framework)
driver.evasion = evasion
driver.payload = evasion.framework.payloads.create(opts['Payload'])
if (driver.payload == nil)
raise MissingPayloadError,
"You specified an invalid payload: #{opts['Payload']}", caller
end
evasion.datastore['ENCODER'] = opts['Encoder'] if opts['Encoder']
evasion.datastore['NOP'] = opts['Nop'] if opts['Nop']
driver.payload.share_datastore(driver.evasion.datastore)
driver.payload.options.validate(driver.payload.datastore)
evasion.datastore['TARGET'] = opts['Target'] if opts['Target']
target_idx = evasion.target_index
if (target_idx == nil or target_idx < 0)
raise MissingTargetError,
"You must select a target.", caller
end
driver.target_idx = target_idx
if ! opts['Quiet']
driver.evasion.init_ui(opts['LocalInput'] || evasion.user_input, opts['LocalOutput'] || evasion.user_output)
driver.payload.init_ui(opts['LocalInput'] || evasion.user_input, opts['LocalOutput'] || evasion.user_output)
else
driver.evasion.init_ui(nil, nil)
driver.payload.init_ui(nil, nil)
end
if (opts['RunAsJob'])
driver.use_job = true
end
driver.run
evasion.job_id = driver.job_id
oevasion.job_id = evasion.job_id
rescue ::Interrupt
evasion.error = $!
raise $!
rescue ::Msf::OptionValidateError => e
evasion.error = e
::Msf::Ui::Formatter::OptionValidateError.print_error(evasion, e)
rescue ::Exception => e
evasion.error = e
evasion.print_error("evasion failed: #{e}")
elog("Evasion failed (#{evasion.refname})", error: e)
end
nil
end
|