示例#1
0
    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'
示例#2
0
    def pcap_analyse(self):
        if not os.access(self.destination_report.get(), os.W_OK):
            mb.showerror(
                "Error",
                "Permission denied to create report! Run with higher privilege."
            )
            return

        if os.path.exists(self.pcap_file.get()):
            self.progressbar.start()
            result = q.Queue()
            packet_read = threading.Thread(target=pcap_reader.PcapEngine,
                                           args=(self.pcap_file.get(),
                                                 "scapy"))
            packet_read.start()
            while packet_read.is_alive():
                self.progressbar.update()
            packet_read.join()
            self.progressbar.stop()
            #packet_read.join()
            #self.capture_read = result.get()
            reportThreadpcap = threading.Thread(
                target=report_generator.reportGen(
                    self.destination_report.get(),
                    self.filename).packetDetails,
                args=())
            reportThreadpcap.start()
            #self.option.set("Tor")
            self.option.trace("w", self.map_select)
            #self.option.set("Tor")
            self.name_servers = ""
        else:
            mb.showerror("Error", "File Not Found !")
示例#3
0
    def generate_graph(self):
        if self.name_servers == "":
            result = q.Queue()
            t = threading.Thread(
                target=communication_details_fetch.trafficDetailsFetch,
                args=("sock", ))
            t.start()
            self.progressbar.start()
            while t.is_alive():
                self.progressbar.update()
            t.join()
            self.progressbar.stop()
            #self.name_servers = result.get()
            reportThread = threading.Thread(target=report_generator.reportGen(
                self.destination_report.get(),
                self.filename).communicationDetailsReport,
                                            args=())
            reportThread.start()

        self.image_file = os.path.join(
            self.destination_report.get(), "Report",
            self.filename + "_" + self.option.get() + ".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(),
                                  ))
            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()
        reportThread = threading.Thread(target=report_generator.reportGen(
            self.destination_report.get(), self.filename).deviceDetailsReport,
                                        args=())
        reportThread.start()
示例#4
0
def test_report_gen():
    directory = sys.path[0] 
    filename = "test"
    pcap_reader.PcapEngine(directory + 'examples/' + filename + ".pcap", "scapy")
    if memory.packet_db:
        report_generator.reportGen(sys.path[0], filename).packetDetails()
        report_generator.reportGen(sys.path[0], filename).communicationDetailsReport()
        report_generator.reportGen(sys.path[0], filename).deviceDetailsReport()
        if os.path.isfile(sys.path[0]+"/Report/testcommunicationDetailsReport.txt") and os.path.isfile(sys.path[0]+"/Report/testdeviceDetailsReport.txt") and os.path.isfile(sys.path[0]+"/Report/testpacketDetailsReport.txt"):
            assert True
示例#5
0
    def pcap_analyse(self):
        if not os.access(self.destination_report.get(), os.W_OK):
            mb.showerror("Error","Permission denied to create report! Run with higher privilege.")
            return

        if os.path.exists(self.pcap_file.get()):
            
            # Disable controls when performing analysis
            self.trigger['state'] = 'disabled'
            self.ibutton['state'] = 'disabled'
            self.to_menu['state'] = 'disabled'
            self.from_menu['state'] = 'disabled'

            self.progressbar.start()

            # PcapRead - First of All!
            #result = q.Queue()
            packet_read = threading.Thread(target=pcap_reader.PcapEngine,args=(self.pcap_file.get(), self.engine.get()))
            packet_read.start()
            while packet_read.is_alive():
                self.progressbar.update()
            packet_read.join()
            self.progressbar.stop()

            # Report Generation of the PcapData
            
            
            #packet_read.join()
            #self.capture_read = result.get()
            reportThreadpcap = threading.Thread(target=report_generator.reportGen(self.destination_report.get(), self.filename).packetDetails,args=())
            reportThreadpcap.start()
            #self.option.set("Tor")
            #self.option.trace("w",self.map_select)
            #self.option.set("Tor")
            
            # Reset
            self.details_fetch = 0
            self.to_hosts = ["All"]
            self.from_hosts = ["All"]


            # Default filter values
            self.to_menu['values'] = self.to_hosts
            self.from_menu['values'] = self.from_hosts
            self.from_menu.set("All")
            self.to_menu.set("All")
            self.option.set("All")
            
            """
            # Filters update 
            # Reset Option Menu with the values fetched from the pcap
            menu1 = self.to_menu["menu"]
            menu1.delete(0, "end")
            for ip in memory.destination_hosts:
                menu1.add_command(label=ip, command=lambda value=ip: self.to_ip.set(value))
            menu1.add_command(label="All", command=lambda value="All": self.to_ip.set(value))
            menu = self.from_menu["menu"]
            menu.delete(0, "end")
            for mac in memory.lan_hosts:
                menu.add_command(label=memory.lan_hosts[mac]["ip"], command=lambda value=memory.lan_hosts[mac]["ip"]: self.from_ip.set(value))
                menu1.add_command(label=memory.lan_hosts[mac]["ip"], command=lambda value=memory.lan_hosts[mac]["ip"]: self.to_ip.set(value))
            menu.add_command(label="All", command=lambda value="All": self.from_ip.set(value))
            """
            self.progressbar.start()
            self.to_hosts += list(memory.destination_hosts.keys())
            for mac in list(memory.lan_hosts.keys()):
                self.progressbar.update()
                self.from_hosts.append(memory.lan_hosts[mac]["ip"])
            self.to_hosts = list(set(self.to_hosts + self.from_hosts))
            self.to_menu['values'] = self.to_hosts
            self.from_menu['values'] = self.from_hosts
            self.progressbar.stop()

            # Enable controls
            self.trigger['state'] = 'normal'
            self.to_menu['state'] = 'normal'
            self.from_menu['state'] = 'normal'
        else:
            mb.showerror("Error","File Not Found !")