Ejemplo n.º 1
0
    def checkIfFieldsAreValid(self, input, output):
        database = bend.CookieDatabase()

        # IF input is NOT None (-> if the user entered something):
        if (input == "") == False:
            self.existing = database.checkExistance('transformed', input)       # Is the requested CSV-DataBase (transformed from SQlite) available ?
            self.save_taken = database.checkExistance('report', output)         # Is the wished csv-name (for the report) already TAKEN (by another file) ?

            # IF SQlite DB exists and the csv-name is available (free / not taken)
            if self.existing and self.save_taken == False:
                return True
            elif self.save_taken == True:
                self.label_message.configure(text="[X] CSV already existing!", fg='red')
                self.CONTROLLER.update()
                print("[X] ERROR! CSV already existing!!\n")
                self.CONTROLLER.after(1500, self.label_message.configure(text="", fg='black'))
            elif self.existing == False:
                self.label_message.configure(text="[X] PATH not found!", fg='red')
                self.CONTROLLER.update()
                print("[X] ERROR! PATH not found!\n")
                self.CONTROLLER.after(1500, self.label_message.configure(text="", fg='black'))
        # ELSE if the user has not entered anything:
        else:
            self.label_message.configure(text="[X] Enter CSV name first!", fg='red')
            self.CONTROLLER.update()            # CONTROLLER is the key to THREADING!
            print("[X] Enter CSV name first!\n")
            self.CONTROLLER.after(1500, self.label_message.configure(text="", fg='black'))

        return False
Ejemplo n.º 2
0
    def searchDatabase(self, event=None):
        self.search_term = self.entry_name.get()
        self.database = bend.CookieDatabase()
        print("[>] Searching for file '..._count_%s.csv'..." %
              self.search_term)
        self.host_existing = self.database.checkExistance(
            "report", "host/host_count_" + self.search_term)
        self.suffix_existing = self.database.checkExistance(
            "report", "suffix/suffix_count_" + self.search_term)
        self.cook1st_existing = self.database.checkExistance(
            "report", "cook1st/cook1st_count_" + self.search_term)
        self.cook3rd_existing = self.database.checkExistance(
            "report", "cook3rd/cook3rd_count_" + self.search_term)
        self.tracker_existing = self.database.checkExistance(
            "report", "tracker/tracker_count_" + self.search_term)
        self.unique_existing = self.database.checkExistance(
            "report", "unique/unique_info_" + self.search_term)

        # if self.host_existing and self.suffix_existing and self.cook1st_existing and self.cook3rd_existing and self.tracker_existing and self.unique_existing:
        if self.host_existing:
            self.label_name.configure(text="[*] File exists!", fg='green')
            self.CONTROLLER.update()  # CONTROLLER is the key to THREADING!
            print("[*] File exists!\n")
            self.CONTROLLER.after(
                1500, self.label_name.configure(text="Report Name:",
                                                fg='black'))
        else:
            self.label_name.configure(text="[X] File not found!", fg='red')
            self.CONTROLLER.update()
            print("[X] ERROR! File not found!\n")
            self.CONTROLLER.after(
                1500, self.label_name.configure(text="Report Name:",
                                                fg='black'))
Ejemplo n.º 3
0
 def saveUniqueInfoAsCSV(self, host, cook1st, cook3rd, tracker, suffix, name):
     backend = bend.CookieDatabase()
     info_list = [host, cook1st, cook3rd, tracker, suffix]
     info_columns = ["HOSTS", "COOKIES 1st", "COOKIES 3rd", "TRACKER", "SUFFIXES"]
     self.unique_info = pd.DataFrame(columns=info_columns, index=None)
     self.unique_info.loc[0] = info_list
     self.unique_info.to_csv(backend.REPORT_SAVE + "unique/unique_info_%s.csv" % name, header=info_columns, sep=',', index=False, mode='w+')
     print("\n[+] WROTE new UNIQUE-INFO_CSV to unique_info_%s.csv\n" % (name))
     print(self.unique_info)
