|
@@ -27,6 +27,10 @@ from ID2TLib.MapInputCSVToIDs import find_interval_with_most_comm, determine_id_
|
|
|
from ID2TLib.MacAddressGenerator import MacAddressGenerator
|
|
|
from ID2TLib.PortGenerator import gen_random_server_port
|
|
|
|
|
|
+###### MOVE LOCAL, EXTERNAL IP DECISION INTO MAP CLASS ???? ######
|
|
|
+###### REQUEST/REPLY IDENTIFICATION: NEW DATASTRUCTURE THAT KEEPS REQ AND REPL AND ALL IMPORTANT INFOS (ADDR, ID, PORT). #######
|
|
|
+###### CREATE WHEN DETERMINING INITIATOR AND RESPONDER AND UPDATE LATER WITH ADDRESSES ... ########
|
|
|
+
|
|
|
class MembersMgmtCommAttack(BaseAttack.BaseAttack):
|
|
|
def __init__(self):
|
|
|
"""
|
|
@@ -113,13 +117,13 @@ class MembersMgmtCommAttack(BaseAttack.BaseAttack):
|
|
|
ids = ids_to_add.copy()
|
|
|
macgen = MacAddressGenerator()
|
|
|
for ip in existing_ips:
|
|
|
- random_id = choice(tuple(ids))
|
|
|
+ random_id = choice(ids)
|
|
|
mac = self.statistics.process_db_query("macAddress(IPAddress=%s)" % ip)
|
|
|
bot_configs[random_id] = {"Type": idtype, "IP": ip, "MAC": mac}
|
|
|
ids.remove(random_id)
|
|
|
|
|
|
for ip in new_ips:
|
|
|
- random_id = choice(tuple(ids))
|
|
|
+ random_id = choice(ids)
|
|
|
if idtype == "local":
|
|
|
mac = macgen.random_mac()
|
|
|
elif idtype == "external":
|
|
@@ -187,7 +191,9 @@ class MembersMgmtCommAttack(BaseAttack.BaseAttack):
|
|
|
bot_configs = {}
|
|
|
external_ids = set()
|
|
|
local_ids = set()
|
|
|
+ id_comms = sorted(id_comms)
|
|
|
# print(self.get_param_value(Param.INJECT_AT_TIMESTAMP))
|
|
|
+
|
|
|
if comm_type == "local":
|
|
|
local_ids = set(mapped_ids.keys())
|
|
|
else:
|
|
@@ -197,7 +203,7 @@ class MembersMgmtCommAttack(BaseAttack.BaseAttack):
|
|
|
init_ids, respnd_ids, both_ids = determine_id_roles(abstract_packets[packet_start_idx:packet_end_idx+1], ids)
|
|
|
|
|
|
# assign IDs in 'both' local everytime for mixed?
|
|
|
- initiators = list(init_ids) + list(both_ids)
|
|
|
+ initiators = sorted(list(init_ids) + list(both_ids))
|
|
|
for id_ in initiators:
|
|
|
if id_ in local_ids or id_ in external_ids:
|
|
|
continue
|
|
@@ -236,25 +242,25 @@ class MembersMgmtCommAttack(BaseAttack.BaseAttack):
|
|
|
local_ids.add(other)
|
|
|
|
|
|
|
|
|
- # print(initiators)
|
|
|
- # print(local_ids)
|
|
|
- # print(external_ids)
|
|
|
+ # print(sorted(initiators))
|
|
|
+ # print(sorted(local_ids))
|
|
|
+ # print(sorted(external_ids))
|
|
|
|
|
|
+ # IDs are always added to bot_configs in the same order under a given seed
|
|
|
number_local_ids, number_external_ids = len(local_ids), len(external_ids)
|
|
|
if number_local_ids > 0:
|
|
|
reuse_count_local = int(reuse_percent_total * reuse_percent_local * number_local_ids)
|
|
|
- existing_local_ips = pcapops.get_existing_priv_ips(reuse_count_local)
|
|
|
- new_local_ips = pcapops.get_new_priv_ips(number_local_ids - len(existing_local_ips))
|
|
|
- add_ids_to_config(local_ids, existing_local_ips, new_local_ips, bot_configs)
|
|
|
+ existing_local_ips = sorted(pcapops.get_existing_priv_ips(reuse_count_local))
|
|
|
+ new_local_ips = sorted(pcapops.get_new_priv_ips(number_local_ids - len(existing_local_ips)))
|
|
|
+ add_ids_to_config(sorted(local_ids), existing_local_ips, new_local_ips, bot_configs)
|
|
|
|
|
|
if number_external_ids > 0:
|
|
|
reuse_count_external = int(reuse_percent_total * reuse_percent_external * number_external_ids)
|
|
|
- existing_external_ips = pcapops.get_existing_external_ips(reuse_count_external)
|
|
|
+ existing_external_ips = sorted(pcapops.get_existing_external_ips(reuse_count_external))
|
|
|
remaining = len(external_ids) - len(existing_external_ips)
|
|
|
- new_external_ips = [ipgen.random_ip() for _ in range(remaining)]
|
|
|
- add_ids_to_config(external_ids, existing_external_ips, new_external_ips, bot_configs, idtype="external", router_mac=router_mac)
|
|
|
+ new_external_ips = sorted([ipgen.random_ip() for _ in range(remaining)])
|
|
|
+ add_ids_to_config(sorted(external_ids), existing_external_ips, new_external_ips, bot_configs, idtype="external", router_mac=router_mac)
|
|
|
|
|
|
- # print(bot_configs)
|
|
|
|
|
|
# create bot port configs
|
|
|
for bot in bot_configs:
|