Skip to content

Commit

Permalink
Merge pull request #1973 from beefproject/excluded_hooking_subnet
Browse files Browse the repository at this point in the history
Excluded hooking subnet
  • Loading branch information
jcrew99 authored Oct 25, 2020
2 parents f1f5198 + 09bcb5b commit 4947837
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 2 additions & 0 deletions config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ beef:
# subnet of IP addresses that can connect to the admin UI
#permitted_ui_subnet: ["127.0.0.1/32", "::1/128"]
permitted_ui_subnet: ["0.0.0.0/0", "::/0"]
# subnet of IP addresses that cannot be hooked by the framework
excluded_hooking_subnet: []
# slow API calls to 1 every api_attempt_delay seconds
api_attempt_delay: "0.05"

Expand Down
16 changes: 15 additions & 1 deletion core/main/handlers/hookedbrowsers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class HookedBrowsers < BeEF::Core::Router::Router
permitted_hooking_subnet = config.get('beef.restrictions.permitted_hooking_subnet')
if permitted_hooking_subnet.nil? || permitted_hooking_subnet.empty?
BeEF::Core::Logger.instance.register('Target Range', "Attempted hook from outside of permitted hooking subnet (#{request.ip}) rejected.")
error 404
error 404
end

found = false
Expand All @@ -46,6 +46,20 @@ class HookedBrowsers < BeEF::Core::Router::Router
error 404
end

excluded_hooking_subnet = config.get('beef.restrictions.excluded_hooking_subnet')
unless excluded_hooking_subnet.nil? || excluded_hooking_subnet.empty?
excluded_ip_hooked = false

excluded_hooking_subnet.each do |subnet|
excluded_ip_hooked = true if IPAddr.new(subnet).include?(request.ip)
end

if excluded_ip_hooked
BeEF::Core::Logger.instance.register('Target Range', "Attempted hook from excluded hooking subnet (#{request.ip}) rejected.")
error 404
end
end

# @note get zombie if already hooked the framework
hook_session_name = config.get('beef.http.hook_session_name')
hook_session_id = request[hook_session_name]
Expand Down

0 comments on commit 4947837

Please sign in to comment.