Ejemplo n.º 4
0
 def saveInfoAsCSV(self, amount, cook1st, cook3rd, tracker, name):
     backend = bend.CookieDatabase()
     info_list = [amount, cook1st, cook3rd, tracker]
     info_columns = ["TOTAL", "COOKIES 1st", "COOKIES 3rd", "TRACKER"]
     self.unique_info = pd.DataFrame(columns=info_columns, index=None)
     self.unique_info.loc[0] = info_list
     self.unique_info.to_csv(backend.REPORT_SAVE + "total/total_info_%s.csv" % name, header=info_columns, sep=',', index=False, mode='w+')
     print("\n[+] WROTE new UNIQUE-INFO_CSV to total_info_%s.csv\n" % (name))
     print(self.unique_info)
Ejemplo n.º 5
0
 def processData(self, search_term, csv_name):
     self.database = bend.CookieDatabase()
     self.data = self.database.transformToDataFrame(search_term)
     try:
         #self.data.to_csv(self.PATH_CSV + "%s.csv" % csv_name, sep=',', index=False, mode='w+')
         self.data.to_csv(self.database.TRANSFORM_PATH +
                          "%s.csv" % csv_name,
                          sep=';',
                          index=False,
                          mode='w+')
         print("[*] Saving SUCCESSFULL!")
     except Exception:
         print("ERROR while saving file!")
Ejemplo n.º 6
0
    def startReportCreation(self, event=None):
        self.database = bend.CookieDatabase()
        self.input_name = self.entry_fast.get()
        self.output_name = self.entry_name.get()

        self.fields_valid = self.checkIfFieldsAreValid(self.input_name, self.output_name)

        if self.fields_valid:
            self.label_message.configure(text="[*] Saving report...", fg='green')
            self.CONTROLLER.update()            # CONTROLLER is the key to THREADING!
            print("[*] Saving report...\n")
            ## HERE GOES the SAVING / TRANSFORMING ? -> new method!
            self.createReport(self.input_name, self.output_name)
            self.CONTROLLER.after(200, self.label_message.configure(text="[*] Saving SUCCESSFULL!", fg='green'))
            self.CONTROLLER.update()            # CONTROLLER is the key to THREADING!
            self.CONTROLLER.after(1500, self.label_message.configure(text="", fg='black'))
Ejemplo n.º 7
0
    def generalInfo(self):
        self.database = bend.CookieDatabase()

        # Checks if windows are still open
        if self.DATA_LOADED == False:
            info_win = self.createNewWindow(725, "Info", 420, 320)
            self.textField = tk.Text(info_win)
            self.textField.configure(highlightbackground=self.color)
            self.textField.pack()
            self.DATA_LOADED = True
            self.textField.insert(tk.INSERT, self.database.getInfo())
        else:
            info_win = self.createNewWindow(725, "Info", 420, 320)
            self.textField = tk.Text(info_win)
            self.textField.configure(highlightbackground=self.color)
            self.textField.pack()
            #self.DATA_LOADED = False
            self.textField.insert(tk.INSERT, self.database.getInfo())
Ejemplo n.º 8
0
    def saveData(self, event=None):
        self.database = bend.CookieDatabase()
        self.search_term = self.entry_sqlite.get()
        self.csv_name = self.entry_csv.get()

        if (self.csv_name == "") == False:
            self.existing = self.database.checkExistance(
                "sqlite", self.search_term)
            self.csv_existing = self.database.checkExistance(
                "transformed", self.csv_name)

            if self.existing and self.csv_existing == False:
                self.label_status.configure(text="[*] Saving file...",
                                            fg='green')
                self.CONTROLLER.update()  # CONTROLLER is the key to THREADING!
                print("[*] Saving file...\n")
                self.processData(self.search_term, self.csv_name)
                self.CONTROLLER.after(
                    200,
                    self.label_status.configure(text="[*] Saving SUCCESSFULL!",
                                                fg='green'))
                self.CONTROLLER.update()  # CONTROLLER is the key to THREADING!
                self.CONTROLLER.after(
                    1500, self.label_status.configure(text="", fg='black'))
            elif self.csv_existing == True:
                self.label_status.configure(text="[X] CSV already existing!",
                                            fg='red')
                self.CONTROLLER.update()
                print("[X] ERROR! CSV already existing!!\n")
                self.CONTROLLER.after(
                    1500, self.label_status.configure(text="", fg='black'))
            else:
                self.label_status.configure(text="[X] File not found!",
                                            fg='red')
                self.CONTROLLER.update()
                print("[X] ERROR! File not found!\n")
                self.CONTROLLER.after(
                    1500, self.label_status.configure(text="", fg='black'))
        else:
            self.label_status.configure(text="[X] Enter CSV name first!",
                                        fg='red')
            self.CONTROLLER.update()  # CONTROLLER is the key to THREADING!
            self.CONTROLLER.after(
                1500, self.label_status.configure(text="", fg='black'))
