#1# Copyright (c) 2006-2025 Wade Alcorn - [email protected]2# Browser Exploitation Framework (BeEF) - https://beefproject.com3# See the file 'doc/COPYING' for copying permission4#5module BeEF6module Extension7# Checks to see if extension is set inside the configuration8# @param [String] ext the extension key9# @return [Boolean] whether or not the extension exists in BeEF's configuration10def self.is_present(ext)11BeEF::Core::Configuration.instance.get('beef.extension').key? ext.to_s12end1314# Checks to see if extension is enabled in configuration15# @param [String] ext the extension key16# @return [Boolean] whether or not the extension is enabled17def self.is_enabled(ext)18return false unless is_present(ext)1920BeEF::Core::Configuration.instance.get("beef.extension.#{ext}.enable") == true21end2223# Checks to see if extension has been loaded24# @param [String] ext the extension key25# @return [Boolean] whether or not the extension is loaded26def self.is_loaded(ext)27return false unless is_enabled(ext)2829BeEF::Core::Configuration.instance.get("beef.extension.#{ext}.loaded") == true30end3132# Loads an extension33# @param [String] ext the extension key34# @return [Boolean] whether or not the extension loaded successfully35def self.load(ext)36if File.exist? "#{$root_dir}/extensions/#{ext}/extension.rb"37require "#{$root_dir}/extensions/#{ext}/extension.rb"38print_debug "Loaded extension: '#{ext}'"39BeEF::Core::Configuration.instance.set "beef.extension.#{ext}.loaded", true40return true41end42print_error "Unable to load extension '#{ext}'"43false44rescue StandardError => e45print_error "Unable to load extension '#{ext}':"46print_more e.message47end48end49end505152