From 7a668abc0aa8b70ac36edec1e93cb0e3a6d393f9 Mon Sep 17 00:00:00 2001 From: Brendan Coles Date: Sat, 13 Feb 2016 07:09:00 +0000 Subject: [PATCH] Update ARE to support Evasion extension - Fix #1219 --- core/main/autorun_engine/engine.rb | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/core/main/autorun_engine/engine.rb b/core/main/autorun_engine/engine.rb index 6d0f7efcd..a1a335573 100644 --- a/core/main/autorun_engine/engine.rb +++ b/core/main/autorun_engine/engine.rb @@ -307,12 +307,16 @@ module BeEF begin cmd_body = command_body.lines.map(&:chomp) wrapper_start_index,wrapper_end_index = nil + cmd_body.each_with_index do |line, index| - if line.include?('beef.execute(function()') + if line.to_s =~ /^(beef|[a-zA-Z]+)\.execute\(function\(\)/ wrapper_start_index = index break end end + if wrapper_start_index.nil? + print_error "[ARE] Could not find module start index" + end cmd_body.reverse.each_with_index do |line, index| if line.include?('});') @@ -320,8 +324,14 @@ module BeEF break end end + if wrapper_end_index.nil? + print_error "[ARE] Could not find module end index" + end - cleaned_cmd_body = cmd_body.slice(wrapper_start_index+1..-(wrapper_end_index+2)).join("\n") + cleaned_cmd_body = cmd_body.slice(wrapper_start_index..-(wrapper_end_index+1)).join("\n") + if cleaned_cmd_body.eql?('') + print_error "[ARE] No command to send" + end # check if <> should be replaced with a variable name (depending if the variable is a string or number) if replace_input