From 93ed26d10f675659aa7e8c8db0639d11b3001d9e Mon Sep 17 00:00:00 2001 From: aaron Date: Fri, 3 Apr 2020 14:37:48 +1000 Subject: [PATCH] Moved failed beefJS split into hooked instead of into BeEFJS --- config.yaml | 2 +- core/bootstrap.rb | 1 + core/main/handlers/hookedbrowsers.rb | 8 ++++++-- core/main/handlers/modules/beefjs.rb | 25 ++++--------------------- 4 files changed, 12 insertions(+), 24 deletions(-) diff --git a/config.yaml b/config.yaml index 035adba68..9089a6cf5 100644 --- a/config.yaml +++ b/config.yaml @@ -15,7 +15,7 @@ beef: crypto_default_value_length: 80 # Testif variable - testif: false + testif: true # Credentials to authenticate in BeEF. # Used by both the RESTful API and the Admin interface diff --git a/core/bootstrap.rb b/core/bootstrap.rb index 46bc79ab0..c93f98eba 100644 --- a/core/bootstrap.rb +++ b/core/bootstrap.rb @@ -18,6 +18,7 @@ require 'core/main/router/error_responses' ## @note Include http server functions for beef require 'core/main/server' require 'core/main/handlers/modules/beefjs' +require 'core/main/handlers/modules/legacybeefjs' require 'core/main/handlers/modules/command' require 'core/main/handlers/commands' require 'core/main/handlers/hookedbrowsers' diff --git a/core/main/handlers/hookedbrowsers.rb b/core/main/handlers/hookedbrowsers.rb index 3f2118b9b..22178904a 100644 --- a/core/main/handlers/hookedbrowsers.rb +++ b/core/main/handlers/hookedbrowsers.rb @@ -12,6 +12,7 @@ module Handlers include BeEF::Core::Handlers::Modules::BeEFJS + include BeEF::Core::Handlers::Modules::LegacyBeEFJS include BeEF::Core::Handlers::Modules::Command #antisnatchor: we don't want to have anti-xss/anti-framing headers in the HTTP response for the hook file. @@ -61,8 +62,11 @@ module Handlers # @note generate the instructions to hook the browser host_name = request.host (print_error "Invalid host name";return) if not BeEF::Filters.is_valid_hostname?(host_name) - build_beefjs!(host_name) - + if config.get("beef.testif") + build_beefjs!(host_name) + else + legacy_build_beefjs!(host_name) + end # @note is a known browser so send instructions else # @note Check if we haven't seen this browser for a while, log an event if we haven't diff --git a/core/main/handlers/modules/beefjs.rb b/core/main/handlers/modules/beefjs.rb index 87e2969d6..d898d2133 100644 --- a/core/main/handlers/modules/beefjs.rb +++ b/core/main/handlers/modules/beefjs.rb @@ -11,42 +11,25 @@ module BeEF # @note Purpose: avoid rewriting several times the same code. module BeEFJS - # Builds the default beefjs library (all default components of the library). # @param [Object] req_host The request object def build_beefjs!(req_host) - config = BeEF::Core::Configuration.instance - if config.get("beef.testif") - print("beefnew") - else - legacy = BeEF::Core::Handlers::Modules::LegacyBeEFJS - legacy.legacy_build_beefjs!(req_host) - end + + print("beefnew") + end # Finds the path to js components # @param [String] component Name of component # @return [String|Boolean] Returns false if path was not found, otherwise returns component path def find_beefjs_component_path(component) - config = BeEF::Core::Configuration.instance - if config.get("beef.testif") - print("beefnew") - else - legacy = BeEF::Core::Handlers::Modules::LegacyBeEFJS - legacy.legacy_find_beefjs_component_path(component) - end + print("beefnew") end # Builds missing beefjs components. # @param [Array] beefjs_components An array of component names def build_missing_beefjs_components(beefjs_components) - config = BeEF::Core::Configuration.instance - if config.get("beef.testif") print("beefnew") - else - legacy = BeEF::Core::Handlers::Modules::LegacyBeEFJS - legacy.legacy_build_missing_beefjs_components(beefjs_components) - end end end end