Ejemplo n.º 9
0
    def searchDatabase(self, event=None):
        self.search_term = self.entry_sqlite.get()
        self.database = bend.CookieDatabase()
        print("[>] Searching for file '%s.sqlite'..." % self.search_term)
        self.existing = self.database.checkExistance("sqlite",
                                                     self.search_term)

        if self.existing:
            self.label_status.configure(text="[*] File exists!", fg='green')
            self.CONTROLLER.update()  # CONTROLLER is the key to THREADING!
            print("[*] File exists!\n")
            self.CONTROLLER.after(
                1500, self.label_status.configure(text="", fg='black'))
        else:
            self.label_status.configure(text="[X] File not found!", fg='red')
            self.CONTROLLER.update()
            print("[X] ERROR! File not found!\n")
            self.CONTROLLER.after(
                1500, self.label_status.configure(text="", fg='black'))
Ejemplo n.º 10
0
    def loadData(self, id_state, name_state, host_state, searchtext):
        database = back_end.CookieDatabase()
        result_string = ""
        amount = 0
        amount_string = ""

        if id_state == 1:
            result_string = database.getSelectedEntries(1, searchtext)
            amount = database.getResultCount()
        elif name_state == 1:
            result_string = database.getSelectedEntries(2, searchtext)
            amount = database.getResultCount()
        elif host_state == 1:
            result_string = database.getSelectedEntries(3, searchtext)
            amount = database.getResultCount()

        self.amount_string = "Found [" + str(amount) + "] Entries."
        self.text_space.insert(tk.INSERT, result_string)
        self.counter_label.configure(text=self.amount_string)
        print("\n[>] " + self.amount_string + "\n")
Ejemplo n.º 11
0
    def applySettings(self, event=None):
        backend = bend.CookieDatabase()
        path = self.save_entry.get()

        if os.path.isfile(self.BASE_DIR + path):
            file = open(self.SETTINGS_PATH, 'w+')
            file.write(path)
            file.close()
            backend.reload_path()
            self.info_text2.configure(text="New Filepath: %s" % path,
                                      fg='green')
            self.CONTROLLER.update()
            self.CONTROLLER.after(
                2000, self.info_text2.configure(text="", fg='black'))
        else:
            # EVENTUELL hier noch textfeld im GUI ansprechen!
            self.info_text2.configure(text="ERROR! File not found!", fg='red')
            self.CONTROLLER.update()
            print("[X] ERROR! File not found!")
            self.CONTROLLER.after(
                2000, self.info_text2.configure(text="", fg='black'))
Ejemplo n.º 12
0
    def loadDatabase(self):
        self.database = bend.CookieDatabase()
        # BELOW is just a stupid workaround for opening windows, after they have been withdrawn -> stupid because the window is instantly destroyed
        data_win = tk.Tk()
        data_win.state('withdrawn')

        # Checks if windows are still open
        if self.DATABASE_LOADED == False:
            data_win.destroy()
            data_win = self.createNewWindow(-650, "Database", 1000, 800)
            self.scrollbar = tk.Scrollbar(data_win)
            self.textField = tk.Text(data_win,
                                     yscrollcommand=self.scrollbar.set)
            self.scrollbar.configure(activebackground=self.BACKGROUND_COLOR,
                                     command=self.textField.yview)
            self.textField.configure(highlightbackground=self.color,
                                     height=800,
                                     width=1000,
                                     state=tk.NORMAL)
            self.scrollbar.pack(side=tk.RIGHT, fill=tk.Y)
            self.textField.pack()
            self.DATABASE_LOADED = True
            self.textField.insert(tk.INSERT, self.database.getDatabase())
        elif 'withdrawn' == data_win.state():
            data_win.destroy()
            self.DATABASE_LOADED = False
            data_win = self.createNewWindow(-650, "Database", 1000, 800)
            self.scrollbar = tk.Scrollbar(data_win)
            self.textField = tk.Text(data_win,
                                     yscrollcommand=self.scrollbar.set)
            self.scrollbar.configure(activebackground=self.BACKGROUND_COLOR,
                                     command=self.textField.yview)
            self.textField.configure(highlightbackground=self.color,
                                     height=800,
                                     width=1000,
                                     state=tk.NORMAL)
            self.scrollbar.pack(side=tk.RIGHT, fill=tk.Y)
            self.textField.pack()
            self.DATABASE_LOADED = True
            self.textField.insert(tk.INSERT, self.database.getDatabase())
