Files
beef/lib/filter/init.rb
scotty.b.brown@gmail.com 5fb01bea01 Fixing comment in code
git-svn-id: https://beef.googlecode.com/svn/trunk@649 b87d56ec-f9c0-11de-8c8a-61c5e9addfc9
2011-01-02 00:07:49 +00:00

70 lines
2.3 KiB
Ruby

module BeEF
module Filter
# 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 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 str.length > 2
return false if BeEF::Filter.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 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 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 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 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 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?
return false if not (str =~ /\-\-/).nil?
true
end
# 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 BeEF::Filter.has_non_printable_char?(str)
return false if str.length > 255
puts "TODO filter browser plugins: issue 179"
true
end
end
end