Module: Wpxf::Cli::Help
- Included in:
- Console
- Defined in:
- lib/wpxf/cli/help.rb
Overview
Methods for handling commands that provide the user with help info.
Instance Method Summary collapse
- #empty_option_table_data ⇒ Object
- #help ⇒ Object
- #module_options(mod, advanced) ⇒ Object
- #option_table_row(mod, opt) ⇒ Object
- #print_advanced_option(mod, opt) ⇒ Object
- #print_options(mod) ⇒ Object
- #print_options_table(mod, opts) ⇒ Object
- #print_payload_options(payload) ⇒ Object
- #show(target) ⇒ Object
- #show_advanced_options ⇒ Object
- #show_auxiliary ⇒ Object
- #show_exploits ⇒ Object
- #show_options ⇒ Object
Instance Method Details
#empty_option_table_data ⇒ Object
106 107 108 109 110 111 112 113 |
# File 'lib/wpxf/cli/help.rb', line 106 def empty_option_table_data [{ name: 'Name', value: 'Current Setting', req: 'Required', desc: 'Description' }] end |
#help ⇒ Object
60 61 62 63 64 65 |
# File 'lib/wpxf/cli/help.rb', line 60 def help commands_file = Wpxf::DataFile.new('json', 'commands.json') data = JSON.parse(commands_file.content)['data'] data.unshift('cmd' => 'Command', 'desc' => 'Description') print_table data end |
#module_options(mod, advanced) ⇒ Object
100 101 102 103 104 |
# File 'lib/wpxf/cli/help.rb', line 100 def (mod, advanced) return [] if mod.nil? opts = mod..select { |o| o.advanced? == advanced } opts.sort_by(&:name) end |
#option_table_row(mod, opt) ⇒ Object
115 116 117 118 119 120 121 122 |
# File 'lib/wpxf/cli/help.rb', line 115 def option_table_row(mod, opt) { name: opt.name, value: mod.normalized_option_value(opt.name), req: opt.required?, desc: opt.desc } end |
#print_advanced_option(mod, opt) ⇒ Object
44 45 46 47 48 49 |
# File 'lib/wpxf/cli/help.rb', line 44 def print_advanced_option(mod, opt) print_std "Name: #{opt.name}" print_std "Current setting: #{mod.normalized_option_value(opt.name)}" print_std "Required: #{opt.required?}" print_std "Description: #{opt.desc}" end |
#print_options(mod) ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/wpxf/cli/help.rb', line 9 def (mod) print_std 'Module options:' puts indent_cursor do (mod, (mod, false)) end end |
#print_options_table(mod, opts) ⇒ Object
35 36 37 38 39 40 41 42 |
# File 'lib/wpxf/cli/help.rb', line 35 def (mod, opts) data = empty_option_table_data opts.each do |opt| data.push(option_table_row(mod, opt)) end print_table(data) end |
#print_payload_options(payload) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/wpxf/cli/help.rb', line 17 def (payload) print_std 'Payload options:' puts indent_cursor do (payload, payload.) end end |
#show(target) ⇒ Object
85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/wpxf/cli/help.rb', line 85 def show(target) handlers = { 'options' => 'show_options', 'advanced' => 'show_advanced_options', 'exploits' => 'show_exploits', 'auxiliary' => 'show_auxiliary' } if handlers[target] send(handlers[target]) else print_bad("\"#{target}\" is not a valid argument") end end |
#show_advanced_options ⇒ Object
51 52 53 54 55 56 57 58 |
# File 'lib/wpxf/cli/help.rb', line 51 def return unless module_loaded?(false) (context.module, true).each do |opt| print_advanced_option(context.module, opt) puts end end |
#show_auxiliary ⇒ Object
76 77 78 79 80 81 82 83 |
# File 'lib/wpxf/cli/help.rb', line 76 def show_auxiliary modules = Wpxf::Models::Module.where(type: 'auxiliary') .order(:path) .map { |m| { path: m.path, title: m.name } } print_good "#{modules.length} Auxiliaries" print_module_table modules end |
#show_exploits ⇒ Object
67 68 69 70 71 72 73 74 |
# File 'lib/wpxf/cli/help.rb', line 67 def show_exploits modules = Wpxf::Models::Module.where(type: 'exploit') .order(:path) .map { |m| { path: m.path, title: m.name } } print_good "#{modules.length} Exploits" print_module_table modules end |
#show_options ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'lib/wpxf/cli/help.rb', line 25 def return unless module_loaded?(false) (context.module) return unless context.module.payload puts (context.module.payload) end |