Path: blob/master/modules/network/ping_sweep_ff/module.rb
1154 views
#1# Copyright (c) 2006-2025 Wade Alcorn - [email protected]2# Browser Exploitation Framework (BeEF) - https://beefproject.com3# See the file 'doc/COPYING' for copying permission4#5#6# Ping Sweep Module - jgaliana7# Discover active hosts in the internal network of the hooked browser.8# It works calling a Java method from JavaScript and do not require user interaction.910class Ping_sweep_ff < BeEF::Core::Command11def self.options12[13{ 'name' => 'ipRange', 'ui_label' => 'Scan IP range (C class or IP)', 'value' => '192.168.0.1-192.168.0.254' },14{ 'name' => 'timeout', 'ui_label' => 'Timeout (ms)', 'value' => '2000' },15{ 'name' => 'delay', 'ui_label' => 'Delay between requests (ms)', 'value' => '100' }16]17end1819def post_execute20content = {}21content['host'] = @datastore['host'] unless @datastore['host'].nil?22content['fail'] = 'No active hosts have been discovered.' if content.empty?23save content2425configuration = BeEF::Core::Configuration.instance26return unless configuration.get('beef.extension.network.enable') == true27return unless @datastore['results'] =~ /host=([\d.]+) is alive/2829# save the network host30ip = Regexp.last_match(1)31session_id = @datastore['beefhook']32if BeEF::Filters.is_valid_ip?(ip)33print_debug("Hooked browser has network interface #{ip}")34BeEF::Core::Models::NetworkHost.create(hooked_browser_id: session_id, ip: ip)35end36end37end383940