Use filters

This commit is contained in:
Brendan Coles
2015-02-04 08:36:44 +00:00
parent f329c7331a
commit c099be75ed
10 changed files with 29 additions and 19 deletions

View File

@@ -21,7 +21,7 @@ class Cross_origin_scanner < BeEF::Core::Command
ip = $1
port = $2
print_debug("Hooked browser found HTTP server #{ip}:#{port}")
if !ip.nil? && !port.nil?
if !ip.nil? && !port.nil? && BeEF::Filters.is_valid_ip?(ip)
r = BeEF::Core::Models::NetworkService.new(:hooked_browser_id => session_id, :proto => 'http', :ip => ip, :port => port, :type => 'HTTP Server (CORS)', :cid => cid)
r.save
end

View File

@@ -33,7 +33,7 @@ class Get_http_servers < BeEF::Core::Command
url = $4
session_id = @datastore['beefhook']
cid = @datastore['cid'].to_i
if !ip.nil?
if !ip.nil? && BeEF::Filters.is_valid_ip?(ip)
print_debug("Hooked browser found HTTP Server [proto: #{proto}, ip: #{ip}, port: #{port}]")
r = BeEF::Core::Models::NetworkService.new(:hooked_browser_id => session_id, :proto => proto, :ip => ip, :port => port, :type => "HTTP Server", :cid => cid)
r.save

View File

@@ -36,6 +36,7 @@ class Identify_lan_subnets < BeEF::Core::Command
hosts.split(',').flatten.each do |ip|
next if ip.nil?
next unless ip.to_s =~ /^([\d\.]+)$/
next unless BeEF::Filters.is_valid_ip?(ip)
print_debug("Hooked browser found host #{ip}")
r = BeEF::Core::Models::NetworkHost.new(:hooked_browser_id => session_id, :ip => ip, :cid => cid)
r.save

View File

@@ -35,7 +35,7 @@ class Internal_network_fingerprinting < BeEF::Core::Command
url = $5
session_id = @datastore['beefhook']
cid = @datastore['cid'].to_i
if !ip.nil?
if !ip.nil? && BeEF::Filters.is_valid_ip?(ip)
print_debug("Hooked browser found '#{discovered}' [ip: #{ip}]")
r = BeEF::Core::Models::NetworkService.new(:hooked_browser_id => session_id, :proto => proto, :ip => ip, :port => port, :type => discovered, :cid => cid)
r.save

View File

@@ -35,7 +35,7 @@ class Fingerprint_routers < BeEF::Core::Command
device = $2
session_id = @datastore['beefhook']
cid = @datastore['cid'].to_i
if !ip.nil?
if !ip.nil? && BeEF::Filters.is_valid_ip?(ip)
print_debug("Hooked browser found network device " + device + " [ip: #{ip}]")
r = BeEF::Core::Models::NetworkHost.new(:hooked_browser_id => session_id, :ip => ip, :type => device, :cid => cid)
r.save

View File

@@ -36,9 +36,11 @@ class Ping_sweep < BeEF::Core::Command
# save the network host
if @datastore['results'] =~ /host=([\d\.]+) is alive/
ip = $1
print_debug("Hooked browser has network interface #{ip}")
r = BeEF::Core::Models::NetworkHost.new(:hooked_browser_id => session_id, :ip => ip, :cid => cid)
r.save
if BeEF::Filters.is_valid_ip?(ip)
print_debug("Hooked browser has network interface #{ip}")
r = BeEF::Core::Models::NetworkHost.new(:hooked_browser_id => session_id, :ip => ip, :cid => cid)
r.save
end
end
end

View File

@@ -38,7 +38,7 @@ class Port_scanner < BeEF::Core::Command
service = $4
session_id = @datastore['beefhook']
cid = @datastore['cid'].to_i
if !ip.nil?
if !ip.nil? && BeEF::Filters.is_valid_ip?(ip)
print_debug("Hooked browser found network service [ip: #{ip}, port: #{port}]")
r = BeEF::Core::Models::NetworkService.new(:hooked_browser_id => session_id, :proto => 'http', :ip => ip, :port => port, :type => service, :cid => cid)
r.save