Adding the export of PDF report
This commit is contained in:
@ -44,13 +44,13 @@ class Analysis(object):
|
||||
device, alerts = {}, {}
|
||||
|
||||
# Getting device configuration.
|
||||
if os.path.isfile("/tmp/{}/device.json".format(self.token)):
|
||||
with open("/tmp/{}/device.json".format(self.token), "r") as f:
|
||||
if os.path.isfile("/tmp/{}/assets/device.json".format(self.token)):
|
||||
with open("/tmp/{}/assets/device.json".format(self.token), "r") as f:
|
||||
device = json.load(f)
|
||||
|
||||
# Getting alerts configuration.
|
||||
if os.path.isfile("/tmp/{}/alerts.json".format(self.token)):
|
||||
with open("/tmp/{}/alerts.json".format(self.token), "r") as f:
|
||||
if os.path.isfile("/tmp/{}/assets/alerts.json".format(self.token)):
|
||||
with open("/tmp/{}/assets/alerts.json".format(self.token), "r") as f:
|
||||
alerts = json.load(f)
|
||||
|
||||
if device != {} and alerts != {}:
|
||||
|
@ -15,7 +15,8 @@ import re
|
||||
class Capture(object):
|
||||
|
||||
def __init__(self):
|
||||
self.working_dir = False
|
||||
self.capture_dir = False
|
||||
self.assets_dir = False
|
||||
self.capture_token = False
|
||||
self.random_choice_alphabet = "ABCDEF1234567890"
|
||||
|
||||
@ -33,16 +34,18 @@ class Capture(object):
|
||||
# Few context variable assignment
|
||||
self.capture_token = "".join(
|
||||
[random.choice(self.random_choice_alphabet) for i in range(8)])
|
||||
self.working_dir = "/tmp/{}/".format(self.capture_token)
|
||||
self.pcap = self.working_dir + "capture.pcap"
|
||||
self.capture_dir = "/tmp/{}/".format(self.capture_token)
|
||||
self.assets_dir = "/tmp/{}/assets/".format(self.capture_token)
|
||||
self.pcap = self.capture_dir + "capture.pcap"
|
||||
self.iface = read_config(("network", "in"))
|
||||
|
||||
# For packets monitoring
|
||||
self.list_pkts = []
|
||||
self.last_pkts = 0
|
||||
|
||||
# Make the capture directory
|
||||
mkdir(self.working_dir)
|
||||
# Make the capture and the assets directory
|
||||
mkdir(self.capture_dir)
|
||||
mkdir(self.assets_dir)
|
||||
|
||||
try:
|
||||
sp.Popen(["tshark", "-i", self.iface, "-w",
|
||||
|
@ -20,13 +20,13 @@ class Device(object):
|
||||
|
||||
:return: dict containing device properties.
|
||||
"""
|
||||
if not os.path.isfile("/tmp/{}/device.json".format(self.token)):
|
||||
if not os.path.isfile("/tmp/{}/assets/device.json".format(self.token)):
|
||||
device = self.read_leases()
|
||||
if device["status"] != False:
|
||||
with open("/tmp/{}/device.json".format(self.token), "w") as f:
|
||||
with open("/tmp/{}/assets/device.json".format(self.token), "w") as f:
|
||||
f.write(json.dumps(device))
|
||||
else:
|
||||
with open("/tmp/{}/device.json".format(self.token)) as f:
|
||||
with open("/tmp/{}/assets/device.json".format(self.token)) as f:
|
||||
device = json.load(f)
|
||||
return device
|
||||
|
||||
|
Reference in New Issue
Block a user