forked from bennr01/load_balancer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathids.py
30 lines (27 loc) · 1.1 KB
/
ids.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from Kitsune import Kitsune
import numpy as np
import time
class IntrusionDetector(object):
def __init__(self):
path = "../pcap2/packets.pcap" #the pcap, pcapng, or tsv file to process.
packet_limit = 5000 #the number of packets to process
# KitNET params:
maxAE = 10 #maximum size for any autoencoder in the ensemble layer
FMgrace = 5000 #the number of instances taken to learn the feature mapping (the ensemble's architecture)
ADgrace = 40000 #the number of instances used to train the anomaly detector (ensemble itself)
# Build Kitsune
self.kitsune = Kitsune(path,packet_limit,maxAE,FMgrace,ADgrace)
self.RMSE = []
i = 0
while True:
i+=1
if i % 1000 == 0:
print(i)
rmse = self.kitsune.proc_next_packet()
if rmse == -1:
break
self.RMSE.append(rmse)
def packet_rmse(self, packet):
return self.kitsune.process_packet(packet)
if __name__ == '__main__':
intrusion_detector = IntrusionDetector()