Module: Wpxf::Cli::LoadedModule
Overview
Methods for handling commands that interact with the currently loaded module.
Instance Method Summary
collapse
Methods included from ModuleInfo
#formatted_module_description, #info, #print_author, #print_description, #print_module_summary, #print_references
Instance Method Details
#check ⇒ Object
53
54
55
56
57
58
59
60
61
62
63
64
|
# File 'lib/wpxf/cli/loaded_module.rb', line 53
def check
return unless module_loaded?(false) && module_can_execute?
state = context.module.check
if state == :vulnerable
print_warning 'Target appears to be vulnerable'
elsif state == :unknown
print_bad 'Could not determine if the target is vulnerable'
else
print_good 'Target appears to be safe'
end
end
|
#execute_module ⇒ Object
31
32
33
34
35
36
37
38
|
# File 'lib/wpxf/cli/loaded_module.rb', line 31
def execute_module
mod = context.module
mod.run && (!mod.payload || mod.payload.post_exploit(mod))
rescue StandardError => e
print_bad "Uncaught error: #{e}"
print_bad e.backtrace.join("\n\t")
false
end
|
#module_can_execute? ⇒ Boolean
16
17
18
19
20
21
22
23
|
# File 'lib/wpxf/cli/loaded_module.rb', line 16
def module_can_execute?
can_execute = context.module.can_execute?
unless can_execute
opts = context.module.missing_options.join(', ')
print_bad "One or more required options not set: #{opts}"
end
can_execute
end
|
#module_loaded?(quiet = true) ⇒ Boolean
11
12
13
14
|
# File 'lib/wpxf/cli/loaded_module.rb', line 11
def module_loaded?(quiet = true)
print_warning 'No module loaded' if context.nil? && !quiet
!context.nil?
end
|
#payload_prepared? ⇒ Boolean
25
26
27
28
29
|
# File 'lib/wpxf/cli/loaded_module.rb', line 25
def payload_prepared?
failed = context.module.payload && !context.module.payload.prepare(context.module)
print_bad 'Failed to prepare the payload' if failed
!failed
end
|
#run ⇒ Object
40
41
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/wpxf/cli/loaded_module.rb', line 40
def run
return unless module_loaded?(false) && module_can_execute? && payload_prepared?
if execute_module
print_good 'Execution finished successfully'
else
print_bad 'Execution failed'
end
context.module.cleanup
self.indent_level = 1
end
|