Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
beefproject
GitHub Repository: beefproject/beef
Path: blob/master/modules/network/get_http_servers/module.rb
1866 views
1
#
2
# Copyright (c) 2006-2026 Wade Alcorn - [email protected]
3
# Browser Exploitation Framework (BeEF) - https://beefproject.com
4
# See the file 'doc/COPYING' for copying permission
5
#
6
7
class Get_http_servers < BeEF::Core::Command
8
def self.options
9
[
10
{ 'name' => 'rhosts', 'ui_label' => 'Remote IP(s)', 'value' => 'common' },
11
{ 'name' => 'ports', 'ui_label' => 'Ports', 'value' => '80,8080' },
12
{ 'name' => 'threads', 'ui_label' => 'Workers', 'value' => '3' },
13
{ 'name' => 'wait', 'ui_label' => 'Wait (s) between each request for each worker', 'value' => '5' },
14
{ 'name' => 'timeout', 'ui_label' => 'Timeout for each request (s)', 'value' => '10' }
15
]
16
end
17
18
def post_execute
19
content = {}
20
content['url'] = @datastore['url'] unless @datastore['url'].nil?
21
content['fail'] = 'No HTTP servers were discovered.' if content.empty?
22
save content
23
24
configuration = BeEF::Core::Configuration.instance
25
return unless configuration.get('beef.extension.network.enable') == true
26
return unless @datastore['results'] =~ /^proto=(.+)&ip=(.+)&port=(\d+)&url=(.+)/
27
28
proto = Regexp.last_match(1)
29
ip = Regexp.last_match(2)
30
port = Regexp.last_match(3)
31
url = Regexp.last_match(4)
32
session_id = @datastore['beefhook']
33
if !ip.nil? && BeEF::Filters.is_valid_ip?(ip)
34
print_debug("Hooked browser found HTTP Server [proto: #{proto}, ip: #{ip}, port: #{port}]")
35
BeEF::Core::Models::NetworkService.create(hooked_browser_id: session_id, proto: proto, ip: ip, port: port, type: 'HTTP Server')
36
end
37
end
38
end
39
40