Browse Source

Adds merger.py and modifications on ID2T classes

Patrick Jattke 7 years ago
parent
commit
c03e35c5b3
4 changed files with 37 additions and 7 deletions
  1. 4 4
      code/CLI.py
  2. 2 1
      code/ID2TLib/AttackController.py
  3. 28 0
      code/merger.py
  4. 3 2
      code/profile-process.py

+ 4 - 4
code/CLI.py

@@ -115,14 +115,14 @@ if __name__ == '__main__':
     #             '/root/datasets/201506021400_2G.pcap',
     #             '/root/datasets/201506021400_5G.pcap']
 
-    FILES = ['/mnt/hgfs/datasets/201506021400_2G.pcap']
+    FILES = ['/root/datasets/201506021400_1G.pcap']
 
-    #    FILES = ['/mnt/hgfs/datasets/95M.pcap']
+#    FILES = ['/mnt/hgfs/datasets/95M.pcap']
 
     ATTACK_PS = ['-a', 'PortscanAttack', 'ip.src=10.2.2.4', 'mac.dst=05:AB:47:B5:19:11',
                  'inject.at-timestamp=1449038705.316721', 'attack.note=Portscan2']
     ATTACK_PS2 = ['-a', 'PortscanAttack', 'port.dst=1-1024']
-    ATTACK_DD = ['-a', 'DDoSAttack', 'attackers.count=10', 'packets.limit=1000']
+    ATTACK_DD = ['-a', 'DDoSAttack', 'attackers.count=10', 'packets.limit=500000']
 
     STATS_RECALC = ['-r']
     STATS_PRINT = ['-s']
@@ -132,5 +132,5 @@ if __name__ == '__main__':
     QUERY_DB = ['-q', 'ipAddress(pktsSent > 1000, kbytesSent >= 20)']
 
     for f in FILES:
-        main(INPUT + [f] + ATTACK_PS2 + ATTACK_DD)  # Statistics Calculation
+        main(INPUT + [f] + ATTACK_DD)  # Statistics Calculation
         #main(INPUT + ATTACK_DD)  # Attack Packet Generation -> insert exit() | Merging

+ 2 - 1
code/ID2TLib/AttackController.py

@@ -92,7 +92,8 @@ class AttackController:
         # f.write(str(time_e - time_s) + "\n")
         # f.close()
         # print("Finished............")
-        # exit(0)
+        print("Temporary attack pcap located at: " + temp_attack_pcap_path)
+        exit(0)
         print("done. (total: " + str(total_packets) + " pkts.)")
 
         # Merge attack with existing pcap

+ 28 - 0
code/merger.py

@@ -0,0 +1,28 @@
+#! /usr/bin/env python3
+
+import hashlib
+import os.path
+import sys
+
+import ID2TLib.libpcapreader as pr
+import time
+
+def merge():
+    #base = ['/root/datasets/201506021400_2G.pcap', '/root/datasets/201506021400_5G.pcap', '/root/datasets/201506021400.pcap']
+    base = ['/root/datasets/201506021400.pcap']
+    attack = ['/root/attack_pcaps/portscan_ddos_attack.pcap']
+    #attack = ['/root/attack_pcaps/portscan_attack.pcap', '/root/attack_pcaps/ddos_attack.pcap']
+    
+    for b in base:
+        print("processing ", b)
+        pcap = pr.pcap_processor(b)
+        start = time.time()
+        for a in attack:
+            print("injecting attack: " + a + " at " + str(time.time()))
+            dest_path = pcap.merge_pcaps(a)
+        end = time.time()
+        f = open('/root/perfresults/runtime_mergeop.txt', 'a')
+        f.write(b + ':  ' + str(end-start) + '\n')
+        f.close()
+
+merge()

+ 3 - 2
code/profile-process.py

@@ -18,7 +18,7 @@ def log_performance():
             return n
 
     # Interval for data collection (in seconds)
-    probe_interval = 0.1
+    probe_interval = 1
 
     i = 0
     x = []
@@ -35,7 +35,8 @@ def log_performance():
     stats_io_r_b = []
     stats_io_w_b = []
 
-    proc = subprocess.Popen("./CLI.py")
+#    proc = subprocess.Popen("./CLI.py")
+    proc = subprocess.Popen(sys.argv[1:])
     p = psutil.Process(proc.pid)
     start_time = time.time()
     while proc is None or proc.poll() is None: