diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000000..c8d769bba6 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,36 @@ +name: "RuboCop" + +on: + pull_request: + branches: [master] + +jobs: + rubocop: + name: "RuboCop Analysis" + runs-on: ubuntu-latest + steps: + - name: "Checkout the repository" + uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} + fetch-depth: 2 + + - name: "Update and Install Dependencies" + run: | + sudo apt update + sudo apt install libcurl4 libcurl4-openssl-dev + + - name: "Setting up Ruby" + uses: ruby/setup-ruby@v1 + with: + bundler-cache: true + + - name: "Configure Bundle testing and install gems" + run: | + bundle config unset --local without + bundle config set --local with 'development' + bundle install + + - name: "Run RuboCop" + run: | + bundle exec rubocop --display-only-safe-correctable diff --git a/.github/workflows/github_actions.yml b/.github/workflows/test.yml similarity index 50% rename from .github/workflows/github_actions.yml rename to .github/workflows/test.yml index 880302da3b..7c6e195ed8 100644 --- a/.github/workflows/github_actions.yml +++ b/.github/workflows/test.yml @@ -1,55 +1,57 @@ -name: 'BrowserStack Test' +name: "BrowserStack Test" on: pull_request_target: - branches: [ master ] - -jobs: + branches: [master] + +jobs: ubuntu-job: - name: 'BrowserStack Test on Ubuntu' - runs-on: ubuntu-latest # Can be self-hosted runner also + name: "BrowserStack Test on Ubuntu" + runs-on: ubuntu-latest # Can be self-hosted runner also environment: name: Integrate Pull Request - env: + env: GITACTIONS: true steps: - - - name: 'BrowserStack Env Setup' # Invokes the setup-env action + - name: "BrowserStack Env Setup" # Invokes the setup-env action uses: browserstack/github-actions/setup-env@master with: - username: ${{ secrets.BROWSERSTACK_USERNAME }} + username: ${{ secrets.BROWSERSTACK_USERNAME }} access-key: ${{ secrets.BROWSERSTACK_ACCESS_KEY }} - - name: 'BrowserStack Local Tunnel Setup' # Invokes the setup-local action + - name: "BrowserStack Local Tunnel Setup" # Invokes the setup-local action uses: browserstack/github-actions/setup-local@master with: local-testing: start local-identifier: random - - name: 'Checkout the repository' + - name: "Checkout the repository" uses: actions/checkout@v4 with: ref: ${{ github.event.pull_request.head.sha }} fetch-depth: 2 - - name: 'Setting up Ruby' - uses: ruby/setup-ruby@v1 - # Ruby version is defined in .ruby-version file - - - name: 'Update and Install Dependencies' + - name: "Update and Install Dependencies" run: | sudo apt update sudo apt install libcurl4 libcurl4-openssl-dev - - name: 'Configure Bundle testing and install gems' + + - name: "Setting up Ruby" + uses: ruby/setup-ruby@v1 + with: + bundler-cache: true + + - name: "Configure Bundle testing and install gems" run: | bundle config unset --local without - bundle config set --local with 'test' 'development' + bundle config set --local with 'test' bundle install - - name: 'Run BrowserStack simple verification' + + - name: "Run BrowserStack simple verification" run: | bundle exec rake browserstack --trace - - name: 'BrowserStackLocal Stop' # Terminating the BrowserStackLocal tunnel connection + - name: "BrowserStackLocal Stop" # Terminating the BrowserStackLocal tunnel connection uses: browserstack/github-actions/setup-local@master with: - local-testing: stop \ No newline at end of file + local-testing: stop diff --git a/.rubocop.yml b/.rubocop.yml index 7cf5f3c079..f0c700d100 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,15 +1,19 @@ AllCops: - Exclude: - - 'test/**/*' - - 'tmp/**/*' - - 'tools/**/*' - - 'doc/**/*' TargetRubyVersion: <%= File.read(".ruby-version").strip[/^(\d+\.\d+)/, 1] || raise("Ruby version not found") %> + NewCops: enable + Exclude: + - "vendor/**/*" + - "tools/**/*" + - "spec/**/*" + - "test/**/*" + +Bundler/OrderedGems: + Enabled: false + Layout/LineLength: - Enabled: true - Max: 180 + Enabled: false Metrics/AbcSize: Enabled: false @@ -20,6 +24,9 @@ Metrics/BlockLength: Metrics/ClassLength: Enabled: false +Metrics/CyclomaticComplexity: + Enabled: false + Metrics/MethodLength: Enabled: false @@ -29,14 +36,32 @@ Metrics/ModuleLength: Metrics/PerceivedComplexity: Enabled: false -Metrics/CyclomaticComplexity: +Naming/ClassAndModuleCamelCase: Enabled: false -Naming/ClassAndModuleCamelCase: +Style/BlockDelimiters: Enabled: false -Style/FrozenStringLiteralComment: +Style/CommentAnnotation: Enabled: false Style/Documentation: Enabled: false + +Style/GuardClause: + Enabled: false + +Style/IfInsideElse: + Enabled: false + +Style/IfUnlessModifier: + Enabled: false + +Style/RescueStandardError: + Enabled: false + +Style/WordArray: + Enabled: false + +Style/FrozenStringLiteralComment: + Enabled: false diff --git a/Gemfile b/Gemfile index 078f4327ff..23fdfce5ad 100644 --- a/Gemfile +++ b/Gemfile @@ -4,6 +4,8 @@ # See the file 'doc/COPYING' for copying permission # +source 'https://rubygems.org' + gem 'net-smtp', require: false gem 'json' @@ -17,14 +19,13 @@ gem 'uglifier', '~> 4.2' gem 'mime-types', '~> 3.7' gem 'execjs', '~> 2.10' gem 'ansi', '~> 1.5' -gem 'term-ansicolor', :require => 'term/ansicolor' +gem 'term-ansicolor', require: 'term/ansicolor' gem 'rubyzip', '~> 3.2' gem 'espeak-ruby', '~> 1.1.0' # Text-to-Voice gem 'rake', '~> 13.3' gem 'activerecord', '~> 8.1' gem 'otr-activerecord', '~> 2.6.0' gem 'sqlite3', '~> 2.8' -gem 'rubocop', '~> 1.81.7', require: false # Geolocation support group :geoip do @@ -59,6 +60,10 @@ group :ext_qrcode do gem 'qr4r', '~> 0.6.1' end +group :development do + gem 'rubocop', '~> 1.81.7', require: false +end + # For running unit tests group :test do gem 'test-unit-full', '~> 0.0.5' @@ -86,5 +91,3 @@ group :test do # sudo port install libxml2 libxslt gem 'capybara', '~> 3.40' end - -source 'https://rubygems.org' diff --git a/Rakefile b/Rakefile index 258b392ba6..aad5620a44 100644 --- a/Rakefile +++ b/Rakefile @@ -5,7 +5,7 @@ # require 'rspec/core/rake_task' -task :default => ["short"] +task default: ['short'] RSpec::Core::RakeTask.new(:short) do |task| task.rspec_opts = ['--tag ~run_on_browserstack', '--tag ~run_on_long_tests'] @@ -27,7 +27,7 @@ RSpec::Core::RakeTask.new(:browserstack) do |task| end RSpec::Core::RakeTask.new(:bs) do |task| - configs = Dir["spec/support/browserstack/**/*.yml"] + configs = Dir['spec/support/browserstack/**/*.yml'] configs.each do |config| config = config.split('spec/support/browserstack')[1] ENV['CONFIG_FILE'] = config @@ -48,13 +48,13 @@ namespace :ssl do puts 'Certificate already exists. Replace? [Y/n]' confirm = STDIN.getch.chomp unless confirm.eql?('') || confirm.downcase.eql?('y') - puts "Aborted" + puts 'Aborted' exit 1 end end Rake::Task['ssl:replace'].invoke end - + desc 'Re-generate SSL certificate' task :replace do if File.file?('/usr/local/bin/openssl') @@ -62,7 +62,7 @@ namespace :ssl do elsif File.file?('/usr/bin/openssl') path = '/usr/bin/openssl' else - puts "[-] Error: could not find openssl" + puts '[-] Error: could not find openssl' exit 1 end IO.popen([path, 'req', '-new', '-newkey', 'rsa:4096', '-sha256', '-x509', '-days', '3650', '-nodes', '-out', 'beef_cert.pem', '-keyout', 'beef_key.pem', '-subj', '/CN=localhost'], 'r+').read.to_s @@ -88,8 +88,8 @@ namespace :rdoc do rd.rdoc_dir = 'doc/rdocs' rd.main = 'README.mkd' rd.rdoc_files.include('core/**/*\.rb') - #'extensions/**/*\.rb' - #'modules/**/*\.rb' + # 'extensions/**/*\.rb' + # 'modules/**/*\.rb' rd.options << '--line-numbers' rd.options << '--all' end @@ -98,15 +98,15 @@ end ################################ # X11 set up -@xserver_process_id = nil; +@xserver_process_id = nil task :xserver_start do - printf "Starting X11 Server (wait 10 seconds)..." - @xserver_process_id = IO.popen("/usr/bin/Xvfb :0 -screen 0 1024x768x24 2> /dev/null", "w+") + printf 'Starting X11 Server (wait 10 seconds)...' + @xserver_process_id = IO.popen('/usr/bin/Xvfb :0 -screen 0 1024x768x24 2> /dev/null', 'w+') delays = [2, 2, 1, 1, 1, 0.5, 0.5, 0.5, 0.3, 0.2, 0.1, 0.1, 0.1, 0.05, 0.05] delays.each do |i| # delay for 10 seconds printf '.' - sleep (i) # increase the . display rate + sleep(i) # increase the . display rate end puts '.' end @@ -119,16 +119,16 @@ end ################################ # BeEF environment set up -@beef_process_id = nil; -@beef_config_file = 'tmp/rk_beef_conf.yaml'; +@beef_process_id = nil +@beef_config_file = 'tmp/rk_beef_conf.yaml' -task :beef_start => 'beef' do +task beef_start: 'beef' do # read environment param for creds or use bad_fred test_user = ENV['TEST_BEEF_USER'] || 'bad_fred' test_pass = ENV['TEST_BEEF_PASS'] || 'bad_fred_no_access' # write a rake config file for beef - config = YAML.safe_load(File.read('./config.yaml')) + config = YAML.safe_load_file('./config.yaml') config['beef']['credentials']['user'] = test_user config['beef']['credentials']['passwd'] = test_pass Dir.mkdir('tmp') unless Dir.exist?('tmp') @@ -140,12 +140,12 @@ task :beef_start => 'beef' do config = nil puts "Using config file: #{@beef_config_file}\n" - printf "Starting BeEF (wait a few seconds)..." - @beef_process_id = IO.popen("ruby ./beef -c #{@beef_config_file} -x 2> /dev/null", "w+") + printf 'Starting BeEF (wait a few seconds)...' + @beef_process_id = IO.popen("ruby ./beef -c #{@beef_config_file} -x 2> /dev/null", 'w+') delays = [5, 5, 5, 4, 4, 3, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1] delays.each do |i| # delay for a few seconds printf '.' - sleep (i) + sleep(i) end puts ".\n\n" end @@ -165,41 +165,41 @@ end ################################ # MSF environment set up -@msf_process_id = nil; +@msf_process_id = nil -task :msf_start => '/tmp/msf-test/msfconsole' do - printf "Starting MSF (wait 45 seconds)..." - @msf_process_id = IO.popen("/tmp/msf-test/msfconsole -r test/thirdparty/msf/unit/BeEF.rc 2> /dev/null", "w+") +task msf_start: '/tmp/msf-test/msfconsole' do + printf 'Starting MSF (wait 45 seconds)...' + @msf_process_id = IO.popen('/tmp/msf-test/msfconsole -r test/thirdparty/msf/unit/BeEF.rc 2> /dev/null', 'w+') delays = [10, 7, 6, 5, 4, 3, 2, 2, 1, 1, 1, 0.5, 0.5, 0.5, 0.3, 0.2, 0.1, 0.1, 0.1, 0.05, 0.05] delays.each do |i| # delay for 45 seconds printf '.' - sleep (i) # increase the . display rate + sleep(i) # increase the . display rate end puts '.' end task :msf_stop do puts "\nShutting down MSF...\n" - @msf_process_id.puts "quit" + @msf_process_id.puts 'quit' end -task :msf_install => '/tmp/msf-test/msfconsole' do +task msf_install: '/tmp/msf-test/msfconsole' do # Handled by the 'test/msf-test/msfconsole' task. end -task :msf_update => '/tmp/msf-test/msfconsole' do - sh "cd /tmp/msf-test;git pull" +task msf_update: '/tmp/msf-test/msfconsole' do + sh 'cd /tmp/msf-test;git pull' end file '/tmp/msf-test/msfconsole' do - puts "Installing MSF" - sh "cd test;git clone https://github.com/rapid7/metasploit-framework.git /tmp/msf-test" + puts 'Installing MSF' + sh 'cd test;git clone https://github.com/rapid7/metasploit-framework.git /tmp/msf-test' end ################################ # ActiveRecord namespace :db do task :environment do - require_relative "beef" + require_relative 'beef' end end diff --git a/beef b/beef index e0d9375a6e..359ded43e8 100755 --- a/beef +++ b/beef @@ -35,7 +35,7 @@ end # # @note set load path, application root directory and user preferences directory # -$root_dir = File.join(File.expand_path(File.dirname(File.realpath(__FILE__))), '.') +$root_dir = File.join(File.expand_path(__dir__), '.') $:.unshift($root_dir) $home_dir = File.expand_path("#{Dir.home}/.beef/", __FILE__).freeze @@ -79,11 +79,11 @@ end # # @note Initialize the Configuration object. Loads a different config.yaml if -c flag was passed. # -if BeEF::Core::Console::CommandLine.parse[:ext_config].empty? - config = BeEF::Core::Configuration.new("#{$root_dir}/config.yaml") -else - config = BeEF::Core::Configuration.new("#{BeEF::Core::Console::CommandLine.parse[:ext_config]}") -end +config = if BeEF::Core::Console::CommandLine.parse[:ext_config].empty? + BeEF::Core::Configuration.new("#{$root_dir}/config.yaml") + else + BeEF::Core::Configuration.new("#{BeEF::Core::Console::CommandLine.parse[:ext_config]}") + end # # @note set log level @@ -93,11 +93,11 @@ BeEF.logger.level = config.get('beef.debug') ? Logger::DEBUG : Logger::WARN # # @note Check the system language settings for UTF-8 compatibility # -env_lang = ENV['LANG'] +env_lang = ENV.fetch('LANG', nil) if env_lang !~ /(utf8|utf-8)/i print_warning "Warning: System language $LANG '#{env_lang}' does not appear to be UTF-8 compatible." if env_lang =~ /\A([a-z]+_[a-z]+)\./i - country = $1 + country = Regexp.last_match(1) print_more "Try: export LANG=#{country}.utf8" end end @@ -123,9 +123,9 @@ end # # @note Exit on default credentials # -if config.get("beef.credentials.user").eql?('beef') && config.get("beef.credentials.passwd").eql?('beef') - print_error "ERROR: Default username and password in use!" - print_more "Change the beef.credentials.passwd in config.yaml" +if config.get('beef.credentials.user').eql?('beef') && config.get('beef.credentials.passwd').eql?('beef') + print_error 'ERROR: Default username and password in use!' + print_more 'Change the beef.credentials.passwd in config.yaml' exit 1 end @@ -194,9 +194,9 @@ end # Connect to DB ActiveRecord::Base.logger = nil -OTR::ActiveRecord.configure_from_hash!(adapter:'sqlite3', database:db_file) +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. +# 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 @@ -250,7 +250,7 @@ BeEF::Core::Console::Banners.print_dns # # @note Prints the API key needed to use the RESTful API # -print_info "RESTful API key: #{BeEF::Core::Crypto::api_token}" +print_info "RESTful API key: #{BeEF::Core::Crypto.api_token}" # # @note Load the GeoIP database @@ -270,7 +270,7 @@ BeEF::Core::AutorunEngine::RuleLoader.instance.load_directory # # @note Start the WebSocket server # -if config.get("beef.http.websocket.enable") +if config.get('beef.http.websocket.enable') BeEF::Core::Websocket::Websocket.instance BeEF::Core::Console::Banners.print_websocket_servers end diff --git a/core/api.rb b/core/api.rb index 0e4531aace..fef16324d0 100644 --- a/core/api.rb +++ b/core/api.rb @@ -132,7 +132,7 @@ def get_owners(clss, method, params = []) # @param [String] mthd the target method to verify # def verify_api_path(clss, mthd) - (clss.const_defined?('API_PATHS') && clss.const_get('API_PATHS').key?(mthd)) + clss.const_defined?('API_PATHS') && clss.const_get('API_PATHS').key?(mthd) end # diff --git a/core/filters/base.rb b/core/filters/base.rb index 5bf170f0d5..aeefa94717 100644 --- a/core/filters/base.rb +++ b/core/filters/base.rb @@ -21,7 +21,7 @@ def self.is_non_empty_string?(str) # @param [String] str String for testing # @return [Boolean] Whether or not the only characters in str are specified in chars def self.only?(chars, str) - regex = Regexp.new('[^' + chars + ']') + regex = Regexp.new("[^#{chars}]") regex.match(str.encode('UTF-8', invalid: :replace, undef: :replace, replace: '')).nil? end diff --git a/core/main/autorun_engine/engine.rb b/core/main/autorun_engine/engine.rb index 6bd17625b4..af0413c43e 100644 --- a/core/main/autorun_engine/engine.rb +++ b/core/main/autorun_engine/engine.rb @@ -135,7 +135,7 @@ def zombie_os_matches_rule?(os, os_version, rule) 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) + return false unless os_major_version_match && os_minor_version_match end true @@ -158,20 +158,20 @@ def zombie_browser_matches_rule?(browser, browser_version, rule) # check if rule specifies multiple browsers if rule.browser =~ /\A[A-Z]+\Z/ - return false unless rule.browser == 'ALL' || browser == rule.browser + 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 + # 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 - return false unless browser_match + end + return false unless browser_match end true @@ -504,9 +504,9 @@ def prepare_command(mod, options, hb_id, replace_input, rule_token) if config.get('beef.extension.evasion.enable') evasion = BeEF::Extension::Evasion::Evasion.instance - command_body = evasion.obfuscate(command_module.output) + "\n\n" + command_body = "#{evasion.obfuscate(command_module.output)}\n\n" else - command_body = command_module.output + "\n\n" + command_body = "#{command_module.output}\n\n" end # @note prints the event to the console diff --git a/core/main/autorun_engine/parser.rb b/core/main/autorun_engine/parser.rb index 93a4c34b9e..3a83eb6385 100644 --- a/core/main/autorun_engine/parser.rb +++ b/core/main/autorun_engine/parser.rb @@ -28,11 +28,13 @@ def parse(name, author, browser, browser_version, os, os_version, modules, execu 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 diff --git a/core/main/autorun_engine/rule_loader.rb b/core/main/autorun_engine/rule_loader.rb index 889dcbfe35..06fd58bf87 100644 --- a/core/main/autorun_engine/rule_loader.rb +++ b/core/main/autorun_engine/rule_loader.rb @@ -202,7 +202,7 @@ def update_rule_json(id, data) # @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)) + load_rule_json(JSON.parse(rule_file)) rescue => e print_error("[ARE] Failed to load ruleset from #{json_rule_path}: #{e.message}") end diff --git a/core/main/command.rb b/core/main/command.rb index 2a68763a33..a991b0e910 100644 --- a/core/main/command.rb +++ b/core/main/command.rb @@ -17,7 +17,7 @@ module CommandUtils # @return [String] Formatted string # def format_multiline(text) - text.gsub(/\n/, '\n') + text.gsub("\n", '\n') end end @@ -28,12 +28,13 @@ def format_multiline(text) # class CommandContext < Erubis::Context include BeEF::Core::CommandUtils + # # Constructor # @param [Hash] hash # def initialize(hash = nil) - super(hash) + super end end @@ -226,9 +227,9 @@ def map_file_to_url(file, path = nil, extension = nil, count = 1) def use(component) return if @beefjs_components.include? component - component_path = '/' + component + component_path = "/#{component}" component_path.gsub!(/beef./, '') - component_path.gsub!(/\./, '/') + component_path.gsub!('.', '/') component_path.replace "#{$root_dir}/core/main/client/#{component_path}.js" raise "Invalid beefjs component for command module #{@path}" unless File.exist? component_path @@ -250,11 +251,6 @@ def apply_defaults opt['value'] = oc_value(opt['name']) || opt['value'] end end - - @use_template - @eruby - @update_zombie - @results end end end diff --git a/core/main/configuration.rb b/core/main/configuration.rb index e3a37144c1..c03253bc28 100644 --- a/core/main/configuration.rb +++ b/core/main/configuration.rb @@ -42,6 +42,7 @@ def initialize(config) # @return [Hash] YAML formatted hash def load(file) return nil unless File.exist?(file) + YAML.safe_load(File.binread(file)) end @@ -246,7 +247,7 @@ def load_extensions_config next end - y['beef']['extension'][y['beef']['extension'].keys.first]['path'] = cf.gsub(/config\.yaml/, '').gsub(%r{#{$root_dir}/}, '') + y['beef']['extension'][y['beef']['extension'].keys.first]['path'] = cf.gsub('config.yaml', '').gsub(%r{#{$root_dir}/}, '') @config = y.deep_merge(@config) end end diff --git a/core/main/console/banners.rb b/core/main/console/banners.rb index d262338133..5fdbd6bf2d 100644 --- a/core/main/console/banners.rb +++ b/core/main/console/banners.rb @@ -35,7 +35,7 @@ def print_welcome_msg # data += "Blog: http://blog.beefproject.com\n" data += "Wiki: https://github.com/beefproject/beef/wiki\n" print_more data - print_info 'Project Creator: ' + 'Wade Alcorn'.red + ' (@WadeAlcorn)' + print_info "Project Creator: #{'Wade Alcorn'.red} (@WadeAlcorn)" end # @@ -156,7 +156,6 @@ def print_dns print_more upstream_servers unless upstream_servers.empty? end end - end end end diff --git a/core/main/handlers/browserdetails.rb b/core/main/handlers/browserdetails.rb index f69eef9480..370329fdcd 100644 --- a/core/main/handlers/browserdetails.rb +++ b/core/main/handlers/browserdetails.rb @@ -71,8 +71,8 @@ def setup # Parse http_headers. Unfortunately Rack doesn't provide a util-method to get them :( @http_headers = {} - http_header = @data['request'].env.select { |k, _v| k.to_s.start_with? 'HTTP_' } - .each do |key, value| + @data['request'].env.select { |k, _v| k.to_s.start_with? 'HTTP_' } + .each do |key, value| @http_headers[key.sub(/^HTTP_/, '')] = value.force_encoding('UTF-8') end zombie.httpheaders = @http_headers.to_json @@ -242,7 +242,7 @@ def setup X_FORWARDED X_FORWARDED_FOR ].each do |header| - proxy_clients << (JSON.parse(zombie.httpheaders)[header]).to_s unless JSON.parse(zombie.httpheaders)[header].nil? + proxy_clients << JSON.parse(zombie.httpheaders)[header].to_s unless JSON.parse(zombie.httpheaders)[header].nil? end # retrieve proxy server @@ -400,8 +400,8 @@ def setup browser_plugins = get_param(@data['results'], 'browser.plugins') if BeEF::Filters.is_valid_browser_plugins?(browser_plugins) BD.set(session_id, 'browser.plugins', browser_plugins) - elsif browser_plugins == "[]" - err_msg "No browser plugins detected." + elsif browser_plugins == '[]' + err_msg 'No browser plugins detected.' else err_msg "Invalid browser plugins returned from the hook browser's initial connection." end @@ -458,7 +458,7 @@ def setup print_debug("Hooked browser [id:#{zombie.id}] has IP [ip: #{zombie.ip}]") if !os_name.nil? and !os_version.nil? - BeEF::Core::Models::NetworkHost.create(hooked_browser: zombie, ip: zombie.ip, ntype: 'Host', os: os_name + '-' + os_version) + BeEF::Core::Models::NetworkHost.create(hooked_browser: zombie, ip: zombie.ip, ntype: 'Host', os: "#{os_name}-#{os_version}") elsif !os_name.nil? BeEF::Core::Models::NetworkHost.create(hooked_browser: zombie, ip: zombie.ip, ntype: 'Host', os: os_name) else diff --git a/core/main/handlers/commands.rb b/core/main/handlers/commands.rb index 8d033b9e76..72ba0fc0ef 100644 --- a/core/main/handlers/commands.rb +++ b/core/main/handlers/commands.rb @@ -32,14 +32,14 @@ def initialize(data, kclass) def setup @http_params = @data['request'].params @http_header = {} - http_header = @data['request'].env.select { |k, _v| k.to_s.start_with? 'HTTP_' }.each do |key, value| + @data['request'].env.select { |k, _v| k.to_s.start_with? 'HTTP_' }.each do |key, value| @http_header[key.sub(/^HTTP_/, '')] = value.force_encoding('UTF-8') end # @note get and check command id from the request command_id = get_param(@data, 'cid') unless command_id.is_a?(Integer) - print_error("Command ID is invalid") + print_error('Command ID is invalid') return end diff --git a/core/main/handlers/hookedbrowsers.rb b/core/main/handlers/hookedbrowsers.rb index ea08a6f5be..dc50bff3bc 100644 --- a/core/main/handlers/hookedbrowsers.rb +++ b/core/main/handlers/hookedbrowsers.rb @@ -128,7 +128,7 @@ def confirm_browser_user_agent(user_agent) host_name = request.host unless BeEF::Filters.is_valid_hostname?(host_name) (print_error 'Invalid host name' - return) + return) end # Generate the hook js provided to the hookwed browser (the magic happens here) diff --git a/core/main/handlers/modules/beefjs.rb b/core/main/handlers/modules/beefjs.rb index 3c95cb5129..c381fa91c1 100644 --- a/core/main/handlers/modules/beefjs.rb +++ b/core/main/handlers/modules/beefjs.rb @@ -46,22 +46,22 @@ def build_beefjs!(req_host) print_debug "Excluding #{ext_js_sub_file} from core files obfuscation list" # do not obfuscate the file ext_js_sub_file_path = beef_js_path + ext_js_sub_file - ext_js_to_not_obfuscate << (File.read(ext_js_sub_file_path) + "\n\n") + ext_js_to_not_obfuscate << "#{File.read(ext_js_sub_file_path)}\n\n" else ext_js_sub_file_path = beef_js_path + ext_js_sub_file - ext_js_to_obfuscate << (File.read(ext_js_sub_file_path) + "\n\n") + ext_js_to_obfuscate << "#{File.read(ext_js_sub_file_path)}\n\n" end else # Evasion is not enabled, do not obfuscate anything ext_js_sub_file_path = beef_js_path + ext_js_sub_file - ext_js_to_not_obfuscate << (File.read(ext_js_sub_file_path) + "\n\n") + ext_js_to_not_obfuscate << "#{File.read(ext_js_sub_file_path)}\n\n" end end # @note construct the beef_js string from file(s) beef_js_sub_files.each do |beef_js_sub_file| beef_js_sub_file_path = beef_js_path + beef_js_sub_file - beef_js << (File.read(beef_js_sub_file_path) + "\n\n") + beef_js << "#{File.read(beef_js_sub_file_path)}\n\n" end # @note create the config for the hooked browser session @@ -74,7 +74,7 @@ def build_beefjs!(req_host) end if hook_session_config['beef_host'].eql? '0.0.0.0' hook_session_config['beef_host'] = req_host - hook_session_config['beef_url'].sub!(/0\.0\.0\.0/, req_host) + hook_session_config['beef_url'].sub!('0.0.0.0', req_host) end # @note set the XHR-polling timeout @@ -88,7 +88,7 @@ def build_beefjs!(req_host) if !hook_session_config['beef_public_port'].nil? && (hook_session_config['beef_port'] != hook_session_config['beef_public_port']) hook_session_config['beef_port'] = hook_session_config['beef_public_port'] hook_session_config['beef_url'].sub!(/#{hook_session_config['beef_port']}/, hook_session_config['beef_public_port']) - hook_session_config['beef_url'].sub!(/http:/, 'https:') if hook_session_config['beef_public_port'] == '443' + hook_session_config['beef_url'].sub!('http:', 'https:') if hook_session_config['beef_public_port'] == '443' end # @note Set some WebSocket properties @@ -121,7 +121,7 @@ def build_beefjs!(req_host) def find_beefjs_component_path(component) component_path = component component_path.gsub!(/beef./, '') - component_path.gsub!(/\./, '/') + component_path.gsub!('.', '/') component_path.replace "#{$root_dir}/core/main/client/#{component_path}.js" return false unless File.exist? component_path @@ -152,9 +152,9 @@ def build_missing_beefjs_components(beefjs_components) config = BeEF::Core::Configuration.instance if config.get('beef.extension.evasion.enable') evasion = BeEF::Extension::Evasion::Evasion.instance - @body << evasion.obfuscate(File.read(component_path) + "\n\n") + @body << evasion.obfuscate("#{File.read(component_path)}\n\n") else - @body << (File.read(component_path) + "\n\n") + @body << "#{File.read(component_path)}\n\n" end # @note finally we add the component to the list of components already generated so it does not get generated numerous times. diff --git a/core/main/handlers/modules/command.rb b/core/main/handlers/modules/command.rb index 006da1c2d1..47deee9e20 100644 --- a/core/main/handlers/modules/command.rb +++ b/core/main/handlers/modules/command.rb @@ -79,7 +79,7 @@ def add_command_instructions(command, hooked_browser) # //', "") ws.send(@output, hooked_browser.session) else - @body << (@output + "\n\n") + @body << "#{@output}\n\n" end # @note prints the event to the console if BeEF::Settings.console? diff --git a/core/main/handlers/modules/legacybeefjs.rb b/core/main/handlers/modules/legacybeefjs.rb index 66d59b14aa..8e0f908fe0 100644 --- a/core/main/handlers/modules/legacybeefjs.rb +++ b/core/main/handlers/modules/legacybeefjs.rb @@ -46,22 +46,22 @@ def legacy_build_beefjs!(req_host) print_debug "Excluding #{ext_js_sub_file} from core files obfuscation list" # do not obfuscate the file ext_js_sub_file_path = beef_js_path + ext_js_sub_file - ext_js_to_not_obfuscate << (File.read(ext_js_sub_file_path) + "\n\n") + ext_js_to_not_obfuscate << "#{File.read(ext_js_sub_file_path)}\n\n" else ext_js_sub_file_path = beef_js_path + ext_js_sub_file - ext_js_to_obfuscate << (File.read(ext_js_sub_file_path) + "\n\n") + ext_js_to_obfuscate << "#{File.read(ext_js_sub_file_path)}\n\n" end else # Evasion is not enabled, do not obfuscate anything ext_js_sub_file_path = beef_js_path + ext_js_sub_file - ext_js_to_not_obfuscate << (File.read(ext_js_sub_file_path) + "\n\n") + ext_js_to_not_obfuscate << "#{File.read(ext_js_sub_file_path)}\n\n" end end # @note construct the beef_js string from file(s) beef_js_sub_files.each do |beef_js_sub_file| beef_js_sub_file_path = beef_js_path + beef_js_sub_file - beef_js << (File.read(beef_js_sub_file_path) + "\n\n") + beef_js << "#{File.read(beef_js_sub_file_path)}\n\n" end # @note create the config for the hooked browser session @@ -74,7 +74,7 @@ def legacy_build_beefjs!(req_host) end if hook_session_config['beef_host'].eql? '0.0.0.0' hook_session_config['beef_host'] = req_host - hook_session_config['beef_url'].sub!(/0\.0\.0\.0/, req_host) + hook_session_config['beef_url'].sub!('0.0.0.0', req_host) end # @note set the XHR-polling timeout @@ -88,7 +88,7 @@ def legacy_build_beefjs!(req_host) if !hook_session_config['beef_public_port'].nil? && (hook_session_config['beef_port'] != hook_session_config['beef_public_port']) hook_session_config['beef_port'] = hook_session_config['beef_public_port'] hook_session_config['beef_url'].sub!(/#{hook_session_config['beef_port']}/, hook_session_config['beef_public_port']) - hook_session_config['beef_url'].sub!(/http:/, 'https:') if hook_session_config['beef_public_port'] == '443' + hook_session_config['beef_url'].sub!('http:', 'https:') if hook_session_config['beef_public_port'] == '443' end # @note Set some WebSocket properties @@ -121,7 +121,7 @@ def legacy_build_beefjs!(req_host) def legacy_find_beefjs_component_path(component) component_path = component component_path.gsub!(/beef./, '') - component_path.gsub!(/\./, '/') + component_path.gsub!('.', '/') component_path.replace "#{$root_dir}/core/main/client/#{component_path}.js" return false unless File.exist? component_path @@ -152,9 +152,9 @@ def legacy_build_missing_beefjs_components(beefjs_components) config = BeEF::Core::Configuration.instance if config.get('beef.extension.evasion.enable') evasion = BeEF::Extension::Evasion::Evasion.instance - @body << evasion.obfuscate(File.read(component_path) + "\n\n") + @body << evasion.obfuscate("#{File.read(component_path)}\n\n") else - @body << (File.read(component_path) + "\n\n") + @body << "#{File.read(component_path)}\n\n" end # @note finally we add the component to the list of components already generated so it does not get generated numerous times. diff --git a/core/main/handlers/modules/multistagebeefjs.rb b/core/main/handlers/modules/multistagebeefjs.rb index 40f5901827..3c71f434e6 100644 --- a/core/main/handlers/modules/multistagebeefjs.rb +++ b/core/main/handlers/modules/multistagebeefjs.rb @@ -46,22 +46,22 @@ def multi_stage_beefjs!(req_host) print_debug "Excluding #{ext_js_sub_file} from core files obfuscation list" # do not obfuscate the file ext_js_sub_file_path = beef_js_path + ext_js_sub_file - ext_js_to_not_obfuscate << (File.read(ext_js_sub_file_path) + "\n\n") + ext_js_to_not_obfuscate << "#{File.read(ext_js_sub_file_path)}\n\n" else ext_js_sub_file_path = beef_js_path + ext_js_sub_file - ext_js_to_obfuscate << (File.read(ext_js_sub_file_path) + "\n\n") + ext_js_to_obfuscate << "#{File.read(ext_js_sub_file_path)}\n\n" end else # Evasion is not enabled, do not obfuscate anything ext_js_sub_file_path = beef_js_path + ext_js_sub_file - ext_js_to_not_obfuscate << (File.read(ext_js_sub_file_path) + "\n\n") + ext_js_to_not_obfuscate << "#{File.read(ext_js_sub_file_path)}\n\n" end end # @note construct the beef_js string from file(s) beef_js_sub_files.each do |beef_js_sub_file| beef_js_sub_file_path = beef_js_path + beef_js_sub_file - beef_js << (File.read(beef_js_sub_file_path) + "\n\n") + beef_js << "#{File.read(beef_js_sub_file_path)}\n\n" end # @note create the config for the hooked browser session @@ -74,7 +74,7 @@ def multi_stage_beefjs!(req_host) end if hook_session_config['beef_host'].eql? '0.0.0.0' hook_session_config['beef_host'] = req_host - hook_session_config['beef_url'].sub!(/0\.0\.0\.0/, req_host) + hook_session_config['beef_url'].sub!('0.0.0.0', req_host) end # @note set the XHR-polling timeout @@ -88,7 +88,7 @@ def multi_stage_beefjs!(req_host) if !hook_session_config['beef_public_port'].nil? && (hook_session_config['beef_port'] != hook_session_config['beef_public_port']) hook_session_config['beef_port'] = hook_session_config['beef_public_port'] hook_session_config['beef_url'].sub!(/#{hook_session_config['beef_port']}/, hook_session_config['beef_public_port']) - hook_session_config['beef_url'].sub!(/http:/, 'https:') if hook_session_config['beef_public_port'] == '443' + hook_session_config['beef_url'].sub!('http:', 'https:') if hook_session_config['beef_public_port'] == '443' end # @note Set some WebSocket properties @@ -121,7 +121,7 @@ def multi_stage_beefjs!(req_host) def legacy_find_beefjs_component_path(component) component_path = component component_path.gsub!(/beef./, '') - component_path.gsub!(/\./, '/') + component_path.gsub!('.', '/') component_path.replace "#{$root_dir}/core/main/client/#{component_path}.js" return false unless File.exist? component_path @@ -152,9 +152,9 @@ def legacy_build_missing_beefjs_components(beefjs_components) config = BeEF::Core::Configuration.instance if config.get('beef.extension.evasion.enable') evasion = BeEF::Extension::Evasion::Evasion.instance - @body << evasion.obfuscate(File.read(component_path) + "\n\n") + @body << evasion.obfuscate("#{File.read(component_path)}\n\n") else - @body << (File.read(component_path) + "\n\n") + @body << "#{File.read(component_path)}\n\n" end # @note finally we add the component to the list of components already generated so it does not get generated numerous times. diff --git a/core/main/models/execution.rb b/core/main/models/execution.rb index 3d4051f179..b96c519545 100644 --- a/core/main/models/execution.rb +++ b/core/main/models/execution.rb @@ -6,7 +6,7 @@ module BeEF module Core - module Models # @note Stored info about the execution of the ARE on hooked browsers. + module Models # @note Stored info about the execution of the ARE on hooked browsers. class Execution < BeEF::Core::Model end end diff --git a/core/main/models/legacybrowseruseragents.rb b/core/main/models/legacybrowseruseragents.rb index cc383fe76b..93ec563d42 100644 --- a/core/main/models/legacybrowseruseragents.rb +++ b/core/main/models/legacybrowseruseragents.rb @@ -9,15 +9,14 @@ module Models # # Objects stores known 'legacy' browser User Agents. # - # This table is used to determine if a hooked browser is a 'legacy' + # This table is used to determine if a hooked browser is a 'legacy' # browser. # # TODO: make it an actual table # module LegacyBrowserUserAgents def self.user_agents - [ - ] + [] end end end diff --git a/core/main/network_stack/assethandler.rb b/core/main/network_stack/assethandler.rb index a0ef71c573..109548c85e 100644 --- a/core/main/network_stack/assethandler.rb +++ b/core/main/network_stack/assethandler.rb @@ -32,7 +32,7 @@ def bind_redirect(target, path = nil) @allocations[url] = { 'target' => target } @http_server.mount(url, BeEF::Core::NetworkStack::Handlers::Redirector.new(target)) @http_server.remap - print_info 'Redirector to [' + target + '] bound to url [' + url + ']' + print_info "Redirector to [#{target}] bound to url [#{url}]" url rescue StandardError => e print_error "Failed to mount #{path} : #{e.message}" @@ -53,7 +53,7 @@ def bind_raw(status, header, body, path = nil, _count = -1) BeEF::Core::NetworkStack::Handlers::Raw.new(status, header, body) ) @http_server.remap - print_info 'Raw HTTP bound to url [' + url + ']' + print_info "Raw HTTP bound to url [#{url}]" url rescue StandardError => e print_error "Failed to mount #{path} : #{e.message}" @@ -218,8 +218,8 @@ def unbind_socket(name) # @param [Integer] length The amount of characters to be used when generating a random URL # @return [String] Generated URL def build_url(path, extension, length = 20) - url = path.nil? ? '/' + rand(36**length).to_s(36) : path - url += extension.nil? ? '' : '.' + extension + url = path.nil? ? "/#{rand(36**length).to_s(36)}" : path + url += extension.nil? ? '' : ".#{extension}" url end @@ -244,9 +244,6 @@ def check(url) false end - - @http_server - @allocations end end end diff --git a/core/main/network_stack/handlers/dynamicreconstruction.rb b/core/main/network_stack/handlers/dynamicreconstruction.rb index 039e8419ae..e1f1a08170 100644 --- a/core/main/network_stack/handlers/dynamicreconstruction.rb +++ b/core/main/network_stack/handlers/dynamicreconstruction.rb @@ -51,9 +51,9 @@ class DynamicReconstruction < BeEF::Core::Router::Router def check_packets checked = [] PQ.each do |packet| - next if checked.include?(packet[:beefhook] + ':' + String(packet[:stream_id])) + next if checked.include?("#{packet[:beefhook]}:#{String(packet[:stream_id])}") - checked << (packet[:beefhook] + ':' + String(packet[:stream_id])) + checked << "#{packet[:beefhook]}:#{String(packet[:stream_id])}" pc = 0 PQ.each do |p| pc += 1 if packet[:beefhook] == p[:beefhook] and packet[:stream_id] == p[:stream_id] @@ -72,14 +72,14 @@ def check_packets res['request'] = request session_key = BeEF::Core::Configuration.instance.get('beef.http.hook_session_name') res['beefsession'] = request.cookies[session_key] || - request.params[session_key] || - request.env[session_key] + request.params[session_key] || + request.env[session_key] execute(res) - rescue JSON::ParserError => e + rescue JSON::ParserError print_debug 'Network stack could not decode packet stream.' - print_debug 'Dumping Stream Data [base64]: ' + data - print_debug 'Dumping Stream Data: ' + b64 + print_debug "Dumping Stream Data [base64]: #{data}" + print_debug "Dumping Stream Data: #{b64}" end end end diff --git a/core/main/network_stack/handlers/raw.rb b/core/main/network_stack/handlers/raw.rb index b3183eabb6..efce0f232e 100644 --- a/core/main/network_stack/handlers/raw.rb +++ b/core/main/network_stack/handlers/raw.rb @@ -17,15 +17,11 @@ def initialize(status, header = {}, body = nil) def call(_env) # [@status, @header, @body] @response = Rack::Response.new( - body = @body, - status = @status, - header = @header + @body, + @status, + @header ) end - - @request - - @response end end end diff --git a/core/main/network_stack/handlers/redirector.rb b/core/main/network_stack/handlers/redirector.rb index 5265028f96..9fc02871b9 100644 --- a/core/main/network_stack/handlers/redirector.rb +++ b/core/main/network_stack/handlers/redirector.rb @@ -18,18 +18,14 @@ def initialize(target) def call(_env) @response = Rack::Response.new( - body = ['302 found'], - status = 302, - header = { + ['302 found'], + 302, + { 'Content-Type' => 'text', 'Location' => @target } ) end - - @request - - @response end end end diff --git a/core/main/network_stack/websocket/websocket.rb b/core/main/network_stack/websocket/websocket.rb index 31fed5b2c3..7425ef1382 100644 --- a/core/main/network_stack/websocket/websocket.rb +++ b/core/main/network_stack/websocket/websocket.rb @@ -101,7 +101,7 @@ def start_websocket_server(ws_options) unless msg_hash['cookie'].nil? print_debug('[WebSocket] Browser says hello! WebSocket is running') # insert new connection in activesocket - @@activeSocket[(msg_hash['cookie']).to_s] = ws + @@activeSocket[msg_hash['cookie'].to_s] = ws print_debug("[WebSocket] activeSocket content [#{@@activeSocket}]") hb_session = msg_hash['cookie'] diff --git a/core/main/rest/handlers/autorun_engine.rb b/core/main/rest/handlers/autorun_engine.rb index 24b73b02e7..6b7ad31bc2 100644 --- a/core/main/rest/handlers/autorun_engine.rb +++ b/core/main/rest/handlers/autorun_engine.rb @@ -73,6 +73,7 @@ class AutorunEngine < BeEF::Core::Router::Router 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 @@ -91,6 +92,7 @@ class AutorunEngine < BeEF::Core::Router::Router 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) @@ -111,7 +113,7 @@ class AutorunEngine < BeEF::Core::Router::Router get '/run/:rule_id' do rule_id = params[:rule_id] - online_hooks = BeEF::Core::Models::HookedBrowser.where('lastseen >= ?', (Time.new.to_i - 15)) + 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 diff --git a/core/main/rest/handlers/hookedbrowsers.rb b/core/main/rest/handlers/hookedbrowsers.rb index 0b504099a8..898984d7f8 100644 --- a/core/main/rest/handlers/hookedbrowsers.rb +++ b/core/main/rest/handlers/hookedbrowsers.rb @@ -25,14 +25,14 @@ class HookedBrowsers < BeEF::Core::Router::Router # get '/' do if config.get('beef.http.websocket.enable') == false - online_hooks = hb_to_json(BeEF::Core::Models::HookedBrowser.where('lastseen >= ?', (Time.new.to_i - 15))) - offline_hooks = hb_to_json(BeEF::Core::Models::HookedBrowser.where('lastseen <= ?', (Time.new.to_i - 15))) + online_hooks = hb_to_json(BeEF::Core::Models::HookedBrowser.where('lastseen >= ?', Time.new.to_i - 15)) + offline_hooks = hb_to_json(BeEF::Core::Models::HookedBrowser.where('lastseen <= ?', Time.new.to_i - 15)) # If we're using websockets use the designated threshold timeout to determine live, instead of hardcoded 15 # Why is it hardcoded 15? else timeout = config.get('beef.http.websocket.ws_poll_timeout') - online_hooks = hb_to_json(BeEF::Core::Models::HookedBrowser.where('lastseen >= ?', (Time.new.to_i - timeout))) - offline_hooks = hb_to_json(BeEF::Core::Models::HookedBrowser.where('lastseen <= ?', (Time.new.to_i - timeout))) + online_hooks = hb_to_json(BeEF::Core::Models::HookedBrowser.where('lastseen >= ?', Time.new.to_i - timeout)) + offline_hooks = hb_to_json(BeEF::Core::Models::HookedBrowser.where('lastseen <= ?', Time.new.to_i - timeout)) end output = { @@ -74,7 +74,7 @@ class HookedBrowsers < BeEF::Core::Router::Router xssraysdetails = BeEF::Core::Models::Xssraysdetail.where(hooked_browser_id: hb.id) xssraysdetails.destroy_all - rescue StandardError => e + rescue StandardError # @todo why is this error swallowed? # the xssraysscan module may not be enabled end diff --git a/core/main/rest/handlers/modules.rb b/core/main/rest/handlers/modules.rb index 3ae859419c..f8602add7c 100644 --- a/core/main/rest/handlers/modules.rb +++ b/core/main/rest/handlers/modules.rb @@ -145,7 +145,7 @@ class Modules < BeEF::Core::Router::Router options = [] data.each { |k, v| options.push({ 'name' => k, 'value' => v }) } exec_results = BeEF::Module.execute(modk, params[:session], options) - exec_results.nil? ? '{"success":"false"}' : '{"success":"true","command_id":"' + exec_results.to_s + '"}' + exec_results.nil? ? '{"success":"false"}' : "{\"success\":\"true\",\"command_id\":\"#{exec_results}\"}" rescue StandardError print_error "Invalid JSON input for module '#{params[:mod_id]}'" error 400 # Bad Request @@ -172,7 +172,7 @@ class Modules < BeEF::Core::Router::Router # curl example (alert module with custom text, 2 hooked browsers)): # # curl -H "Content-Type: application/json; charset=UTF-8" -d '{"mod_id":110,"mod_params":{"text":"mucci?"},"hb_ids":[1,2]}' - #-X POST http://127.0.0.1:3000/api/modules/multi_browser?token=2316d82702b83a293e2d46a0886a003a6be0a633 + # -X POST http://127.0.0.1:3000/api/modules/multi_browser?token=2316d82702b83a293e2d46a0886a003a6be0a633 # post '/multi_browser' do request.body.rewind diff --git a/core/main/router/router.rb b/core/main/router/router.rb index a91ea007ab..aa685cc1e2 100644 --- a/core/main/router/router.rb +++ b/core/main/router/router.rb @@ -186,8 +186,8 @@ def index_page "
" \ '' \ '' \ - '' \ - 'For information on CentOS please visit the CentOS website.
' \ 'CentOS is an Operating System and it is used to power this website; however, the webserver is owned by the domain owner and not the CentOS Project. If you have issues with the content of this site, contact the owner of the domain, not the CentOS project.' \ @@ -235,12 +235,12 @@ def index_page "\n" \ "
\n" \ "The requested URL was not found on this server.
-The requested URL was not found on this server.
+
-The page cannot be found-The page you are looking for might have been removed, had its name changed, or is temporarily unavailable. -- Please try the following: -
HTTP Error 404 - File or directory not found.
- |
+ The page cannot be found+ The page you are looking for might have been removed, had its name changed, or is temporarily unavailable. ++ Please try the following: +
HTTP Error 404 - File or directory not found.
+ |