2006-05-06 17:13:45 +00:00
|
|
|
#!/usr/bin/env ruby
|
|
|
|
#
|
2010-05-03 17:13:09 +00:00
|
|
|
# $Id$
|
|
|
|
#
|
2006-05-06 17:13:45 +00:00
|
|
|
# This script lists each module by its licensing terms
|
|
|
|
#
|
2010-05-03 17:13:09 +00:00
|
|
|
# $Revision$
|
|
|
|
#
|
2006-05-06 17:13:45 +00:00
|
|
|
|
2006-07-31 15:36:08 +00:00
|
|
|
msfbase = File.symlink?(__FILE__) ? File.readlink(__FILE__) : __FILE__
|
2007-02-26 18:01:13 +00:00
|
|
|
$:.unshift(File.join(File.dirname(msfbase), '..', 'lib'))
|
2006-05-06 17:13:45 +00:00
|
|
|
|
|
|
|
require 'rex'
|
|
|
|
require 'msf/ui'
|
|
|
|
require 'msf/base'
|
|
|
|
|
|
|
|
def lic_short(l)
|
2010-05-03 17:13:09 +00:00
|
|
|
if (l.class == Array)
|
2006-05-06 17:13:45 +00:00
|
|
|
l = l[0]
|
|
|
|
end
|
2010-05-03 17:13:09 +00:00
|
|
|
|
2006-05-06 17:13:45 +00:00
|
|
|
case l
|
|
|
|
when MSF_LICENSE
|
|
|
|
'MSF'
|
|
|
|
when GPL_LICENSE
|
|
|
|
'GPL'
|
|
|
|
when BSD_LICENSE
|
|
|
|
'BSD'
|
|
|
|
when ARTISTIC_LICENSE
|
|
|
|
'ART'
|
|
|
|
else
|
|
|
|
'UNK'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2011-06-07 00:20:21 +00:00
|
|
|
|
|
|
|
sort=0
|
|
|
|
filter= 'All'
|
2011-06-07 01:25:12 +00:00
|
|
|
filters = ['all','exploit','payload','post','nop','encoder','auxiliary']
|
2011-06-07 00:20:21 +00:00
|
|
|
reg=0
|
|
|
|
regex= ''
|
|
|
|
|
|
|
|
opts = Rex::Parser::Arguments.new(
|
|
|
|
"-h" => [ false, "Help menu." ],
|
|
|
|
"-s" => [ false, "Sort by License 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 License Field"]
|
|
|
|
)
|
|
|
|
|
|
|
|
opts.parse(ARGV) { |opt, idx, val|
|
|
|
|
case opt
|
|
|
|
when "-h"
|
|
|
|
puts "\nMetasploit Script for Displaying Module License information."
|
|
|
|
puts "=========================================================="
|
|
|
|
puts opts.usage
|
|
|
|
exit
|
|
|
|
when "-s"
|
|
|
|
puts "Sorting by License"
|
|
|
|
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}"
|
|
|
|
reg=1
|
|
|
|
regex = val
|
|
|
|
end
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-05-03 17:13:09 +00:00
|
|
|
Indent = ' '
|
2006-05-06 17:13:45 +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
|
|
|
|
|
2006-05-06 17:13:45 +00:00
|
|
|
# Initialize the simplified framework instance.
|
2011-06-07 01:25:12 +00:00
|
|
|
$framework = Msf::Simple::Framework.create(framework_opts)
|
2006-05-06 17:13:45 +00:00
|
|
|
|
|
|
|
|
|
|
|
tbl = Rex::Ui::Text::Table.new(
|
|
|
|
'Header' => 'Licensed Modules',
|
2009-01-09 22:40:38 +00:00
|
|
|
'Indent' => Indent.length,
|
2006-05-06 17:13:45 +00:00
|
|
|
'Columns' => [ 'License','Type', 'Name' ]
|
|
|
|
)
|
|
|
|
|
|
|
|
licenses = {}
|
|
|
|
|
2011-06-07 01:25:12 +00:00
|
|
|
$framework.modules.each { |name, mod|
|
|
|
|
x = mod.new
|
|
|
|
lictype = lic_short(x.license)
|
|
|
|
if reg==0 or lictype=~/#{regex}/
|
|
|
|
tbl << [ lictype, mod.type.capitalize, name ]
|
|
|
|
end
|
|
|
|
}
|
2011-06-07 00:20:21 +00:00
|
|
|
|
|
|
|
|
|
|
|
if sort == 1
|
|
|
|
tbl.sort_rows(0)
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
if sort == 2
|
|
|
|
tbl.sort_rows(1)
|
|
|
|
tbl.rows.reverse
|
|
|
|
end
|
2006-05-06 17:13:45 +00:00
|
|
|
|
2009-01-09 22:40:38 +00:00
|
|
|
puts tbl.to_s
|