module Wpxf::Cli::Help
Methods for handling commands that provide the user with help info.
Public Instance Methods
empty_option_table_data()
click to toggle source
# File lib/wpxf/cli/help.rb, line 106 def empty_option_table_data [{ name: 'Name', value: 'Current Setting', req: 'Required', desc: 'Description' }] end
help()
click to toggle source
# 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)
click to toggle source
# File lib/wpxf/cli/help.rb, line 100 def module_options(mod, advanced) return [] if mod.nil? opts = mod.options.select { |o| o.advanced? == advanced } opts.sort_by(&:name) end
option_table_row(mod, opt)
click to toggle source
# 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)
click to toggle source
# 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)
click to toggle source
# File lib/wpxf/cli/help.rb, line 9 def print_options(mod) print_std 'Module options:' puts indent_cursor do print_options_table(mod, module_options(mod, false)) end end
print_options_table(mod, opts)
click to toggle source
# File lib/wpxf/cli/help.rb, line 35 def print_options_table(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)
click to toggle source
# File lib/wpxf/cli/help.rb, line 17 def print_payload_options(payload) print_std 'Payload options:' puts indent_cursor do print_options_table(payload, payload.options) end end
show(target)
click to toggle source
# 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()
click to toggle source
# File lib/wpxf/cli/help.rb, line 51 def show_advanced_options return unless module_loaded?(false) module_options(context.module, true).each do |opt| print_advanced_option(context.module, opt) puts end end
show_auxiliary()
click to toggle source
# 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()
click to toggle source
# 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()
click to toggle source
# File lib/wpxf/cli/help.rb, line 25 def show_options return unless module_loaded?(false) print_options(context.module) return unless context.module.payload puts print_payload_options(context.module.payload) end