Ejemplo n.º 13
0
    def saveDict(self, dict, type, name):
        backend = bend.CookieDatabase()
        sorted_dict = {}

        if len(dict) > 1:
            # SORT the list here! -> Better for VIZUALIZATION!   (SORTING FOR >AMOUNT<)
            for value in sorted(dict.items(), key=lambda x: x[1]):
                if dict[value[0]] != "":
                    sorted_dict[value[0]] = dict[value[0]]
                else:
                    sorted_dict[value[0]] = "0"
        elif len(dict) == 1:
            for value in sorted(dict.items(), key=lambda x: x[1]):
                    sorted_dict[value[0]] = dict[value[0]]
        else:
            sorted_dict = None

        try:
            self.df = pd.DataFrame(columns=["HOST", "AMOUNT"]).from_dict(sorted_dict, orient='index').reset_index()
            self.df.to_csv(backend.REPORT_SAVE + '%s/%s_count_%s.csv' % (type, type, name), header=["HOST", "AMOUNT"], sep=',', index=False, mode='w+')
            print("[+] WROTE new %sname CSV to %s_count_%s.csv\n" % (type, type, name))
            print(self.df)
        except Exception:
            print("%s of %sdict could not be saved! -> No Cookies found in here!" % (type, name))
Ejemplo n.º 14
0
    def checkCSVFile(self, event=None):
        # Check each file ->
        self.database = bend.CookieDatabase()
        self.input_name = self.entry_fast.get()


        if (self.input_name == "") == False:
            self.existing = self.database.checkExistance('transformed', self.input_name)

            if self.existing == False:
                self.label_message.configure(text="[X] ERROR! File does not exist!", fg='red')
                self.CONTROLLER.update()            # CONTROLLER is the key to THREADING!
                print("[X] ERROR! File does not exist!\n")
                self.CONTROLLER.after(1500, self.label_message.configure(text="", fg='black'))
            elif self.existing == True:
                self.label_message.configure(text="[*] CSV exists!", fg='green')
                self.CONTROLLER.update()
                print("[*] CSV exists!\n")
                self.CONTROLLER.after(1500, self.label_message.configure(text="", fg='black'))
        else:
            self.label_message.configure(text="[X] Enter CSV name first!", fg='red')
            self.CONTROLLER.update()            # CONTROLLER is the key to "THREADING"!
            print("[X] Enter CSV name first!\n")
            self.CONTROLLER.after(1500, self.label_message.configure(text="", fg='black'))
Ejemplo n.º 15
0
    def loadData(self, searchtext):
        database = bend.CookieDatabase()
        result_string = ""

        result_string = database.getSelectedEntryInfo(1, searchtext)
        self.result_space.insert(tk.INSERT, result_string)
