def __init__(self, filename, path, option="Tor"): self.directory = os.path.join(path, "Report") if not os.path.exists(self.directory): os.makedirs(self.directory) self.filename = os.path.join(self.directory, filename+"_"+option) self.styles = { 'graph': { 'label': 'PcapGraph', 'fontsize': '16', 'fontcolor': 'black', 'bgcolor': 'grey', 'rankdir': 'BT', 'dpi':'600' }, 'nodes': { 'fontname': 'Helvetica', 'shape': 'circle', 'fontcolor': 'black', 'color': ' black', 'style': 'filled', 'fillcolor': 'yellow', } } self.sessions = memory.packet_db.keys() device_details_fetch.fetchDeviceDetails("ieee").fetch_info() if option == "Malicious" or option == "All": self.mal_identify = malicious_traffic_identifier.maliciousTrafficIdentifier() if option == "Tor" or option == "All": self.tor_identify = tor_traffic_handle.torTrafficHandle().tor_traffic_detection() self.draw_graph(option)
def generate_graph(self): if self.details_fetch == 0: # Threads to fetch communication and device details #result = q.Queue() t = threading.Thread( target=communication_details_fetch.trafficDetailsFetch, args=("sock", )) t1 = threading.Thread( target=device_details_fetch.fetchDeviceDetails( "ieee").fetch_info, args=()) t.start() t1.start() self.progressbar.start() while t.is_alive(): self.progressbar.update() t.join() t1.join() # Report Generation Control and Filters update (Here?) self.details_fetch = 1 # Report Creation Threads reportThread = threading.Thread(target=report_generator.reportGen( self.destination_report.get(), self.filename).communicationDetailsReport, args=()) reportThread.start() reportThread = threading.Thread(target=report_generator.reportGen( self.destination_report.get(), self.filename).deviceDetailsReport, args=()) reportThread.start() self.progressbar.stop() # Loding the generated map options = self.option.get() + "_" + self.to_ip.get().replace( ".", "-") + "_" + self.from_ip.get().replace(".", "-") self.image_file = os.path.join(self.destination_report.get(), "Report", self.filename + "_" + options + ".png") if not os.path.exists(self.image_file): t1 = threading.Thread(target=plot_lan_network.plotLan, args=(self.filename, self.destination_report.get(), self.option.get(), self.to_ip.get(), self.from_ip.get())) t1.start() self.progressbar.start() while t1.is_alive(): self.progressbar.update() t1.join() self.progressbar.stop() self.label.grid_forget() self.load_image() else: self.label.grid_forget() self.load_image() self.ibutton['state'] = 'normal'
def test_device_details_fetch(): pcap_reader.PcapEngine(sys.path[0]+'examples/test.pcap', "scapy") device_details_fetch.fetchDeviceDetails("ieee").fetch_info() if memory.lan_hosts: assert True