add a framework-wide search method

bug/bundler_fix
Brent Cook 2017-06-24 15:09:32 -05:00
parent 8eceef18d9
commit e0695cbf9b
3 changed files with 45 additions and 48 deletions

View File

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

View File

@ -401,49 +401,9 @@ module Msf
end
}
matching_modules = []
# Check if the database is usable
use_db = true
if framework.db
if !(framework.db.migrated && framework.db.modules_cached)
print_warning("Module database cache not built yet, using slow search")
use_db = false
end
else
print_warning("Database not connected, using slow search")
use_db = false
end
# Do the actual search
if use_db
framework.db.search_modules(match).each do |o|
matching_modules << o
end
else
[
framework.exploits,
framework.auxiliary,
framework.post,
framework.payloads,
framework.nops,
framework.encoders
].each do |mset|
mset.each do |m|
begin
o = mset.create(m[0])
if o && !o.search_filter(match)
matching_modules << o
end
rescue
end
end
end
end
# Display the table of matches
tbl = generate_module_table("Matching Modules", search_term)
matching_modules.each do |o|
framework.search(match, verbose: true).each do |o|
tbl << [
o.fullname,
o.disclosure_date.nil? ? "" : o.disclosure_date.strftime(DISCLOSURE_DATE_FORMAT),
@ -452,7 +412,6 @@ module Msf
]
end
print_line(tbl.to_s)
end
#