Преглед на файлове

Rename attack parameter for ports

dustin.born преди 7 години
родител
ревизия
989b5a6d21
променени са 2 файла, в които са добавени 7 реда и са изтрити 7 реда
  1. 1 3
      code/Attack/AttackParameters.py
  2. 6 4
      code/Attack/MembersMgmtCommAttack.py

+ 1 - 3
code/Attack/AttackParameters.py

@@ -41,6 +41,7 @@ class Parameter(Enum):
     PORT_SOURCE_RANDOMIZE = 'port.src.shuffle'  # randomizes the source port if a list of sources ports is given
     NAT_PRESENT = 'nat.present'  # if NAT is active, external computers cannot initiate a communication in MembersMgmtCommAttack
     TTL_FROM_CAIDA = 'ttl.from.caida'  # if True, TTLs are assigned based on the TTL distributions from the CAIDA dataset
+    MULTIPORT = "multiport"  # select destination port as an ephemeral port if True, calculate the destination port based on the hostname, otherwise 
     # recommended type: Filepath ------------------------------------
     FILE_CSV = 'file.csv'  # filepath to CSV containing a communication pattern
     FILE_XML = 'file.xml'  # filepath to XML containing a communication pattern
@@ -52,9 +53,6 @@ class Parameter(Enum):
     IP_REUSE_EXTERNAL = 'ip.reuse.external'  # percentage of public IPs in original PCAP to be reused
     # recommended type: Positive Integer between 0 and 100 ------------------------------------
     PACKET_PADDING = 'packet.padding'
-    # calculate the destination port based on the hostname (like some botnets do)
-    # otherwise the destination port is a normal ephemeral port
-    BOTNET_DST_PORT_CALCULATION = "botnet.dstportcalculation"
     #recommended type: interval selection strategy, i.e. 'random', 'optimal' or 'custom' ------------------------------------
     INTERVAL_SELECT_STRATEGY = 'interval.selection.strategy'
 

+ 6 - 4
code/Attack/MembersMgmtCommAttack.py

@@ -113,7 +113,7 @@ class MembersMgmtCommAttack(BaseAttack.BaseAttack):
 
             # whether the destination port of a response should be the ephemeral port 
             # its request came from or a static (server)port based on a hostname
-            Param.BOTNET_DST_PORT_CALCULATION: ParameterTypes.TYPE_BOOLEAN,
+            Param.MULTIPORT: ParameterTypes.TYPE_BOOLEAN,
 
             # information about the interval selection strategy
             Param.INTERVAL_SELECT_STRATEGY: ParameterTypes.TYPE_INTERVAL_SELECT_STRAT,
@@ -163,7 +163,9 @@ class MembersMgmtCommAttack(BaseAttack.BaseAttack):
 
         # choose the input PCAP as default base for the TTL distribution
         self.add_param_value(Param.TTL_FROM_CAIDA, False)
-        self.add_param_value(Param.BOTNET_DST_PORT_CALCULATION, True)
+
+        # do not use multiple ports for requests and responses
+        self.add_param_value(Param.MULTIPORT, False)
 
         # interval selection strategy
         self.add_param_value(Param.INTERVAL_SELECT_STRATEGY, "optimal")
@@ -603,10 +605,10 @@ class MembersMgmtCommAttack(BaseAttack.BaseAttack):
 
         portSelector = PortSelectors.LINUX
         # create port configurations for the bots
-        calculate_dst_port = self.get_param_value(Param.BOTNET_DST_PORT_CALCULATION)
+        use_multiple_ports = self.get_param_value(Param.MULTIPORT)
         for bot in sorted(bot_configs):
             bot_configs[bot]["SrcPort"] = portSelector.select_port_udp()
-            if calculate_dst_port:
+            if not use_multiple_ports:
                 bot_configs[bot]["DstPort"] = Generator.gen_random_server_port()
             else:
                 bot_configs[bot]["DstPort"] = portSelector.select_port_udp()