Browse Source

Fix #19 and #20: Process ports correctly

Carlos Garcia 7 years ago
parent
commit
1f37ee6ded
2 changed files with 3 additions and 3 deletions
  1. 2 2
      code/Attack/BaseAttack.py
  2. 1 1
      code/Attack/PortscanAttack.py

+ 2 - 2
code/Attack/BaseAttack.py

@@ -95,7 +95,7 @@ class BaseAttack(metaclass=ABCMeta):
             :param num: The port number as int.
             :return: True if the port number is invalid, otherwise False.
             """
-            return num < 0 or num > 65535
+            return num < 1 or num > 65535
 
         ports_input = ports_input.replace(' ', '').split(',')
         ports_output = []
@@ -114,7 +114,7 @@ class BaseAttack(metaclass=ABCMeta):
             elif '-' in port_entry or '..' in port_entry:
                 # port_entry describes a port range
                 # allowed format: '12-123', '12..123', '12...123'
-                match = re.match('^([0-9]{1,4})(?:-|\.{2,3})([0-9]{1,4})$', port_entry)
+                match = re.match('^([0-9]{1,5})(?:-|\.{2,3})([0-9]{1,5})$', port_entry)
                 # check validity of port range
                 # and create list of ports derived from given start and end port
                 (port_start, port_end) = int(match.group(1)), int(match.group(2))

+ 1 - 1
code/Attack/PortscanAttack.py

@@ -46,7 +46,7 @@ class PortscanAttack(BaseAttack.BaseAttack):
         self.add_param_value(Param.IP_SOURCE, most_used_ipAddress)
         self.add_param_value(Param.IP_SOURCE_RANDOMIZE, 'False')
         self.add_param_value(Param.IP_DESTINATION, '192.168.178.13')
-        self.add_param_value(Param.PORT_DESTINATION, '0-1023,1720,1900,8080')
+        self.add_param_value(Param.PORT_DESTINATION, '1-1023,1720,1900,8080')
         self.add_param_value(Param.PORT_SOURCE, '8542')
         self.add_param_value(Param.PORT_OPEN, '8080,9232,9233')
         self.add_param_value(Param.PORT_SOURCE_RANDOM, 'False')