diff --git a/config.yaml b/config.yaml index d4d93e81b..f263b7186 100644 --- a/config.yaml +++ b/config.yaml @@ -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" diff --git a/core/main/handlers/hookedbrowsers.rb b/core/main/handlers/hookedbrowsers.rb index ee1511221..8e897e772 100644 --- a/core/main/handlers/hookedbrowsers.rb +++ b/core/main/handlers/hookedbrowsers.rb @@ -33,7 +33,7 @@ module Handlers 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 @@ -46,6 +46,20 @@ module Handlers error 404 end + excluded_hooking_subnet = config.get('beef.restrictions.excluded_hooking_subnet') + unless excluded_hooking_subnet.nil? || excluded_hooking_subnet.empty? + found = false + + excluded_hooking_subnet.each do |subnet| + found = true if IPAddr.new(subnet).include?(request.ip) + end + + if found + 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]