Browse Source

Added experimental functionality to inject botnet traffic into a pre-specified IP Address

leonboeck 5 years ago
parent
commit
d4b8726341
2 changed files with 12 additions and 3 deletions
  1. 2 1
      code/Attack/AttackParameters.py
  2. 10 2
      code/Attack/MembersMgmtCommAttack.py

+ 2 - 1
code/Attack/AttackParameters.py

@@ -14,6 +14,7 @@ class Parameter(enum.Enum):
     HOSTING_IP = 'hosting.ip'  # IP address(es) hosting the vulnerable service
     HOSTING_PERCENTAGE = 'hosting.percentage'  # percentage of target IPs hosting the vulnerable service
     IP_VICTIM = 'ip.victim'
+    INJECT_INTO_IPS = 'inject.ip'
     # recommended type: MAC address ------------------------------
     MAC_SOURCE = 'mac.src'  # MAC address of source
     MAC_DESTINATION = 'mac.dst'  # MAC address of destination
@@ -87,4 +88,4 @@ class ParameterTypes(enum.Enum):
     TYPE_FILEPATH = 10
     TYPE_PERCENTAGE = 11
     TYPE_PADDING = 12
-    TYPE_INTERVAL_SELECT_STRAT = 13
+    TYPE_INTERVAL_SELECT_STRAT = 13

+ 10 - 2
code/Attack/MembersMgmtCommAttack.py

@@ -50,6 +50,7 @@ class MembersMgmtCommAttack(BaseAttack.BaseAttack):
             Param.IP_REUSE_TOTAL: ParameterTypes.TYPE_PERCENTAGE,
             Param.IP_REUSE_LOCAL: ParameterTypes.TYPE_PERCENTAGE,
             Param.IP_REUSE_EXTERNAL: ParameterTypes.TYPE_PERCENTAGE,
+            Param.INJECT_INTO_IPS: ParameterTypes.TYPE_IP_ADDRESS,
 
             # the user-selected padding to add to every packet
             Param.PACKET_PADDING: ParameterTypes.TYPE_PADDING,
@@ -363,7 +364,7 @@ class MembersMgmtCommAttack(BaseAttack.BaseAttack):
                         dist = Lea.fromSeq(avg_delay_local)
                     delay = 0
                     
-                 while delay < 50 or (float(delay)*0.000001 > 5):
+                    while delay < 50 or (float(delay)*0.000001 > 5):
                         delay = dist.random()
                     respns_msg.time = req_msg.time + float(delay) * 0.000001
 
@@ -542,10 +543,17 @@ class MembersMgmtCommAttack(BaseAttack.BaseAttack):
         # assign addresses for local IDs
         if number_local_ids > 0:
             reuse_count_local = int(reuse_percent_total * reuse_percent_local * number_local_ids)
-            existing_local_ips = sorted(pcapops.get_existing_local_ips(reuse_count_local))
+            existing_local_ips=[]
+            if(self.get_param_value(Param.INJECT_INTO_IPS)):
+                existing_local_ips.append(self.get_param_value(Param.INJECT_INTO_IPS))
+                existing_local_ips+=(sorted(pcapops.get_existing_local_ips(reuse_count_local-1)))            
+            else:
+                existing_local_ips = (sorted(pcapops.get_existing_local_ips(reuse_count_local)))
             new_local_ips = sorted(pcapops.get_new_local_ips(number_local_ids - len(existing_local_ips)))
             add_ids_to_config(sorted(local_ids), existing_local_ips, new_local_ips, bot_configs)
 
+
+
         # assign addresses for external IDs
         if number_external_ids > 0:
             reuse_count_external = int(reuse_percent_total * reuse_percent_external * number_external_ids)