Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
beefproject
GitHub Repository: beefproject/beef
Path: blob/master/modules/network/ping_sweep_ff/module.rb
1154 views
1
#
2
# Copyright (c) 2006-2025 Wade Alcorn - [email protected]
3
# Browser Exploitation Framework (BeEF) - https://beefproject.com
4
# See the file 'doc/COPYING' for copying permission
5
#
6
#
7
# Ping Sweep Module - jgaliana
8
# Discover active hosts in the internal network of the hooked browser.
9
# It works calling a Java method from JavaScript and do not require user interaction.
10
11
class Ping_sweep_ff < BeEF::Core::Command
12
def self.options
13
[
14
{ 'name' => 'ipRange', 'ui_label' => 'Scan IP range (C class or IP)', 'value' => '192.168.0.1-192.168.0.254' },
15
{ 'name' => 'timeout', 'ui_label' => 'Timeout (ms)', 'value' => '2000' },
16
{ 'name' => 'delay', 'ui_label' => 'Delay between requests (ms)', 'value' => '100' }
17
]
18
end
19
20
def post_execute
21
content = {}
22
content['host'] = @datastore['host'] unless @datastore['host'].nil?
23
content['fail'] = 'No active hosts have been discovered.' if content.empty?
24
save content
25
26
configuration = BeEF::Core::Configuration.instance
27
return unless configuration.get('beef.extension.network.enable') == true
28
return unless @datastore['results'] =~ /host=([\d.]+) is alive/
29
30
# save the network host
31
ip = Regexp.last_match(1)
32
session_id = @datastore['beefhook']
33
if BeEF::Filters.is_valid_ip?(ip)
34
print_debug("Hooked browser has network interface #{ip}")
35
BeEF::Core::Models::NetworkHost.create(hooked_browser_id: session_id, ip: ip)
36
end
37
end
38
end
39
40