From 419789baf59266b630926a4665cdcff764c25167 Mon Sep 17 00:00:00 2001 From: aaron Date: Fri, 3 Apr 2020 13:22:47 +1000 Subject: [PATCH] Finished legacy pivot --- core/main/handlers/modules/beefjs.rb | 49 ++++++---------------------- 1 file changed, 10 insertions(+), 39 deletions(-) diff --git a/core/main/handlers/modules/beefjs.rb b/core/main/handlers/modules/beefjs.rb index 7ee67a271..a4e5699de 100644 --- a/core/main/handlers/modules/beefjs.rb +++ b/core/main/handlers/modules/beefjs.rb @@ -17,7 +17,7 @@ module BeEF # @param [Object] req_host The request object def build_beefjs!(req_host) if config.get("beef.testif.enable") - + print("beefnew") else legacy_build_beefjs!(req_host) end @@ -27,50 +27,21 @@ module BeEF # @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) - component_path = component - component_path.gsub!(/beef./, '') - component_path.gsub!(/\./, '/') - component_path.replace "#{$root_dir}/core/main/client/#{component_path}.js" - - return false if not File.exists? component_path - - component_path + if config.get("beef.testif.enable") + print("beefnew") + else + legacy_find_beefjs_component_path(component) + end end # Builds missing beefjs components. # @param [Array] beefjs_components An array of component names def build_missing_beefjs_components(beefjs_components) - # @note verifies that @beef_js_cmps is not nil to avoid bugs - @beef_js_cmps = '' if @beef_js_cmps.nil? - - if beefjs_components.is_a? String - beefjs_components_path = find_beefjs_component_path(beefjs_components) - raise "Invalid component: could not build the beefjs file" if not beefjs_components_path - beefjs_components = {beefjs_components => beefjs_components_path} + if config.get("beef.testif.enable") + print("beefnew") + else + build_missing_beefjs_components(beefjs_components) end - - beefjs_components.keys.each { |k| - next if @beef_js_cmps.include? beefjs_components[k] - - # @note path to the component - component_path = beefjs_components[k] - - # @note we output the component to the hooked browser - config = BeEF::Core::Configuration.instance - if config.get("beef.extension.evasion.enable") - evasion = BeEF::Extension::Evasion::Evasion.instance - @body << evasion.obfuscate(File.read(component_path) + "\n\n") - else - @body << File.read(component_path) + "\n\n" - end - - # @note finally we add the component to the list of components already generated so it does not get generated numerous times. - if @beef_js_cmps.eql? '' - @beef_js_cmps = component_path - else - @beef_js_cmps += ",#{component_path}" - end - } end end end