2009-09-27 21:31:33 +00:00
|
|
|
#!/usr/bin/env ruby
|
|
|
|
#
|
2010-05-03 17:13:09 +00:00
|
|
|
# $Id$
|
|
|
|
# $Revision$
|
|
|
|
#
|
2010-06-15 07:14:29 +00:00
|
|
|
# This script lists each module by its author(s) and
|
|
|
|
# the number of modules per author
|
2009-09-27 21:31:33 +00:00
|
|
|
#
|
|
|
|
|
|
|
|
msfbase = File.symlink?(__FILE__) ? File.readlink(__FILE__) : __FILE__
|
|
|
|
$:.unshift(File.join(File.dirname(msfbase), '..', 'lib'))
|
|
|
|
|
|
|
|
require 'rex'
|
|
|
|
require 'msf/ui'
|
|
|
|
require 'msf/base'
|
|
|
|
|
2011-06-07 01:25:12 +00:00
|
|
|
sort = 0
|
|
|
|
filter = 'All'
|
|
|
|
filters = ['all','exploit','payload','post','nOP','encoder','auxiliary']
|
|
|
|
reg = 0
|
|
|
|
regex = nil
|
2011-06-07 00:20:21 +00:00
|
|
|
|
|
|
|
opts = Rex::Parser::Arguments.new(
|
|
|
|
"-h" => [ false, "Help menu." ],
|
|
|
|
"-s" => [ false, "Sort by Author instead of Module Type."],
|
|
|
|
"-r" => [ false, "Reverse Sort"],
|
2011-06-07 01:25:12 +00:00
|
|
|
"-f" => [ true, "Filter based on Module Type [#{filters.map{|f|f.capitalize}.join(", ")}] (Default = All)."],
|
2011-06-07 00:20:21 +00:00
|
|
|
"-x" => [ true, "String or RegEx to try and match against the Author Field"]
|
|
|
|
)
|
|
|
|
|
|
|
|
opts.parse(ARGV) { |opt, idx, val|
|
|
|
|
case opt
|
|
|
|
when "-h"
|
|
|
|
puts "\nMetasploit Script for Displaying Module Author information."
|
|
|
|
puts "=========================================================="
|
|
|
|
puts opts.usage
|
|
|
|
exit
|
|
|
|
when "-s"
|
|
|
|
puts "Sorting by Author"
|
|
|
|
sort = 1
|
|
|
|
when "-r"
|
|
|
|
puts "Reverse Sorting"
|
|
|
|
sort = 2
|
|
|
|
when "-f"
|
2011-06-07 01:25:12 +00:00
|
|
|
unless filters.include?(val.downcase)
|
2011-06-07 00:20:21 +00:00
|
|
|
puts "Invalid Filter Supplied: #{val}"
|
2011-06-07 01:25:12 +00:00
|
|
|
puts "Please use one of these: #{filters.map{|f|f.capitalize}.join(", ")}"
|
2011-06-07 00:20:21 +00:00
|
|
|
exit
|
|
|
|
end
|
|
|
|
puts "Module Filter: #{val}"
|
|
|
|
filter = val
|
|
|
|
when "-x"
|
|
|
|
puts "Regex: #{val}"
|
2011-06-07 01:25:12 +00:00
|
|
|
regex = Regexp.new(val)
|
2011-06-07 00:20:21 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-05-03 17:13:09 +00:00
|
|
|
Indent = ' '
|
2009-09-27 21:31:33 +00:00
|
|
|
|
2011-06-07 01:25:12 +00:00
|
|
|
# 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
|
|
|
|
|
2009-09-27 21:31:33 +00:00
|
|
|
# Initialize the simplified framework instance.
|
2011-06-07 01:25:12 +00:00
|
|
|
$framework = Msf::Simple::Framework.create(framework_opts)
|
|
|
|
|
2009-09-27 21:31:33 +00:00
|
|
|
|
|
|
|
tbl = Rex::Ui::Text::Table.new(
|
|
|
|
'Header' => 'Module References',
|
|
|
|
'Indent' => Indent.length,
|
|
|
|
'Columns' => [ 'Module', 'Reference' ]
|
|
|
|
)
|
|
|
|
|
|
|
|
names = {}
|
|
|
|
|
2011-06-07 01:25:12 +00:00
|
|
|
$framework.modules.each { |name, mod|
|
|
|
|
x = mod.new
|
|
|
|
x.author.each do |r|
|
|
|
|
r = r.to_s
|
|
|
|
if regex.nil? or r =~ regex
|
|
|
|
tbl << [ x.fullname, r ]
|
|
|
|
names[r] ||= 0
|
|
|
|
names[r] += 1
|
2011-06-07 00:20:21 +00:00
|
|
|
end
|
2011-06-07 01:25:12 +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
|
2009-09-27 21:31:33 +00:00
|
|
|
|
|
|
|
puts tbl.to_s
|
|
|
|
|
|
|
|
tbl = Rex::Ui::Text::Table.new(
|
|
|
|
'Header' => 'Module Count by Author',
|
|
|
|
'Indent' => Indent.length,
|
|
|
|
'Columns' => [ 'Count', 'Name' ]
|
|
|
|
)
|
|
|
|
names.keys.sort {|a,b| names[b] <=> names[a] }.each do |name|
|
|
|
|
tbl << [ names[name].to_s, name ]
|
|
|
|
end
|
|
|
|
|
2011-06-07 01:25:12 +00:00
|
|
|
puts
|
2009-09-27 21:31:33 +00:00
|
|
|
puts tbl.to_s
|