Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
beefproject
GitHub Repository: beefproject/beef
Path: blob/master/core/main/rest/handlers/browserdetails.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
module BeEF
8
module Core
9
module Rest
10
class BrowserDetails < BeEF::Core::Router::Router
11
config = BeEF::Core::Configuration.instance
12
13
before do
14
error 401 unless params[:token] == config.get('beef.api_token')
15
halt 401 unless BeEF::Core::Rest.permitted_source?(request.ip)
16
headers 'Content-Type' => 'application/json; charset=UTF-8',
17
'Pragma' => 'no-cache',
18
'Cache-Control' => 'no-cache',
19
'Expires' => '0'
20
end
21
22
#
23
# @note Get all browser details for the specified session
24
#
25
get '/:session' do
26
hb = BeEF::Core::Models::HookedBrowser.where(session: params[:session]).first
27
error 404 if hb.nil?
28
29
details = BeEF::Core::Models::BrowserDetails.where(session_id: hb.session)
30
error 404 if details.nil?
31
32
result = []
33
details.each do |d|
34
result << { key: d[:detail_key], value: d[:detail_value] }
35
end
36
37
output = {
38
'count' => result.length,
39
'details' => result
40
}
41
42
output.to_json
43
end
44
end
45
end
46
end
47
end
48
49