Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
beefproject
GitHub Repository: beefproject/beef
Path: blob/master/modules/host/get_internal_ip_webrtc/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
class Get_internal_ip_webrtc < BeEF::Core::Command
7
def post_execute
8
content = {}
9
content['Result'] = @datastore['result']
10
save content
11
12
configuration = BeEF::Core::Configuration.instance
13
return unless configuration.get('beef.extension.network.enable') == true
14
15
return unless @datastore['results'] =~ /IP is ([\d.,]+)/
16
17
# save the network host
18
ips = Regexp.last_match(1).to_s.split(/,/)
19
session_id = @datastore['beefhook']
20
if !ips.nil? && !ips.empty?
21
os = BeEF::Core::Models::BrowserDetails.get(session_id, 'host.os.name')
22
ips.uniq.each do |ip|
23
next unless ip =~ /^[\d.]+$/
24
next if ip =~ /^0\.0\.0\.0$/
25
next unless BeEF::Filters.is_valid_ip?(ip)
26
27
print_debug("Hooked browser has network interface #{ip}")
28
BeEF::Core::Models::NetworkHost.create(hooked_browser_id: session_id, ip: ip, os: os)
29
end
30
end
31
end
32
end
33
34