Files
beef/lib/filter/command.rb
wade@bindshell.net 7e65b30b4a Updated to fix issue 222. The filtering prevented percent characters in the URL which impacted URL encoded characters. They are now permitted.
An additional filtering function was added: has_valid_base_chars?(). Wherever possible this function should not be used and instead specific ones should be employed. 


git-svn-id: https://beef.googlecode.com/svn/trunk@719 b87d56ec-f9c0-11de-8c8a-61c5e9addfc9
2011-01-26 07:03:55 +00:00

56 lines
1.6 KiB
Ruby

module BeEF
module Filter
# check if the string is a valid path from a HTTP request
def self.is_valid_path_info?(str)
return false if str.nil?
return false if not str.is_a? String
return false if BeEF::Filter.has_non_printable_char?(str)
true
end
# check if the command id valid
def self.is_valid_command_id?(str)
return false if not BeEF::Filter.is_non_empty_string?(str)
return false if not BeEF::Filter.nums_only?(str)
true
end
# check if the session id valid
def self.is_valid_hook_session_id?(str)
return false if not BeEF::Filter.is_non_empty_string?(str)
return false if not BeEF::Filter.has_valid_key_chars?(str)
true
end
# check if valid command module datastore key
def self.is_valid_command_module_datastore_key?(str)
return false if not BeEF::Filter.is_non_empty_string?(str)
return BeEF::Filter.has_valid_key_chars?(str)
end
# check if valid command module datastore value
def self.is_valid_command_module_datastore_param?(str)
return false if BeEF::Filter.has_null?(str)
has_valid_base_chars?(str)
end
# check for word and some punc chars
def self.has_valid_key_chars?(str)
return false if not BeEF::Filter.is_non_empty_string?(str)
has_valid_base_chars?(str)
end
# check for word and underscore chars
def self.has_valid_param_chars?(str)
return false if str.nil?
return false if not str.is_a? String
return false if str.empty?
(str =~ /[^\w_]/).nil?
end
end
end