Files
beef/extensions/demos/handler.rb
jcrew99 486a9bb329 Update copyright 2023 (#2675)
* updated copyright

* reverted gemfile lock changes
2022-12-31 15:36:07 +10:00

53 lines
1.4 KiB
Ruby

#
# Copyright (c) 2006-2023 Wade Alcorn - wade@bindshell.net
# Browser Exploitation Framework (BeEF) - http://beefproject.com
# See the file 'doc/COPYING' for copying permission
#
module BeEF
module Extension
module Demos
class Handler
def initialize(file_path)
if File.exist?(file_path)
@file_path = file_path
else
print_error "[Demos] File does not exist: #{file_path}"
end
end
def call(env)
@body = ''
@request = Rack::Request.new(env)
@params = @request.query_string
@response = Rack::Response.new(body = [], 200, header = {})
config = BeEF::Core::Configuration.instance
eruby = Erubis::FastEruby.new(File.read(@file_path))
@body << eruby.evaluate(
'hook_uri' => config.get('beef.http.hook_file')
)
@response = Rack::Response.new(
body = [@body],
status = 200,
header = {
'Pragma' => 'no-cache',
'Cache-Control' => 'no-cache',
'Expires' => '0',
'Content-Type' => 'text/html'
}
)
end
# @note String representing the absolute path to the .html file
@file_path
# @note Object representing the HTTP request
@request
# @note Object representing the HTTP response
@response
end
end
end
end