Add BeEF::Filters.is_valid_port
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user