Path: blob/master/modules/network/get_ntop_network_hosts/module.rb
1873 views
#1# Copyright (c) 2006-2026 Wade Alcorn - [email protected]2# Browser Exploitation Framework (BeEF) - https://beefproject.com3# See the file 'doc/COPYING' for copying permission4#5class Get_ntop_network_hosts < BeEF::Core::Command6def self.options7[8{ 'name' => 'rhost', 'ui_label' => 'Remote Host', 'value' => '127.0.0.1' },9{ 'name' => 'rport', 'ui_label' => 'Remote Port', 'value' => '3000' }10]11end1213def post_execute14save({ 'result' => @datastore['result'] })1516configuration = BeEF::Core::Configuration.instance17return unless configuration.get('beef.extension.network.enable') == true18return unless @datastore['results'] =~ /^proto=(https?)&ip=([\d.]+)&port=(\d+)&data=(.+)\z/1920proto = Regexp.last_match(1)21ip = Regexp.last_match(2)22port = Regexp.last_match(3)23data = Regexp.last_match(4)24session_id = @datastore['beefhook']25type = 'ntop'26if BeEF::Filters.is_valid_ip?(ip)27print_debug("Hooked browser found 'ntop' [proto: #{proto}, ip: #{ip}, port: #{port}]")28BeEF::Core::Models::NetworkService.create(hooked_browser_id: session_id, proto: proto, ip: ip, port: port, type: type)29end30data.to_s.scan(/"hostNumIpAddress":"([\d.]+)"/).flatten.each do |ip|31if BeEF::Filters.is_valid_ip?(ip)32print_debug("Hooked browser found host #{ip}")33BeEF::Core::Models::NetworkHost.create(hooked_browser_id: session_id, ip: ip, port: port)34end35end36end37end383940