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:
parent
8be2b1f59e
commit
ab36b5dd5d
22
lib/msf/core/modules/external/shim.rb
vendored
22
lib/msf/core/modules/external/shim.rb
vendored
@ -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
|
||||
|
31
lib/msf/core/modules/external/templates/single_scanner.erb
vendored
Normal file
31
lib/msf/core/modules/external/templates/single_scanner.erb
vendored
Normal 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
|
Loading…
Reference in New Issue
Block a user