Ver código fonte

Make linenumbers start from 1 (not 0)

Previously, for the CSV to PCAP mapping, linenumbers started at 0.
Now linenumbers start at 1.
dustin.born 7 anos atrás
pai
commit
0e777e28bb

+ 3 - 3
code/Attack/MembersMgmtCommAttack.py

@@ -46,7 +46,7 @@ class Message():
         :param type_: the type of the message
         :param time: the timestamp of the message
         :param refer_msg_id: the ID this message is a request for or reply to. -1 if there is no related message.
-        :param line_no: The line number this message appeared in the original file
+        :param line_no: The line number this message appeared at in the original CSV file
         """
         self.msg_id = msg_id
         self.src = src
@@ -54,11 +54,10 @@ class Message():
         self.type = type_
         self.time = time
         self.refer_msg_id = refer_msg_id
-        # if similar fields to line_no should be added consider a separate class
         self.line_no = line_no
 
     def __str__(self):
-        str_ = "{0}. at {1}: {2}-->{3}, {4}, refer:{5}".format(self.msg_id, self.time, self.src, self.dst, self.type, self.refer_msg_id)
+        str_ = "{0}. at {1}: {2}-->{3}, {4}, refer:{5} (line {6})".format(self.msg_id, self.time, self.src, self.dst, self.type, self.refer_msg_id, self.line_no)
         return str_
 
 
@@ -197,6 +196,7 @@ class MembersMgmtCommAttack(BaseAttack.BaseAttack):
 
         # create packets to write to PCAP file
         for msg in messages:
+            print(msg)
             # retrieve the source and destination configurations
             id_src, id_dst = msg.src["ID"], msg.dst["ID"]
             ip_src, ip_dst = msg.src["IP"], msg.dst["IP"]

+ 1 - 1
code_boost/src/cxx/botnet_comm_processor.cpp

@@ -85,7 +85,7 @@ void botnet_comm_processor::process_kv(abstract_msg &msg, const std::string &key
  */
 unsigned int botnet_comm_processor::parse_csv(const std::string &filepath){
     std::ifstream input(filepath);
-    int line_no = 0;
+    int line_no = 1;  // the first line has number 1
 
     messages.clear();
     // iterate over every line