Remove Ruby Object patches (#2772)
This commit is contained in:
@@ -69,8 +69,8 @@ module BeEF
|
||||
end
|
||||
end
|
||||
|
||||
exec_order.each { |order| return [false, 'execution_order values must be Integers'] unless order.integer? }
|
||||
exec_delay.each { |delay| return [false, 'execution_delay values must be Integers'] unless delay.integer? }
|
||||
exec_order.each { |order| return [false, 'execution_order values must be Integers'] unless order.is_a?(Integer) }
|
||||
exec_delay.each { |delay| return [false, 'execution_delay values must be Integers'] unless delay.is_a?(Integer) }
|
||||
|
||||
return [false, 'execution_order and execution_delay values must be consistent with modules numbers'] unless
|
||||
modules.size == exec_order.size && modules.size == exec_delay.size
|
||||
|
||||
@@ -20,7 +20,7 @@ module BeEF
|
||||
# @param [String] configuration_file Configuration file to be loaded,
|
||||
# by default loads $root_dir/config.yaml
|
||||
def initialize(config)
|
||||
raise TypeError, "'config' needs to be a string" unless config.string?
|
||||
raise TypeError, "'config' needs to be a string" unless config.is_a?(String)
|
||||
raise TypeError, "Configuration file '#{config}' cannot be found" unless File.exist? config
|
||||
|
||||
begin
|
||||
|
||||
@@ -54,8 +54,8 @@ module BeEF
|
||||
# @param length integer length of returned string
|
||||
#
|
||||
def self.random_alphanum_string(length = 10)
|
||||
raise TypeError, 'Invalid length' unless length.integer?
|
||||
raise TypeError, 'Invalid length' unless length.positive?
|
||||
raise TypeError, "'length' is #{length.class}; expected Integer" unless length.is_a?(Integer)
|
||||
raise TypeError, "Invalid length: #{length}" unless length.positive?
|
||||
|
||||
[*('a'..'z'), *('A'..'Z'), *('0'..'9')].shuffle[0, length].join
|
||||
end
|
||||
@@ -66,8 +66,8 @@ module BeEF
|
||||
# @param length integer length of returned string
|
||||
#
|
||||
def self.random_hex_string(length = 10)
|
||||
raise TypeError, 'Invalid length' unless length.integer?
|
||||
raise TypeError, 'Invalid length' unless length.positive?
|
||||
raise TypeError, "'length' is #{length.class}; expected Integer" unless length.is_a?(Integer)
|
||||
raise TypeError, "Invalid length: #{length}" unless length.positive?
|
||||
|
||||
SecureRandom.random_bytes(length).unpack1('H*')[0...length]
|
||||
end
|
||||
|
||||
@@ -48,7 +48,7 @@ module BeEF
|
||||
# @return [Hash] IP address lookup results
|
||||
#
|
||||
def lookup(ip)
|
||||
raise TypeError, '"ip" needs to be a string' unless ip.string?
|
||||
raise TypeError, '"ip" needs to be a string' unless ip.is_a?(String)
|
||||
|
||||
return unless @enabled
|
||||
|
||||
|
||||
@@ -38,15 +38,15 @@ module BeEF
|
||||
|
||||
# @note get and check command id from the request
|
||||
command_id = get_param(@data, 'cid')
|
||||
unless command_id.integer?
|
||||
print_error 'command_id is invalid'
|
||||
unless command_id.is_a?(Integer)
|
||||
print_error("Command ID is invalid")
|
||||
return
|
||||
end
|
||||
|
||||
# @note get and check session id from the request
|
||||
beefhook = get_param(@data, 'beefhook')
|
||||
unless BeEF::Filters.is_valid_hook_session_id?(beefhook)
|
||||
print_error 'BeEF hook is invalid'
|
||||
print_error 'BeEF hook session ID is invalid'
|
||||
return
|
||||
end
|
||||
|
||||
@@ -68,7 +68,7 @@ module BeEF
|
||||
end
|
||||
|
||||
command_status = @data['status']
|
||||
unless command_status.integer?
|
||||
unless command_status.is_a?(Integer)
|
||||
print_error 'command status is invalid'
|
||||
return
|
||||
end
|
||||
|
||||
@@ -35,9 +35,9 @@ module BeEF
|
||||
time_now = Time.now
|
||||
|
||||
# arguments type checking
|
||||
raise TypeError, '"from" needs to be a string' unless from.string?
|
||||
raise TypeError, '"event" needs to be a string' unless event.string?
|
||||
raise TypeError, '"Hooked Browser ID" needs to be an integer' unless hb.integer?
|
||||
raise TypeError, "'from' is #{from.class}; expected String" unless from.is_a?(String)
|
||||
raise TypeError, "'event' is #{event.class}; expected String" unless event.is_a?(String)
|
||||
raise TypeError, "'hb' hooked browser ID is #{hb.class}; expected Integer" unless hb.is_a?(Integer)
|
||||
|
||||
# logging the new event into the database
|
||||
@logs.create(logtype: from.to_s, event: event.to_s, date: time_now, hooked_browser_id: hb).save!
|
||||
|
||||
@@ -23,11 +23,11 @@ module BeEF
|
||||
#
|
||||
def self.save_result(hook_session_id, command_id, command_friendly_name, result, status)
|
||||
# @note argument type checking
|
||||
raise TypeError, '"hook_session_id" needs to be a string' unless hook_session_id.string?
|
||||
raise TypeError, '"command_id" needs to be an integer' unless command_id.integer?
|
||||
raise TypeError, '"command_friendly_name" needs to be a string' unless command_friendly_name.string?
|
||||
raise TypeError, '"result" needs to be a hash' unless result.hash?
|
||||
raise TypeError, '"status" needs to be an integer' unless status.integer?
|
||||
raise TypeError, '"hook_session_id" needs to be a string' unless hook_session_id.is_a?(String)
|
||||
raise TypeError, '"command_id" needs to be an integer' unless command_id.is_a?(Integer)
|
||||
raise TypeError, '"command_friendly_name" needs to be a string' unless command_friendly_name.is_a?(String)
|
||||
raise TypeError, '"result" needs to be a hash' unless result.is_a?(Hash)
|
||||
raise TypeError, '"status" needs to be an integer' unless status.is_a?(Integer)
|
||||
|
||||
# @note get the hooked browser structure and id from the database
|
||||
hooked_browser = BeEF::Core::Models::HookedBrowser.where(session: hook_session_id).first || nil
|
||||
|
||||
@@ -48,7 +48,7 @@ module BeEF
|
||||
#
|
||||
def mount(url, http_handler_class, args = nil)
|
||||
# argument type checking
|
||||
raise TypeError, '"url" needs to be a string' unless url.string?
|
||||
raise TypeError, '"url" needs to be a string' unless url.is_a?(String)
|
||||
|
||||
@mounts[url] = if args.nil?
|
||||
http_handler_class
|
||||
@@ -64,7 +64,7 @@ module BeEF
|
||||
# @param [String] url URL to unmount.
|
||||
#
|
||||
def unmount(url)
|
||||
raise TypeError, '"url" needs to be a string' unless url.string?
|
||||
raise TypeError, '"url" needs to be a string' unless url.is_a?(String)
|
||||
|
||||
@mounts.delete url
|
||||
end
|
||||
|
||||
@@ -9,7 +9,6 @@ require 'core/ruby/security'
|
||||
|
||||
# @note Patching Ruby
|
||||
require 'core/ruby/module'
|
||||
require 'core/ruby/object'
|
||||
require 'core/ruby/string'
|
||||
require 'core/ruby/print'
|
||||
require 'core/ruby/hash'
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
#
|
||||
# Copyright (c) 2006-2023 Wade Alcorn - wade@bindshell.net
|
||||
# Browser Exploitation Framework (BeEF) - http://beefproject.com
|
||||
# See the file 'doc/COPYING' for copying permission
|
||||
#
|
||||
class Object
|
||||
# Returns true if the object is a Boolean
|
||||
# @return [Boolean] Whether the object is boolean
|
||||
def boolean?
|
||||
is_a?(TrueClass) || is_a?(FalseClass)
|
||||
end
|
||||
|
||||
# Returns true if the object is a String
|
||||
# @return [Boolean] Whether the object is a string
|
||||
def string?
|
||||
is_a?(String)
|
||||
end
|
||||
|
||||
# Returns true if the object is an Integer
|
||||
# @return [Boolean] Whether the object is an integer
|
||||
def integer?
|
||||
is_a?(Integer)
|
||||
end
|
||||
|
||||
# Returns true if the object is a hash
|
||||
# @return [Boolean] Whether the object is a hash
|
||||
def hash?
|
||||
is_a?(Hash)
|
||||
end
|
||||
|
||||
# Returns true if the object is a class
|
||||
# @return [Boolean] Whether the object is a class
|
||||
def class?
|
||||
is_a?(Class)
|
||||
end
|
||||
|
||||
# Returns true if the object is nil, and empty string, or empty array
|
||||
# @return [Boolean]
|
||||
def blank?
|
||||
respond_to?(:empty?) ? !!empty? : !self
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user