Пример #1
0
 def add_port(self, port):
     """
     Add the specified port to the list of ports to scan.
     :param port: The port to add
     :return: None
     """
     ValidationHelper.validate_port(port)
     self._ports.add(port)
Пример #2
0
 def target_port(self, new_value):
     """
     Set the port that should be scanned.
     :param new_value: The value to set as the port to scan.
     :return: None
     """
     ValidationHelper.validate_port(new_value)
     self._target_port = int(new_value)
Пример #3
0
 def _process_data(self):
     to_process = self.wrapped_data
     if ":" not in to_process:
         raise InvalidUrlError("No : found in URL (%s)." % (to_process, ))
     self._scheme = to_process[:to_process.find(":")]
     to_process = to_process[to_process.find(":") + 1:]
     if not to_process.startswith("//"):
         raise InvalidUrlError(
             "No trailing double slashes found after URL scheme (%s)." %
             (self.wrapped_data, ))
     to_process = to_process[2:]
     first_slash = to_process.find("/")
     first_question = to_process.find("?")
     first_hash = to_process.find("#")
     encounters = [first_slash, first_question, first_hash]
     if all([x == -1 for x in encounters]):
         self._authority = to_process
         to_process = ""
     else:
         encounters = filter(lambda x: x > -1, encounters)
         first_encounter = min(encounters)
         self._authority = to_process[:first_encounter]
         to_process = to_process[first_encounter:]
     if "@" in self.authority:
         user_pass = self.authority[:self.authority.find("@")]
         if ":" not in user_pass:
             raise InvalidUrlError(
                 "Credentials supplied in URL, but no colon was found delimiting them (%s)."
                 % (self.wrapped_data, ))
         self._username = user_pass[:user_pass.find(":")]
         self._password = user_pass[user_pass.find(":") + 1:]
         rest_of_authority = self.authority[self.authority.find("@") + 1:]
     else:
         rest_of_authority = self.authority
     if ":" in rest_of_authority:
         self._destination = rest_of_authority[:rest_of_authority.find(":")]
         port = rest_of_authority[rest_of_authority.find(":") + 1:]
         ValidationHelper.validate_port(port)
         self._port = int(port)
     else:
         self._destination = rest_of_authority
     self._full_path_string = to_process