2009-09-27 21:31:33 +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
|
|
|
|
##
|
|
|
|
|
2010-05-03 17:13:09 +00:00
|
|
|
#
|
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
|
|
|
#
|
|
|
|
|
2012-02-04 06:38:21 +00:00
|
|
|
msfbase = __FILE__
|
|
|
|
while File.symlink?(msfbase)
|
2013-09-30 18:47:53 +00:00
|
|
|
msfbase = File.expand_path(File.readlink(msfbase), File.dirname(msfbase))
|
2012-02-04 06:38:21 +00:00
|
|
|
end
|
|
|
|
|
2015-10-06 15:30:52 +00:00
|
|
|
$:.unshift(File.expand_path(File.join(File.dirname(msfbase), '..', '..', 'lib')))
|
2009-09-27 21:31:33 +00:00
|
|
|
|
|
|
|
require 'rex'
|
2019-02-22 04:56:04 +00:00
|
|
|
require 'json'
|
|
|
|
|
|
|
|
FILENAME = 'db/modules_metadata_base.json'
|
2009-09-27 21:31:33 +00:00
|
|
|
|
2011-06-07 01:25:12 +00:00
|
|
|
sort = 0
|
|
|
|
filter = 'All'
|
2019-02-22 05:11:39 +00:00
|
|
|
filters = ['all','exploit','payload','post','nop','encoder','auxiliary', 'evasion']
|
2011-06-07 01:25:12 +00:00
|
|
|
reg = 0
|
|
|
|
regex = nil
|
2011-06-07 00:20:21 +00:00
|
|
|
|
|
|
|
opts = Rex::Parser::Arguments.new(
|
2013-09-30 18:47:53 +00:00
|
|
|
"-h" => [ false, "Help menu." ],
|
|
|
|
"-s" => [ false, "Sort by Author instead of Module Type."],
|
|
|
|
"-r" => [ false, "Reverse Sort"],
|
|
|
|
"-f" => [ true, "Filter based on Module Type [#{filters.map{|f|f.capitalize}.join(", ")}] (Default = All)."],
|
|
|
|
"-x" => [ true, "String or RegEx to try and match against the Author Field"]
|
2011-06-07 00:20:21 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
opts.parse(ARGV) { |opt, idx, val|
|
2013-09-30 18:47:53 +00:00
|
|
|
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"
|
|
|
|
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
|
|
|
|
when "-x"
|
|
|
|
puts "Regex: #{val}"
|
|
|
|
regex = Regexp.new(val)
|
|
|
|
end
|
2011-06-07 00:20:21 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-05-03 17:13:09 +00:00
|
|
|
Indent = ' '
|
2009-09-27 21:31:33 +00:00
|
|
|
|
2016-08-10 18:30:09 +00:00
|
|
|
tbl = Rex::Text::Table.new(
|
2013-09-30 18:47:53 +00:00
|
|
|
'Header' => 'Module References',
|
|
|
|
'Indent' => Indent.length,
|
|
|
|
'Columns' => [ 'Module', 'Reference' ]
|
2009-09-27 21:31:33 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
names = {}
|
|
|
|
|
2019-02-22 05:20:43 +00:00
|
|
|
local_modules = JSON.parse(File.read(FILENAME)) # get cache file location from framework?
|
2019-02-22 04:56:04 +00:00
|
|
|
|
|
|
|
local_modules.each do |_module_key, local_module|
|
|
|
|
local_module['author'].each do |r|
|
2019-02-22 05:07:22 +00:00
|
|
|
next if filter.downcase != 'all' && local_module['type'] != filter.downcase
|
2013-09-30 18:47:53 +00:00
|
|
|
if regex.nil? or r =~ regex
|
2019-02-22 04:56:04 +00:00
|
|
|
tbl << [ local_module['full_name'], r ]
|
2013-09-30 18:47:53 +00:00
|
|
|
names[r] ||= 0
|
|
|
|
names[r] += 1
|
|
|
|
end
|
|
|
|
end
|
2019-02-22 04:56:04 +00:00
|
|
|
end
|
2011-06-07 00:20:21 +00:00
|
|
|
|
|
|
|
if sort == 1
|
2013-09-30 18:47:53 +00:00
|
|
|
tbl.sort_rows(1)
|
2011-06-07 00:20:21 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
if sort == 2
|
2013-09-30 18:47:53 +00:00
|
|
|
tbl.sort_rows(1)
|
|
|
|
tbl.rows.reverse
|
2011-06-07 00:20:21 +00:00
|
|
|
end
|
2009-09-27 21:31:33 +00:00
|
|
|
|
|
|
|
puts tbl.to_s
|
|
|
|
|
2016-08-10 18:30:09 +00:00
|
|
|
tbl = Rex::Text::Table.new(
|
2013-09-30 18:47:53 +00:00
|
|
|
'Header' => 'Module Count by Author',
|
|
|
|
'Indent' => Indent.length,
|
|
|
|
'Columns' => [ 'Count', 'Name' ]
|
2009-09-27 21:31:33 +00:00
|
|
|
)
|
|
|
|
names.keys.sort {|a,b| names[b] <=> names[a] }.each do |name|
|
2013-09-30 18:47:53 +00:00
|
|
|
tbl << [ names[name].to_s, name ]
|
2009-09-27 21:31:33 +00:00
|
|
|
end
|
|
|
|
|
2011-06-07 01:25:12 +00:00
|
|
|
puts
|
2009-09-27 21:31:33 +00:00
|
|
|
puts tbl.to_s
|