Files
beef/lib/filter/command.rb
wade@bindshell.net 37c75f68dc comment added
git-svn-id: https://beef.googlecode.com/svn/trunk@593 b87d56ec-f9c0-11de-8c8a-61c5e9addfc9
2010-12-03 22:56:08 +00:00

57 lines
1.7 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_commmamd_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_commmamd_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_commmamd_module_datastore_param?(str)
return false if BeEF::Filter.has_null?(str)
return false if BeEF::Filter.has_non_printable_char?(str)
true
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)
(str =~ /[^\w\d\s()-.,;_\302\256]/).nil? # \302\256 is the (r) character
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