minor refactor
git-svn-id: https://beef.googlecode.com/svn/trunk@720 b87d56ec-f9c0-11de-8c8a-61c5e9addfc9
This commit is contained in:
@@ -6,40 +6,43 @@ module BeEF
|
||||
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)
|
||||
return false if 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)
|
||||
return false if not is_non_empty_string?(str)
|
||||
return false if not 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)
|
||||
return false if not is_non_empty_string?(str)
|
||||
return false if not 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)
|
||||
return false if not is_non_empty_string?(str)
|
||||
return false if not has_valid_key_chars?(str)
|
||||
true
|
||||
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)
|
||||
return false if has_null?(str)
|
||||
return false if not has_valid_base_chars?(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)
|
||||
has_valid_base_chars?(str)
|
||||
return false if not is_non_empty_string?(str)
|
||||
return false if not has_valid_base_chars?(str)
|
||||
true
|
||||
end
|
||||
|
||||
# check for word and underscore chars
|
||||
@@ -47,7 +50,8 @@ module BeEF
|
||||
return false if str.nil?
|
||||
return false if not str.is_a? String
|
||||
return false if str.empty?
|
||||
(str =~ /[^\w_]/).nil?
|
||||
return false if not (str =~ /[^\w_]/).nil?
|
||||
true
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -5,49 +5,49 @@ module BeEF
|
||||
# verify the page title string is valid
|
||||
def self.is_valid_pagetitle?(str)
|
||||
return false if not str.is_a? String
|
||||
return false if BeEF::Filter.has_non_printable_char?(str)
|
||||
return false if has_non_printable_char?(str)
|
||||
return false if str.length > 50
|
||||
true
|
||||
end
|
||||
|
||||
# check the browser type value - for example, 'FF'
|
||||
def self.is_valid_browsername?(str)
|
||||
return false if not BeEF::Filter.is_non_empty_string?(str)
|
||||
return false if not is_non_empty_string?(str)
|
||||
return false if str.length > 2
|
||||
return false if BeEF::Filter.has_non_printable_char?(str)
|
||||
return false if has_non_printable_char?(str)
|
||||
true
|
||||
end
|
||||
|
||||
# check the os name value - for example, 'Windows XP'
|
||||
def self.is_valid_osname?(str)
|
||||
return false if not BeEF::Filter.is_non_empty_string?(str)
|
||||
return false if BeEF::Filter.has_non_printable_char?(str)
|
||||
return false if not is_non_empty_string?(str)
|
||||
return false if has_non_printable_char?(str)
|
||||
return false if str.length < 2
|
||||
true
|
||||
end
|
||||
|
||||
# verify the browser version string is valid
|
||||
def self.is_valid_browserversion?(str)
|
||||
return false if not BeEF::Filter.is_non_empty_string?(str)
|
||||
return false if BeEF::Filter.has_non_printable_char?(str)
|
||||
return false if not is_non_empty_string?(str)
|
||||
return false if has_non_printable_char?(str)
|
||||
return true if str.eql? "UNKNOWN"
|
||||
return false if not BeEF::Filter.nums_only?(str) and not BeEF::Filter.is_valid_float?(str)
|
||||
return false if not nums_only?(str) and not is_valid_float?(str)
|
||||
return false if str.length > 10
|
||||
true
|
||||
end
|
||||
|
||||
# verify the browser/UA string is valid
|
||||
def self.is_valid_browserstring?(str)
|
||||
return false if not BeEF::Filter.is_non_empty_string?(str)
|
||||
return false if BeEF::Filter.has_non_printable_char?(str)
|
||||
return false if not is_non_empty_string?(str)
|
||||
return false if has_non_printable_char?(str)
|
||||
return false if str.length > 200
|
||||
true
|
||||
end
|
||||
|
||||
# verify the hostname string is valid
|
||||
def self.is_valid_hostname?(str)
|
||||
return false if not BeEF::Filter.is_non_empty_string?(str)
|
||||
return false if BeEF::Filter.has_non_printable_char?(str)
|
||||
return false if not is_non_empty_string?(str)
|
||||
return false if has_non_printable_char?(str)
|
||||
return false if str.length > 255
|
||||
return false if (str =~ /^[a-zA-Z0-9][a-zA-Z0-9\-\.]*[a-zA-Z0-9]$/).nil?
|
||||
return false if not (str =~ /\.\./).nil?
|
||||
@@ -57,7 +57,7 @@ module BeEF
|
||||
|
||||
# verify the browser_plugins string is valid
|
||||
def self.is_valid_browser_plugins?(str)
|
||||
return false if not BeEF::Filter.is_non_empty_string?(str)
|
||||
return false if not is_non_empty_string?(str)
|
||||
return false if str.length > 400
|
||||
return (str =~ /[^\w\d\s()-.,;_!\302\256]/).nil? # \302\256 is the (r) character
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user