Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
beefproject
GitHub Repository: beefproject/beef
Path: blob/master/modules/network/get_ntop_network_hosts/module.rb
1873 views
1
#
2
# Copyright (c) 2006-2026 Wade Alcorn - [email protected]
3
# Browser Exploitation Framework (BeEF) - https://beefproject.com
4
# See the file 'doc/COPYING' for copying permission
5
#
6
class Get_ntop_network_hosts < BeEF::Core::Command
7
def self.options
8
[
9
{ 'name' => 'rhost', 'ui_label' => 'Remote Host', 'value' => '127.0.0.1' },
10
{ 'name' => 'rport', 'ui_label' => 'Remote Port', 'value' => '3000' }
11
]
12
end
13
14
def post_execute
15
save({ 'result' => @datastore['result'] })
16
17
configuration = BeEF::Core::Configuration.instance
18
return unless configuration.get('beef.extension.network.enable') == true
19
return unless @datastore['results'] =~ /^proto=(https?)&ip=([\d.]+)&port=(\d+)&data=(.+)\z/
20
21
proto = Regexp.last_match(1)
22
ip = Regexp.last_match(2)
23
port = Regexp.last_match(3)
24
data = Regexp.last_match(4)
25
session_id = @datastore['beefhook']
26
type = 'ntop'
27
if BeEF::Filters.is_valid_ip?(ip)
28
print_debug("Hooked browser found 'ntop' [proto: #{proto}, ip: #{ip}, port: #{port}]")
29
BeEF::Core::Models::NetworkService.create(hooked_browser_id: session_id, proto: proto, ip: ip, port: port, type: type)
30
end
31
data.to_s.scan(/"hostNumIpAddress":"([\d.]+)"/).flatten.each do |ip|
32
if BeEF::Filters.is_valid_ip?(ip)
33
print_debug("Hooked browser found host #{ip}")
34
BeEF::Core::Models::NetworkHost.create(hooked_browser_id: session_id, ip: ip, port: port)
35
end
36
end
37
end
38
end
39
40