forked from muhky/scryer
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrecord.py
39 lines (33 loc) · 1016 Bytes
/
record.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
31
32
33
34
35
36
37
38
39
import time
from datetime import datetime
def get_packet_layers(packet):
counter = 0
while True:
layer = packet.getlayer(counter)
if layer is None:
break
yield layer.name
counter += 1
class IDSRecord:
_type: str = ""
_src_ip: str = ""
_dst_ip: str = ""
_description: str = ""
_layers: str = ""
_time: float = 0.0
def __init__(self, packet, type, src_ip, dst_ip = "", description = ""):
self._type = type
self._src_ip = src_ip
self._dst_ip = dst_ip
self._description = description
self._layers = [l for l in get_packet_layers(packet)]
self._time = time.time()
def get_dict(self):
return {
'type': self._type,
'src_ip': self._src_ip,
'dst_ip': self._dst_ip,
'layers': self._layers,
'description': self._description,
'time': datetime.fromtimestamp(self._time).strftime("%m/%d/%Y, %H:%M:%S")
}