Просмотр исходного кода

Add way to create files with same base name as output PCAP

Add the possibilty for attacks to create files that will later
have the same base name as the output PCAP.
dustin.born 6 лет назад
Родитель
Сommit
284eef43a9
2 измененных файлов с 16 добавлено и 1 удалено
  1. 15 1
      code/Core/Controller.py
  2. 1 0
      code/ID2TLib/Utility.py

+ 15 - 1
code/Core/Controller.py

@@ -108,6 +108,17 @@ class Controller:
 
         os.rename(self.pcap_dest_path, result_path)
         self.pcap_dest_path = result_path
+        created_files = [self.pcap_dest_path]
+
+        # process/move other created files
+        pcap_root = os.path.splitext(self.pcap_dest_path)[0]
+        for k, v in Util.MISC_OUT_FILES:
+            if v is None:
+                created_files.append(k)
+            else:
+                outpath = pcap_root + "_" + k
+                os.rename(v, outpath)
+                created_files.append(outpath)
 
         print("done.")
 
@@ -119,9 +130,12 @@ class Controller:
 
         # write label file with attacks
         self.label_manager.write_label_file(self.pcap_dest_path)
+        created_files.insert(1, self.label_manager.label_file_path)
 
         # print status message
-        print('\nOutput files created: \n', self.pcap_dest_path, '\n', self.label_manager.label_file_path)
+        print('\nOutput files created:')
+        for filepath in created_files:
+            print(filepath)
 
         # print summary statistics
         if not self.non_verbose:

+ 1 - 0
code/ID2TLib/Utility.py

@@ -18,6 +18,7 @@ ROOT_DIR = CODE_DIR + "../"
 RESOURCE_DIR = ROOT_DIR + "resources/"
 TEST_DIR = RESOURCE_DIR + "test/"
 OUT_DIR = None
+MISC_OUT_FILES = {}
 
 platforms = {"win7", "win10", "winxp", "win8.1", "macos", "linux", "win8", "winvista", "winnt", "win2000"}
 platform_probability = {"win7": 48.43, "win10": 27.99, "winxp": 6.07, "win8.1": 6.07, "macos": 5.94, "linux": 3.38,