metasploit-framework/tools/modules/module_description.rb

87 lines
2.0 KiB
Ruby
Raw Normal View History

2017-08-25 01:41:46 +00:00
#!/usr/bin/env ruby
2018-03-20 11:33:34 +00:00
##
# This module requires Metasploit: https://metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##
2017-08-25 01:41:46 +00:00
#
# This script lists each module with its description
#
msfbase = __FILE__
while File.symlink?(msfbase)
msfbase = File.expand_path(File.readlink(msfbase), File.dirname(msfbase))
end
$:.unshift(File.expand_path(File.join(File.dirname(msfbase), '..', '..', 'lib')))
require 'msfenv'
$:.unshift(ENV['MSF_LOCAL_LIB']) if ENV['MSF_LOCAL_LIB']
require 'rex'
require 'msf/ui'
require 'msf/base'
sort = 0
filter= 'All'
filters = ['all','exploit','payload','post','nop','encoder','auxiliary']
opts = Rex::Parser::Arguments.new(
"-h" => [ false, "Help menu." ],
"-f" => [ true, "Filter based on Module Type [#{filters.map{|f|f.capitalize}.join(", ")}] (Default = All)."],
)
opts.parse(ARGV) { |opt, idx, val|
case opt
when "-h"
puts "\nMetasploit Script for Displaying Module Descriptions."
puts "=========================================================="
puts opts.usage
exit
when "-f"
unless filters.include?(val.downcase)
puts "Invalid Filter Supplied: #{val}"
puts "Please use one of these: #{filters.map{|f|f.capitalize}.join(", ")}"
exit
end
puts "Module Filter: #{val}"
filter = val
end
}
Indent = ' '
# Always disable the database (we never need it just to list module
# information).
framework_opts = { 'DisableDatabase' => true }
# If the user only wants a particular module type, no need to load the others
if filter.downcase != 'all'
framework_opts[:module_types] = [ filter.downcase ]
end
# Initialize the simplified framework instance.
$framework = Msf::Simple::Framework.create(framework_opts)
tbl = Rex::Text::Table.new(
'Header' => 'Module Descriptions',
'Indent' => Indent.length,
'Columns' => [ 'Module', 'Description' ]
)
$framework.modules.each { |name, mod|
x = mod.new
tbl << [ x.fullname, x.description ]
}
if sort == 1
tbl.sort_rows(1)
end
puts tbl.to_s