Land #11451, update module authors to consume JSON cache

4.x
Brent Cook 2019-02-22 12:37:19 -06:00 committed by Metasploit
parent 363c71ea60
commit 9c78298602
No known key found for this signature in database
GPG Key ID: CDFB5FA52007B954
1 changed files with 11 additions and 26 deletions

View File

@ -16,17 +16,15 @@ while File.symlink?(msfbase)
end end
$:.unshift(File.expand_path(File.join(File.dirname(msfbase), '..', '..', 'lib'))) $:.unshift(File.expand_path(File.join(File.dirname(msfbase), '..', '..', 'lib')))
require 'msfenv'
$:.unshift(ENV['MSF_LOCAL_LIB']) if ENV['MSF_LOCAL_LIB']
require 'rex' require 'rex'
require 'msf/ui' require 'json'
require 'msf/base'
FILENAME = 'db/modules_metadata_base.json'
sort = 0 sort = 0
filter = 'All' filter = 'All'
filters = ['all','exploit','payload','post','nOP','encoder','auxiliary'] filters = ['all','exploit','payload','post','nop','encoder','auxiliary', 'evasion']
reg = 0 reg = 0
regex = nil regex = nil
@ -69,19 +67,6 @@ opts.parse(ARGV) { |opt, idx, val|
Indent = ' ' Indent = ' '
# 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
# Initialize the simplified framework instance.
$framework = Msf::Simple::Framework.create(framework_opts)
tbl = Rex::Text::Table.new( tbl = Rex::Text::Table.new(
'Header' => 'Module References', 'Header' => 'Module References',
'Indent' => Indent.length, 'Indent' => Indent.length,
@ -90,18 +75,18 @@ tbl = Rex::Text::Table.new(
names = {} names = {}
$framework.modules.each { |name, mod| local_modules = JSON.parse(File.read(FILENAME)) # get cache file location from framework?
x = mod.new
x.author.each do |r| local_modules.each do |_module_key, local_module|
r = r.to_s local_module['author'].each do |r|
next if filter.downcase != 'all' && local_module['type'] != filter.downcase
if regex.nil? or r =~ regex if regex.nil? or r =~ regex
tbl << [ x.fullname, r ] tbl << [ local_module['full_name'], r ]
names[r] ||= 0 names[r] ||= 0
names[r] += 1 names[r] += 1
end end
end end
} end
if sort == 1 if sort == 1
tbl.sort_rows(1) tbl.sort_rows(1)