Add BeEF::Filters.is_valid_port

This commit is contained in:
Brendan Coles
2015-06-29 19:31:35 +00:00
parent c387778959
commit 06bbfe9c3b
2 changed files with 10 additions and 0 deletions

View File

@@ -142,6 +142,15 @@ module Filters
valid
end
# Checks if the given string is a valid TCP port
# @param [String] port string for testing
# @return [Boolean] true if the string is a valid TCP port, otherwise false
def self.is_valid_port?(port)
valid = false
valid = true if port.to_i > 0 && port.to_i < 2**16
valid
end
# Checks if string is a valid domain name
# @param [String] domain string for testing
# @return [Boolean] If the string is a valid domain name

View File

@@ -29,6 +29,7 @@ module BeEF
def self.add(service={})
(print_error "Invalid hooked browser session"; return) if not BeEF::Filters.is_valid_hook_session_id?(service[:hooked_browser_id])
(print_error "Invalid IP address"; return) if not BeEF::Filters.is_valid_ip?(service[:ip])
(print_error "Invalid port"; return) if not BeEF::Filters.is_valid_port?(service[:port])
# store the returned network host details
BeEF::Core::Models::NetworkHost.add(