Skip to content
This repository has been archived by the owner on Oct 22, 2020. It is now read-only.

Commit

Permalink
Fix show commands not returning results
Browse files Browse the repository at this point in the history
  • Loading branch information
rastating committed Jun 17, 2018
1 parent 9cd53e1 commit d86df57
Show file tree
Hide file tree
Showing 2 changed files with 518 additions and 20 deletions.
46 changes: 26 additions & 20 deletions lib/cli/help.rb
@@ -1,13 +1,15 @@
# frozen_string_literal: true

require 'models/module'

module Cli
# Methods for handling commands that provide the user with help info.
module Help
def print_options(mod)
print_std 'Module options:'
puts
indent_cursor do
print_options_table(mod, module_options(false))
print_options_table(mod, module_options(mod, false))
end
end

Expand All @@ -29,27 +31,27 @@ def show_options
print_payload_options(context.module.payload)
end

def print_options_table(parent, opts)
def print_options_table(mod, opts)
data = empty_option_table_data
opts.each do |opt|
data.push(option_table_row(parent, opt))
data.push(option_table_row(mod, opt))
end

print_table(data)
end

def print_advanced_option(opt)
def print_advanced_option(mod, opt)
print_std "Name: #{opt.name}"
print_std "Current setting: #{context.module.normalized_option_value(opt.name)}"
print_std "Current setting: #{mod.normalized_option_value(opt.name)}"
print_std "Required: #{opt.required?}"
print_std "Description: #{opt.desc}"
end

def show_advanced_options
return unless module_loaded?

module_options(true).each do |opt|
print_advanced_option(opt)
module_options(context.module, true).each do |opt|
print_advanced_option(context.module, opt)
puts
end
end
Expand All @@ -64,15 +66,21 @@ def help
end

def show_exploits
results = search_modules(['exploit/'])
print_good "#{results.length} Exploits"
print_module_table results
modules = 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

def show_auxiliary
results = search_modules(['auxiliary/'])
print_good "#{results.length} Auxiliary Modules"
print_module_table results
modules = 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

def show(target)
Expand All @@ -90,11 +98,9 @@ def show(target)
end
end

private

def module_options(advanced)
return [] unless context
opts = context.module.options.select { |o| o.advanced? == advanced }
def module_options(mod, advanced)
return [] if mod.nil?
opts = mod.options.select { |o| o.advanced? == advanced }
opts.sort_by(&:name)
end

Expand All @@ -107,10 +113,10 @@ def empty_option_table_data
}]
end

def option_table_row(parent, opt)
def option_table_row(mod, opt)
{
name: opt.name,
value: parent.normalized_option_value(opt.name),
value: mod.normalized_option_value(opt.name),
req: opt.required?,
desc: opt.desc
}
Expand Down

0 comments on commit d86df57

Please sign in to comment.