Ejemplo n.º 16
0
    def createReport(self, input, output):
        backend = bend.CookieDatabase()
        self.data = backend.loadCSV("transformed", input)
        print(self.data)
        self.hosts = self.data['HOST']

        # HOST SAVING AND HANDLING:
        self.sliced_hosts = self.sliceHosts(self.hosts)         # Slice Hosts
        self.host_dict = Counter(self.sliced_hosts)             # Counts the number of occurrencies within the LIST (from unique websites)
        self.saveDict(self.host_dict, "host", output)           # Save the dist (SORTED!)
        print("\n[1] Amount of all Hosts: " + str(self.countEntries(self.sliced_hosts)))

        # GET suffix dict out of sliced_suffixes and SAVE data:
        self.sliced_suffixes = self.sliceSuffixes(self.hosts)   # Slice Suffixes
        self.suffix_dict = Counter(self.sliced_suffixes)        # Counts the number of occurrencies within the LIST (from unique websites)
        self.saveDict(self.suffix_dict, "suffix", output)       # Save the dict (SORTED!)
        print("\n[2] Amount of all Suffixes: " + str(self.countEntries(self.sliced_suffixes)))

        # GET matching "entries" from database ():
        self.cook1st = self.findMatching(self.sliced_hosts, self.visited_hosts)
        self.cook1st_dict = Counter(self.cook1st)
        print("COOK1st: ######### T E S T ##########")
        print(self.cook1st)
        self.saveDict(self.cook1st_dict, "cook1st", output)       # Save the dict (SORTED!)
        print("\n[3] Amount of all 1st Party Cookies: " + str(self.countEntries(self.cook1st)))

        # GET matching "entries" from database ():
        self.cook3rd = self.findNotMatching(self.sliced_hosts, self.visited_hosts)
        self.cook3rd_dict = Counter(self.cook3rd)
        self.saveDict(self.cook3rd_dict, "cook3rd", output)       # Save the dict (SORTED!)
        print("\n[4] Amount of all 3rd Party Cookies: " + str(self.countEntries(self.cook3rd)))

        # GET matching "entries" from database ():
        self.tracker = self.findMatching(self.sliced_hosts, self.known_tracker)
        self.tracker_dict = Counter(self.tracker)
        self.saveDict(self.tracker_dict, "tracker", output)       # Save the dict (SORTED!)
        print("\n[5] Amount of all Tracking Cookies: " + str(self.countEntries(self.tracker)))

        ####### CSV CREATION: ###############################################################################
        print("\n\n #########  [6.] FILE-Creation:  #########\n")
        # AMOUNT of all cookies (should be in Graph too!)
        self.amount_cookies = str(self.countEntries(self.sliced_hosts))



        # COUNT unique HOSTS (occurrencies)
        self.unique_hosts = self.getUniqueEntries(self.sliced_hosts)
        print("\n########### O C C U R R E N C I E S ###########")
        self.count_hosts = str(self.countEntries(self.unique_hosts))
        print("[6] Amount unique Hosts: " + self.count_hosts)
        print(self.unique_hosts)

        # COUNT unique HOSTS (occurrencies)
        self.unique_suffixes = self.getUniqueEntries(self.sliced_suffixes)
        print("\n########### O C C U R R E N C I E S ###########")
        self.count_suffixes = str(self.countEntries(self.unique_suffixes))
        print("[7] Amount unique Suffixes: " + self.count_suffixes)
        print(self.unique_suffixes)

        # COUNT unique 1st COOKIES (occurrencies)
        self.unique_cook1st = self.getUniqueEntries(self.cook1st)
        print("\n########### O C C U R R E N C I E S ###########")
        self.count_cook1st = str(self.countEntries(self.unique_cook1st))
        print("[8] Amount unique 1st Party Cookies: " + self.count_cook1st)
        print(self.unique_cook1st)

        # COUNT unique 3rd COOKIES (occurrencies)
        self.unique_cook3rd = self.getUniqueEntries(self.cook3rd)
        print("\n########### O C C U R R E N C I E S ###########")
        self.count_cook3rd = str(self.countEntries(self.unique_cook3rd))
        print("[9] Amount unique 3rd Party Cookies: " + self.count_cook3rd)
        print(self.unique_cook3rd)

        # COUNT unique TRACKER (occurrencies)
        self.unique_tracker = self.getUniqueEntries(self.tracker)
        print("\n########### O C C U R R E N C I E S ###########")
        self.count_tracker = str(self.countEntries(self.unique_tracker))
        print("[10] Amount unique Tracking Cookies: " + self.count_tracker)
        print(self.unique_tracker)

        self.saveUniqueInfoAsCSV(self.count_hosts, self.count_cook1st, self.count_cook3rd, self.count_tracker, self.count_suffixes, output)


        self.total_cookies = str(self.countEntries(self.sliced_hosts))
        print("\n### N E W ###\nTOTAL COOKIES: %s" % self.total_cookies)
        self.total_1st = str(self.countEntries(self.cook1st))
        print("\nTOTAL 1ST PARTY: %s" % self.total_1st)
        self.total_3rd = str(self.countEntries(self.cook3rd))
        print("\nTOTAL 3RD PARTY: %s" % self.total_3rd)
        self.total_tracker = str(self.countEntries(self.tracker))
        print("\nTOTAL TRACKER: %s" % self.total_tracker)

        self.saveInfoAsCSV(self.total_cookies, self.total_1st, self.total_3rd, self.total_tracker, output)