export module.search command

This commit is contained in:
Brent Cook 2017-06-24 15:50:37 -05:00
parent e0695cbf9b
commit 5635e81a87
3 changed files with 34 additions and 20 deletions

View File

@ -229,11 +229,11 @@ class Framework
}
end
def search(match, verbose: true)
def search(match, verbose: false)
# Check if the database is usable
use_db = true
if @db
if !(@db.migrated && @db.modules_cached)
if self.db
if !(self.db.migrated && self.db.modules_cached)
if verbose
print_warning("Module database cache not built yet, using slow search")
end
@ -248,12 +248,12 @@ class Framework
# Used the database for search
if use_db
return @db.search_modules(match)
return self.db.search_modules(match)
end
# Do an in-place search
matches = []
[ @exploits, @auxiliary, @post, @payloads, @nops, @encoders ].each do |mset|
[ self.exploits, self.auxiliary, self.post, self.payloads, self.nops, self.encoders ].each do |mset|
mset.each do |m|
begin
o = mset.create(m[0])

View File

@ -99,12 +99,7 @@ class RPC_Module < RPC_Base
# rpc.call('module.info', 'exploit', 'windows/smb/ms08_067_netapi')
def rpc_info(mtype, mname)
m = _find_module(mtype,mname)
res = {}
res['type'] = m.type
res['name'] = m.name
res['fullname'] = m.fullname
res['rank'] = m.rank.to_i
res = module_short_info(m)
res['description'] = Rex::Text.compress(m.description)
res['license'] = m.license
res['filepath'] = m.file_path
@ -165,6 +160,23 @@ class RPC_Module < RPC_Base
res
end
def module_short_info(m)
res = {}
res['type'] = m.type
res['name'] = m.name
res['fullname'] = m.fullname
res['rank'] = RankingName[m.rank].to_s
res['disclosuredate'] = m.disclosure_date.nil? ? "" : m.disclosure_date.strftime("%Y-%m-%d")
res
end
def rpc_search(match)
matches = []
self.framework.search(match).each do |m|
matches << module_short_info(m)
end
matches
end
# Returns the compatible payloads for a specific exploit.
#

View File

@ -18,9 +18,6 @@ module Msf
# Constant for a retry timeout on using modules before they're loaded
CMD_USE_TIMEOUT = 3
# Constant for disclosure date formatting in search functions
DISCLOSURE_DATE_FORMAT = "%Y-%m-%d"
@@search_opts = Rex::Parser::Arguments.new(
"-h" => [ false, "Help banner."],
"-S" => [ true, "Row search filter."],
@ -403,12 +400,12 @@ module Msf
# Display the table of matches
tbl = generate_module_table("Matching Modules", search_term)
framework.search(match, verbose: true).each do |o|
framework.search(match, verbose: true).each do |m|
tbl << [
o.fullname,
o.disclosure_date.nil? ? "" : o.disclosure_date.strftime(DISCLOSURE_DATE_FORMAT),
RankingName[o.rank].to_s,
o.name
m.fullname,
m.disclosure_date.nil? ? "" : m.disclosure_date.strftime("%Y-%m-%d"),
RankingName[m.rank].to_s,
m.name
]
end
print_line(tbl.to_s)
@ -1120,7 +1117,12 @@ module Msf
end
end
if (opts == nil or show == true)
tbl << [ refname, o.disclosure_date.nil? ? "" : o.disclosure_date.strftime(DISCLOSURE_DATE_FORMAT), o.rank_to_s, o.name ]
tbl << [
refname,
o.disclosure_date.nil? ? "" : o.disclosure_date.strftime("%Y-%m-%d"),
o.rank_to_s,
o.name
]
end
end
end