Przeglądaj źródła

Make messages a list again.
Fix payload bug in PcapComparator.

dustin.born 6 lat temu
rodzic
commit
a8a7e41617

+ 1 - 1
code/Attack/MembersMgmtCommAttack.py

@@ -381,7 +381,7 @@ class MembersMgmtCommAttack(BaseAttack.BaseAttack):
         # configurations (i.e. IP, MAC, port, ...) for easier later use
         final_messages = []
         new_id = 0
-        for msg in sorted(messages.values(), key=lambda msg: msg.msg_id):
+        for msg in messages:
             type_src, type_dst = bot_configs[msg.src]["Type"], bot_configs[msg.dst]["Type"]
             id_src, id_dst = msg.src, msg.dst
 

+ 4 - 4
code/ID2TLib/CommunicationProcessor.py

@@ -169,7 +169,7 @@ class CommunicationProcessor():
         # setup initial variables and their values
         respnd_ids = set()
         # msgs --> the filtered messages, msg_id --> an increasing ID to give every message an artificial primary key
-        msgs, msg_id = {}, 0
+        msgs, msg_id = [], 0
         # keep track of previous request to find connections
         prev_reqs = {}
         init_ids = self.init_ids
@@ -193,7 +193,7 @@ class CommunicationProcessor():
                 # convert the abstract message into a message object to handle it better
                 msg_str = "{0}-{1}".format(id_src, id_dst)
                 msg = Message(msg_id, id_src, id_dst, msg_type, time)
-                msgs[msg_id] = msg
+                msgs.append(msg)
                 prev_reqs[msg_str] = msg_id
 
             # process a reply
@@ -209,7 +209,7 @@ class CommunicationProcessor():
                 msgs[refer_idx].refer_msg_id = msg_id
                 # print(msgs[refer_idx])
                 msg = Message(msg_id, id_src, id_dst, msg_type, time, refer_idx)
-                msgs[msg_id] = msg
+                msgs.append(msg)
                 # remove the request to this response from storage
                 del(prev_reqs[msg_str])
 
@@ -222,7 +222,7 @@ class CommunicationProcessor():
         self.messages = msgs
 
         # return the retrieved information
-        return self.init_ids, self.respnd_ids, msgs
+        return self.init_ids, self.respnd_ids, self.messages
 
 
     def det_ext_and_local_ids(self, prob_rspnd_local: int):

+ 8 - 2
test/PcapComparator.py

@@ -200,10 +200,16 @@ def check_payload_diff(idx, payload_one, payload_two):
     if payload_one != payload_two:
         err_msg = "Reason: the packets at index %d have different payloads.\n" % (idx+1)
         err_msg += "Packet 1:\n===================\n"
-        err_msg += paload_one.show()
+        if payload_one.load is not None:
+            err_msg += str(payload_one.load)
+        else:
+            err_msg += "None"
         err_msg += "\n\n"
         err_msg += "Packet 2:\n===================\n"
-        err_msg += paload_two.show()
+        if payload_two.load is not None:
+            err_msg += str(payload_two.load)
+        else:
+            err_msg += "None"
         return True, err_msg
     else:
         return False, ""