1
mirror of https://github.com/rapid7/metasploit-framework synced 2024-11-12 11:52:01 +01:00

Add support for single-IP external scanners

This commit is contained in:
Adam Cammack 2018-02-02 13:59:38 -06:00
parent 8be2b1f59e
commit ab36b5dd5d
No known key found for this signature in database
GPG Key ID: C9378BA088092D66
2 changed files with 51 additions and 2 deletions

View File

@ -13,6 +13,8 @@ class Msf::Modules::External::Shim
capture_server(mod)
when 'dos'
dos(mod)
when 'scanner.single'
single_scanner(mod)
when 'scanner.multi'
multi_scanner(mod)
else
@ -30,13 +32,19 @@ class Msf::Modules::External::Shim
render_template('common_metadata.erb', meta)
end
def self.mod_meta_common(mod, meta = {})
def self.mod_meta_common(mod, meta = {}, drop_rhost: true)
meta[:path] = mod.path.dump
meta[:name] = mod.meta['name'].dump
meta[:description] = mod.meta['description'].dump
meta[:authors] = mod.meta['authors'].map(&:dump).join(",\n ")
meta[:options] = mod.meta['options'].map do |n, o|
options = if drop_rhost
mod.meta['options'].reject {|n, o| n == 'rhost'}
else
mod.meta['options']
end
meta[:options] = options.map do |n, o|
"Opt#{o['type'].camelize}.new(#{n.dump},
[#{o['required']}, #{o['description'].dump}, #{o['default'].inspect}])"
end.join(",\n ")
@ -71,6 +79,16 @@ class Msf::Modules::External::Shim
render_template('capture_server.erb', meta)
end
def self.single_scanner(mod)
meta = mod_meta_common(mod, drop_rhost: true)
meta[:date] = mod.meta['date'].dump
meta[:references] = mod.meta['references'].map do |r|
"[#{r['type'].upcase.dump}, #{r['ref'].dump}]"
end.join(",\n ")
render_template('single_scanner.erb', meta)
end
def self.multi_scanner(mod)
meta = mod_meta_common(mod)
meta[:date] = mod.meta['date'].dump

View File

@ -0,0 +1,31 @@
require 'msf/core/modules/external/bridge'
require 'msf/core/module/external'
class MetasploitModule < Msf::Auxiliary
include Msf::Auxiliary::Scanner
include Msf::Module::External
def initialize
super({
<%= common_metadata meta %>
'References' =>
[
<%= meta[:references] %>
],
'DisclosureDate' => <%= meta[:date] %>,
})
register_options([
<%= meta[:options] %>
])
end
def run_host(ip)
print_status("Running for #{ip}...")
mod = Msf::Modules::External::Bridge.open(<%= meta[:path] %>)
rhost = datastore.delete('RHOST')
datastore['rhost'] = rhost
mod.run(datastore)
wait_status(mod)
end
end