2010-04-02 00:34:17 +00:00
|
|
|
#!/usr/bin/env ruby
|
|
|
|
#
|
|
|
|
# $Id$
|
|
|
|
#
|
2010-06-15 07:14:29 +00:00
|
|
|
# This script lists all modules with their targets
|
2010-04-02 00:34:17 +00:00
|
|
|
#
|
2010-05-03 17:13:09 +00:00
|
|
|
# $Revision$
|
|
|
|
#
|
2010-04-02 00:34:17 +00:00
|
|
|
|
2012-02-04 06:38:21 +00:00
|
|
|
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 'fastlib'
|
|
|
|
|
|
|
|
$:.unshift(ENV['MSF_LOCAL_LIB']) if ENV['MSF_LOCAL_LIB']
|
2010-04-02 00:34:17 +00:00
|
|
|
|
|
|
|
require 'rex'
|
|
|
|
require 'msf/ui'
|
|
|
|
require 'msf/base'
|
|
|
|
|
2011-06-07 00:20:21 +00:00
|
|
|
sort=0
|
|
|
|
fil = 0
|
|
|
|
filter = ""
|
|
|
|
|
|
|
|
opts = Rex::Parser::Arguments.new(
|
|
|
|
"-h" => [ false, "Help menu." ],
|
|
|
|
"-s" => [ false, "Sort by Target instead of Module Type."],
|
|
|
|
"-r" => [ false, "Reverse Sort"],
|
|
|
|
"-x" => [ true, "String or RegEx to try and match against the Targets field"]
|
|
|
|
)
|
|
|
|
|
|
|
|
opts.parse(ARGV) { |opt, idx, val|
|
|
|
|
case opt
|
|
|
|
when "-h"
|
|
|
|
puts "\nMetasploit Script for Displaying Module Target information."
|
|
|
|
puts "=========================================================="
|
|
|
|
puts opts.usage
|
|
|
|
exit
|
|
|
|
when "-s"
|
|
|
|
puts "Sorting by Target"
|
|
|
|
sort = 1
|
|
|
|
when "-r"
|
|
|
|
puts "Reverse Sorting"
|
|
|
|
sort = 2
|
|
|
|
when "-x"
|
|
|
|
puts "Filter: #{val}"
|
|
|
|
filter = val
|
|
|
|
fil=1
|
|
|
|
end
|
|
|
|
}
|
|
|
|
|
2010-04-02 00:34:17 +00:00
|
|
|
Indent = ' '
|
|
|
|
|
|
|
|
# Initialize the simplified framework instance.
|
2010-10-12 15:57:58 +00:00
|
|
|
$framework = Msf::Simple::Framework.create('DisableDatabase' => true)
|
2010-04-02 00:34:17 +00:00
|
|
|
|
|
|
|
tbl = Rex::Ui::Text::Table.new(
|
|
|
|
'Header' => 'Module Targets',
|
|
|
|
'Indent' => Indent.length,
|
|
|
|
'Columns' => [ 'Module name','Target' ]
|
|
|
|
)
|
|
|
|
|
|
|
|
all_modules = $framework.exploits
|
|
|
|
|
|
|
|
all_modules.each_module { |name, mod|
|
|
|
|
x = mod.new
|
|
|
|
x.targets.each do |targ|
|
2011-06-07 00:20:21 +00:00
|
|
|
if fil==0 or targ.name=~/#{filter}/
|
|
|
|
tbl << [ x.fullname, targ.name ]
|
|
|
|
end
|
2010-04-02 00:34:17 +00:00
|
|
|
end
|
|
|
|
}
|
|
|
|
|
2011-06-07 00:20:21 +00:00
|
|
|
if sort == 1
|
|
|
|
tbl.sort_rows(1)
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
if sort == 2
|
|
|
|
tbl.sort_rows(1)
|
|
|
|
tbl.rows.reverse
|
|
|
|
end
|
|
|
|
|
2010-04-02 00:34:17 +00:00
|
|
|
puts tbl.to_s
|