|
| 1 | +#!/usr/bin/env ruby |
| 2 | +# |
| 3 | +# $Id$ |
| 4 | +# |
| 5 | +# This script lists each module with its description |
| 6 | +# |
| 7 | +# $Revision$ |
| 8 | +# |
| 9 | + |
| 10 | +msfbase = __FILE__ |
| 11 | +while File.symlink?(msfbase) |
| 12 | + msfbase = File.expand_path(File.readlink(msfbase), File.dirname(msfbase)) |
| 13 | +end |
| 14 | + |
| 15 | +$:.unshift(File.expand_path(File.join(File.dirname(msfbase), '..', '..', 'lib'))) |
| 16 | +require 'msfenv' |
| 17 | + |
| 18 | +$:.unshift(ENV['MSF_LOCAL_LIB']) if ENV['MSF_LOCAL_LIB'] |
| 19 | + |
| 20 | +require 'rex' |
| 21 | +require 'msf/ui' |
| 22 | +require 'msf/base' |
| 23 | + |
| 24 | +sort = 0 |
| 25 | +filter= 'All' |
| 26 | +filters = ['all','exploit','payload','post','nop','encoder','auxiliary'] |
| 27 | + |
| 28 | +opts = Rex::Parser::Arguments.new( |
| 29 | + "-h" => [ false, "Help menu." ], |
| 30 | + "-f" => [ true, "Filter based on Module Type [#{filters.map{|f|f.capitalize}.join(", ")}] (Default = All)."], |
| 31 | +) |
| 32 | + |
| 33 | +opts.parse(ARGV) { |opt, idx, val| |
| 34 | + case opt |
| 35 | + when "-h" |
| 36 | + puts "\nMetasploit Script for Displaying Module Descriptions." |
| 37 | + puts "==========================================================" |
| 38 | + puts opts.usage |
| 39 | + exit |
| 40 | + when "-f" |
| 41 | + unless filters.include?(val.downcase) |
| 42 | + puts "Invalid Filter Supplied: #{val}" |
| 43 | + puts "Please use one of these: #{filters.map{|f|f.capitalize}.join(", ")}" |
| 44 | + exit |
| 45 | + end |
| 46 | + puts "Module Filter: #{val}" |
| 47 | + filter = val |
| 48 | + |
| 49 | + end |
| 50 | + |
| 51 | +} |
| 52 | + |
| 53 | + |
| 54 | +Indent = ' ' |
| 55 | + |
| 56 | +# Always disable the database (we never need it just to list module |
| 57 | +# information). |
| 58 | +framework_opts = { 'DisableDatabase' => true } |
| 59 | + |
| 60 | +# If the user only wants a particular module type, no need to load the others |
| 61 | +if filter.downcase != 'all' |
| 62 | + framework_opts[:module_types] = [ filter.downcase ] |
| 63 | +end |
| 64 | + |
| 65 | +# Initialize the simplified framework instance. |
| 66 | +$framework = Msf::Simple::Framework.create(framework_opts) |
| 67 | + |
| 68 | + |
| 69 | +tbl = Rex::Text::Table.new( |
| 70 | + 'Header' => 'Module Descriptions', |
| 71 | + 'Indent' => Indent.length, |
| 72 | + 'Columns' => [ 'Module', 'Description' ] |
| 73 | +) |
| 74 | + |
| 75 | +$framework.modules.each { |name, mod| |
| 76 | + x = mod.new |
| 77 | + tbl << [ x.fullname, x.description ] |
| 78 | +} |
| 79 | + |
| 80 | +if sort == 1 |
| 81 | + tbl.sort_rows(1) |
| 82 | +end |
| 83 | + |
| 84 | +puts tbl.to_s |
0 commit comments