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

@@ -29,7 +29,7 @@ class Asus_rt_series_get_info < BeEF::Core::Command
gateway = "#{$5}"
dns_servers = "#{$6}"
if !ip.nil?
if !ip.nil? && BeEF::Filters.is_valid_ip?(ip)
print_debug("Hooked browser found Asus RT series router [ip: #{ip}]")
r = BeEF::Core::Models::NetworkHost.new(:hooked_browser_id => session_id, :ip => ip, :type => 'Asus Router', :cid => cid)
r.save
@@ -41,21 +41,25 @@ class Asus_rt_series_get_info < BeEF::Core::Command
if client.to_s =~ /^([\d\.]+),([:\dA-F]{17})$/
ip = $1
mac = $2
print_debug("Hooked browser found router client [ip: #{ip}, mac: #{mac}]")
r = BeEF::Core::Models::NetworkHost.new(:hooked_browser_id => session_id, :ip => ip, :mac => mac, :cid => cid)
r.save
if BeEF::Filters.is_valid_ip?(ip)
print_debug("Hooked browser found router client [ip: #{ip}, mac: #{mac}]")
r = BeEF::Core::Models::NetworkHost.new(:hooked_browser_id => session_id, :ip => ip, :mac => mac, :cid => cid)
r.save
end
end
end
if !gateway.nil?
if !gateway.nil? && BeEF::Filters.is_valid_ip?(gateway)
print_debug("Hooked browser found WAN gateway server [ip: #{gateway}]")
r = BeEF::Core::Models::NetworkHost.new(:hooked_browser_id => session_id, :ip => gateway, :type => 'WAN Gateway', :cid => cid)
r.save
end
if !dns_servers.nil? && dns_servers =~ /^([\d\. ]+)$/
dns_servers.split(/ /).uniq.each do |dns|
print_debug("Hooked browser found DNS server [ip: #{dns}]")
r = BeEF::Core::Models::NetworkHost.new(:hooked_browser_id => session_id, :ip => dns, :type => 'DNS Server', :cid => cid)
r.save
if BeEF::Filters.is_valid_ip?(dns)
print_debug("Hooked browser found DNS server [ip: #{dns}]")
r = BeEF::Core::Models::NetworkHost.new(:hooked_browser_id => session_id, :ip => dns, :type => 'DNS Server', :cid => cid)
r.save
end
end
end
end

View File

@@ -24,9 +24,11 @@ class Detect_cups < BeEF::Core::Command
port = $3
session_id = @datastore['beefhook']
cid = @datastore['cid'].to_i
print_debug("Hooked browser found 'CUPS' [proto: #{proto}, ip: #{ip}, port: #{port}]")
r = BeEF::Core::Models::NetworkService.new(:hooked_browser_id => session_id, :proto => proto, :ip => ip, :port => port, :type => 'CUPS', :cid => cid)
r.save
if BeEF::Filters.is_valid_ip?(ip)
print_debug("Hooked browser found 'CUPS' [proto: #{proto}, ip: #{ip}, port: #{port}]")
r = BeEF::Core::Models::NetworkService.new(:hooked_browser_id => session_id, :proto => proto, :ip => ip, :port => port, :type => 'CUPS', :cid => cid)
r.save
end
end
end
end

View File

@@ -24,6 +24,7 @@ class Get_internal_ip_webrtc < BeEF::Core::Command
ips.uniq.each do |ip|
next unless ip =~ /^[\d\.]+$/
next if ip =~ /^0\.0\.0\.0$/
next unless 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, :os => os, :cid => cid)
r.save

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