Browse Source

Add the botnet specific parameters

dustin.born 6 years ago
parent
commit
d605fd149c
3 changed files with 46 additions and 3 deletions
  1. 25 1
      code/Attack/AttackParameters.py
  2. 18 1
      code/Attack/BaseAttack.py
  3. 3 1
      code/Attack/MembersMgmtCommAttack.py

+ 25 - 1
code/Attack/AttackParameters.py

@@ -24,9 +24,11 @@ class Parameter(enum.Enum):
     ATTACK_DURATION = 'attack.duration' # in seconds
     VICTIM_BUFFER = 'victim.buffer' # in packets
     TARGET_URI = 'target.uri'
+    NUMBER_INITIATOR_BOTS = 'bots.count'
+    INTERVAL_SELECT_START = 'interval.selection.start'
+    INTERVAL_SELECT_END = 'interval.selection.end'
     # recommended type: domain -----------------------------------
     TARGET_HOST = 'target.host'
-
     # recommended type: Float ------------------------------------
     PACKETS_PER_SECOND = 'packets.per-second'  # packets per second
     INJECT_AT_TIMESTAMP = 'inject.at-timestamp'  # unix epoch time (seconds.millis) where attack should be injected
@@ -37,6 +39,24 @@ class Parameter(enum.Enum):
     PORT_DEST_ORDER_DESC = 'port.dst.order-desc'  # uses a descending port order instead of a ascending order
     IP_SOURCE_RANDOMIZE = 'ip.src.shuffle'  # randomizes the sources IP address if a list of IP addresses is given
     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
+    HIDDEN_MARK = "hidden_mark"  # indicating if the attack will mark generated packets
+    # 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
+    # recommended type: CommType ------------------------------------
+    COMM_TYPE = "comm.type"  # the locality of bots in botnet communication (e.g. local, external, mixed)
+    # recommended type: Percentage (0.0-1.0) ------------------------------------
+    IP_REUSE_TOTAL = 'ip.reuse.total'  # percentage of IPs in original PCAP to be reused
+    IP_REUSE_LOCAL = 'ip.reuse.local'  # percentage of private IPs in original PCAP to be reused
+    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'
+    #recommended type: interval selection strategy, i.e. 'random', 'optimal' or 'custom' ------------------------------------
+    INTERVAL_SELECT_STRATEGY = 'interval.selection.strategy'
+
 
     PROTOCOL_VERSION = 'protocol.version'
     HOSTING_VERSION = 'hosting.version'
@@ -60,3 +80,7 @@ class ParameterTypes(enum.Enum):
     TYPE_PACKET_POSITION = 7  # used to derive timestamp from parameter INJECT_AFTER_PACKET
     TYPE_DOMAIN = 8
     TYPE_STRING = 9
+    TYPE_FILEPATH = 10
+    TYPE_PERCENTAGE = 11
+    TYPE_PADDING = 12
+    TYPE_INTERVAL_SELECT_STRAT = 13

+ 18 - 1
code/Attack/BaseAttack.py

@@ -345,7 +345,7 @@ class BaseAttack(metaclass=abc.ABCMeta):
             print('Parameter ' + str(param_name) + ' not available for chosen attack. Skipping parameter.')
 
         # If value is query -> get value from database
-        elif self.statistics.is_query(value):
+        elif param_name != atkParam.Parameter.INTERVAL_SELECT_STRATEGY and self.statistics.is_query(value):
             value = self.statistics.process_db_query(value, False)
             if value is not None and value is not "":
                 is_valid = True
@@ -388,6 +388,23 @@ class BaseAttack(metaclass=abc.ABCMeta):
                 value = (ts / 1000000)  # convert microseconds from getTimestampMuSec into seconds
         elif param_type == atkParam.ParameterTypes.TYPE_DOMAIN:
             is_valid = self._is_domain(value)
+        elif param_type == atkParam.ParameterTypes.TYPE_FILEPATH:
+            is_valid = os.path.isfile(value)
+        elif param_type == atkParam.ParameterTypes.TYPE_PERCENTAGE:
+            is_valid_float, value = self._is_float(value)
+            if is_valid_float:
+                is_valid = value >= 0 and value <= 1
+            else:
+                is_valid = False
+        elif param_type == atkParam.ParameterTypes.TYPE_PADDING:
+            if isinstance(value, int):
+                is_valid = value >= 0 and value <= 100
+            elif isinstance(value, str) and value.isdigit():
+                value = int(value)
+                is_valid = value >= 0 and value <= 100
+        elif param_type == atkParam.ParameterTypes.TYPE_INTERVAL_SELECT_STRAT:
+            is_valid = value in {"random", "optimal", "custom"}
+
 
         # add value iff validation was successful
         if is_valid:

+ 3 - 1
code/Attack/MembersMgmtCommAttack.py

@@ -87,7 +87,6 @@ class MembersMgmtCommAttack(BaseAttack.BaseAttack):
             # parameters regarding attack
             Param.INJECT_AT_TIMESTAMP: ParameterTypes.TYPE_FLOAT,
             Param.INJECT_AFTER_PACKET: ParameterTypes.TYPE_PACKET_POSITION,
-            Param.PACKETS_PER_SECOND: ParameterTypes.TYPE_FLOAT,
             Param.PACKETS_LIMIT: ParameterTypes.TYPE_INTEGER_POSITIVE,
             Param.ATTACK_DURATION: ParameterTypes.TYPE_INTEGER_POSITIVE,
 
@@ -121,6 +120,9 @@ class MembersMgmtCommAttack(BaseAttack.BaseAttack):
             Param.INTERVAL_SELECT_STRATEGY: ParameterTypes.TYPE_INTERVAL_SELECT_STRAT,
             Param.INTERVAL_SELECT_START: ParameterTypes.TYPE_INTEGER_POSITIVE,
             Param.INTERVAL_SELECT_END: ParameterTypes.TYPE_INTEGER_POSITIVE,
+
+            # determines whether injected packets are marked with an unused IP option
+            # to easily filter them in e.g. wireshark
             Param.HIDDEN_MARK: ParameterTypes.TYPE_BOOLEAN
         }