-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathDiamondSorter.py
4204 lines (3384 loc) · 198 KB
/
DiamondSorter.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import json
import os
import re
import random
import string
import sys
import webbrowser
from PyQt5 import QtCore, QtGui, QtWidgets, uic
from PyQt5.QtCore import QUrl, Qt, QTimer, pyqtSignal, pyqtSlot, QThread, QThreadPool, QBasicTimer, QTimerEvent, QMessageLogContext, QtMsgType, QRect
from PyQt5.QtWidgets import QApplication, QLineEdit, QHBoxLayout, QShortcut, QMainWindow, QListWidget, QDockWidget, QPlainTextEdit, QLCDNumber, QWidget, QVBoxLayout, QTextBrowser, QFileDialog, QTextEdit, QComboBox, QPushButton, QMessageBox, QFrame, QInputDialog, QLabel, QCheckBox, QScrollBar, QDialogButtonBox, QDialog, QGridLayout, QMenu, QAction, QTabBar, QSystemTrayIcon, QScrollArea
from PyQt5.QtXml import QDomDocument
import hashlib
from multiprocessing import Process, Queue
from PyQt5.QtGui import QDesktopServices, QTextCursor, QTextDocument, QColor, QCursor, QTextCharFormat, QIcon, QPainter, QTextOption
import binascii
import json as jsond
import platform
import subprocess
from datetime import datetime
from time import sleep
import shutil
from collections import Counter, deque
from urllib.parse import urlparse
from multiprocessing import Process
import logging
import zipfile
import ctypes
import pystray
from pystray import MenuItem as item
from tqdm import tqdm
import ui_form
import requests
import time
import curses
from PIL import Image
import pyperclip
from flask import session
import warnings
from PyQt5.QtGui import QKeySequence
from PyQt5 import QAxContainer
import difflib
import tkinter as tk
import tk
import tkinter as tk
from tkinter import ttk
warnings.filterwarnings("ignore", category=UserWarning, message="QLayout: Cannot add parent widget")
warnings.filterwarnings("ignore", category=DeprecationWarning)
warnings.filterwarnings("ignore", category=UserWarning, message="Unknown property transform")
warnings.filterwarnings("ignore", category=UserWarning, message="Unknown property transform-origin")
country_phone_codes = {
"United States": "+1",
"United Kingdom": "+44",
"Canada": "+1",
"Australia": "+61",
# Add more countries and phone codes as needed
}
INSTALLER_MODE = False # CHANGE THIS LINE WHEN COMPILE
if INSTALLER_MODE:
top_classes = [QtWidgets.QMainWindow, ui_form.Ui_DiamondSorter]
else:
top_classes = [QtWidgets.QMainWindow]
def get_current_working_dir():
if getattr(sys, 'frozen', False):
application_path = os.path.dirname(sys.executable)
else:
application_path = os.path.dirname(__file__)
return application_path
def calc_lines(txt, remove_empty_lines = True):
if not txt.strip():
return 0
all_lines = txt.strip().split('\n')
if not remove_empty_lines:
return len(all_lines)
else:
return len([i for i in all_lines if bool(i.strip())])
def copytree(src, dst, skip_existing=True):
if not os.path.exists(dst):
os.makedirs(dst)
for root, dirs, files in os.walk(src):
for dir_ in dirs:
dest_dir = os.path.join(dst, os.path.relpath(os.path.join(root, dir_), src))
if not os.path.exists(dest_dir):
os.makedirs(dest_dir)
for file_ in files:
src_file = os.path.join(root, file_)
dest_file = os.path.join(dst, os.path.relpath(src_file, src))
if not skip_existing or not os.path.exists(dest_file):
shutil.copy2(src_file, dest_file)
class LogFilter(logging.Filter):
def filter(self, record):
# Filter out specific log messages containing "Unknown property transform-origin" and "Unknown property transform"
if "Unknown property transform-origin" in record.msg or "Unknown property transform" in record.msg:
return False
return True
def custom_log_handler(log_context, log_type, message):
# Implement your custom logging behavior here
# For example, you can print the log message to the console
print(message)
logger = logging.getLogger()
logger.setLevel(logging.DEBUG)
log_filter = LogFilter()
logger.addFilter(log_filter)
handler = logging.StreamHandler(sys.stdout)
handler.setFormatter(logging.Formatter("%(levelname)s: %(message)s"))
handler.setLevel(logging.DEBUG)
logger.addHandler(handler)
logging.basicConfig(format="%(levelname)s: %(message)s")
logging.Handler.logMessage = custom_log_handler
logging.getLogger("PyQt5.QtCore").setLevel(logging.WARNING)
logging.getLogger("PyQt5.QtGui").setLevel(logging.WARNING)
logging.getLogger("PyQt5.QtWidgets").setLevel(logging.WARNING)
class WordpressFinderThread(QThread):
results_obtained = pyqtSignal(str)
def __init__(self, directory_path):
super().__init__()
self.directory_path = directory_path
def run(self):
# Perform crawling logic and find WordPress instances in the directory
results = crawl_directory_for_wordpress(self.directory_path)
# Emit the results as a signal
self.results_obtained.emit(results)
class OverlayWidget(QWidget):
def __init__(self):
super().__init__()
self.setWindowFlags(Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint)
self.setAttribute(Qt.WA_TranslucentBackground)
self.setStyleSheet("background-color: rgba(0, 0, 0, 150);")
layout = QVBoxLayout()
self.setLayout(layout)
label = QLabel("I Agree to the Terms and Conditions")
layout.addWidget(label)
checkbox = QCheckBox()
layout.addWidget(checkbox)
button = QPushButton("Continue")
layout.addWidget(button)
class CrawlerThread(QThread):
finished = pyqtSignal()
copied = pyqtSignal(str)
not_copied = pyqtSignal(str)
def __init__(self, loaded_directory, folder_name, saved_directory, directory_path=None, input_textedit=None):
super().__init__()
self.loaded_directory = loaded_directory
self.folder_name = folder_name
self.saved_directory = saved_directory
self.directory_path = directory_path
self.input_textedit = input_textedit
def run(self):
try:
if self.input_textedit is not None:
directory_path = self.set_directory_path_element.toPlainText()
results = self.crawl_directory(output_text)
self.copied.emit(results)
else:
error_message = "Missing input_textedit for directory path."
self.not_copied.emit(error_message)
except Exception as e:
error_message = f"An error occurred: {str(e)}"
self.not_copied.emit(error_message)
def crawl_directory(self, directory_path):
# Implement the logic to crawl the directory here using the provided directory path
results = f"Crawling directory: {directory_path}"
return results
class FileSaver:
def __init__(self, savedResultsTextBox):
self.savedResultsTextBox = savedResultsTextBox
def save_output_text(self, always_save_checkBox, output_text):
if always_save_checkBox == True:
file_path = self.savedResultsTextBox.getText() # Get the directory path from the text box
with open(file_path + "/output.txt", "w") as file:
file.write(output_text) # Write the output text to a file named output.txt in the specified directory
class MyProcess(Process):
def __init__(self, queue):
super(MyProcess, self).__init__()
self.queue = queue
def run(self):
result = 1 + 100
self.queue.put(result)
class CookieWindow(QtWidgets.QDialog):
def __init__(self):
super(CookieWindow, self).__init__()
uic.loadUi(r'cookies_window.py', self)
class TaskTracker(QMainWindow):
def __init__(self):
super(TaskTracker, self).__init__()
# Create the main window layout
main_widget = QWidget(self)
main_layout = QVBoxLayout()
main_widget.setLayout(main_layout)
# Create the text edit widget for displaying tasks
self.task_text_edit = QTextEdit()
main_layout.addWidget(self.task_text_edit)
# Create the combo box for selecting task filters
self.filter_combo = QComboBox()
self.filter_combo.addItem("All")
self.filter_combo.addItem("Completed")
self.filter_combo.addItem("Pending")
main_layout.addWidget(self.filter_combo)
# Create the button for adding a new task
add_button = QPushButton("Add Task")
add_button.clicked.connect(self.add_task)
main_layout.addWidget(add_button)
# Set the main widget as the central widget of the main window
self.setCentralWidget(main_widget)
save_results_action_button.clicked.connect(self.open_save_directory_dialog)
def handle_scrape_banking_data(self):
# Get the directory path from the specified file directory
directory_path = self.Directory_Path_Text_Element.toPlainText()
def update_line_count(self):
"""Update the line count in the UI."""
# WHAT SHOULD BE HERE?
try:
total_lines_number = self.findChild(QLabel, "totalLinesNumber")
if total_lines_number is None:
return
input_text = self.findChild(QTextEdit, "input_text")
output_text = self.findChild(QTextEdit, "output_text")
if input_text is not None:
input_lines = len(input_text.toPlainText().split("\n"))
# totalLinesNumber.display(input_lines)
if output_text is not None:
output_lines = len(output_text.toPlainText().split("\n"))
except Exception as e:
print(f"An error occurred: {e}")
def import_requests(self):
try:
file_dialog = QFileDialog(self)
file_dialog.setFileMode(QFileDialog.ExistingFile)
file_dialog.setNameFilter("Text Files (*.txt)")
if file_dialog.exec_():
file_path = file_dialog.selectedFiles()[0]
with open(file_path, 'r') as file:
text = file.read()
self.input_text.setText(text)
except Exception as e:
print(f"An error occurred: {e}")
def launch_insomnia():
message_box = QtWidgets.QMessageBox()
message_box.setText("You are about to launch Insomnia. Continue?")
message_box.setWindowTitle("Diamond Sorter - Window")
message_box.setStandardButtons(QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No)
message_box.setDefaultButton(QtWidgets.QMessageBox.Yes)
result = message_box.exec_()
if result == QtWidgets.QMessageBox.Yes:
insomnia_path = r'references\Insomnia.exe'
subprocess.Popen(insomnia_path)
class GlowTabBar(QTabBar):
def __init__(self, parent=None):
super().__init__(parent)
self.current_index = 0
self.glow_color = QColor(255, 0, 0)
self.glow_width = 5
def paintEvent(self, event):
painter = QPainter(self)
option = self.tabRect(self.current_index)
option.setWidth(option.width() + 2 * self.glow_width)
painter.setRenderHint(QPainter.Antialiasing)
painter.setPen(Qt.NoPen)
painter.setBrush(self.glow_color)
painter.drawRoundedRect(option, 5, 5)
super().paintEvent(event)
def setCurrentIndex(self, index):
self.current_index = index
self.update()
class DiamondSorter(*top_classes):
finished = pyqtSignal(int)
def __init__(self, directory_path=None, input_textedit=None):
super(DiamondSorter, self).__init__()
if INSTALLER_MODE:
self.setupUi(self)
else:
uic.loadUi(r'form.ui', self)
# Create the system tray icon
self.tray_icon = QSystemTrayIcon(self)
# Set the icon for the system tray
icon = QIcon("./icons/diamond.png")
self.tray_icon.setIcon(icon)
# Create a context menu for the system tray icon
menu = QMenu()
# Create a "Show App" action for the context menu
show_app_action = QAction("Show Application", self)
show_app_action.triggered.connect(self.launch_show_app)
menu.addAction(show_app_action)
# Create a "Minimize App" action for the context menu
minimize_app_action = QAction("Minimize", self)
minimize_app_action.triggered.connect(self.launch_minimize)
menu.addAction(minimize_app_action)
# Create a submenu for Community actions
community_menu = menu.addMenu("Community")
# Add actions for Launch Homepage, Chat, and Github to the Community submenu
self.create_action("Launch Homepage", self.launch_homepage, community_menu)
self.create_action("Launch Chat", self.launch_chat, community_menu)
self.create_action("Github Repo", self.launch_github, community_menu)
# Create an "Exit" action for the context menu
exit_action = QAction("Exit", self)
exit_action.triggered.connect(self.exit_application)
menu.addAction(exit_action)
# Set the context menu for the system tray icon
self.tray_icon.setContextMenu(menu)
# Show the system tray icon
self.tray_icon.show()
self.setWindowTitle(self.windowTitle() + ('' if INSTALLER_MODE else ' ~ WIP'))
script_dir = os.path.dirname(sys.argv[0])
icon_path = os.path.join(script_dir, "icons", "diamond.ico")
self.setWindowIcon(QIcon(icon_path))
self.result = None
self.console_layout = QVBoxLayout(self.consolewidget)
self.console_layout.addWidget(self.consolewidget)
self.setup_buttons()
self.ask_user_dialog_box = QtWidgets.QInputDialog()
self.directory_path_text_element = QtWidgets.QTextEdit()
self.Directory_Path_Text_Element = self.directory_path_text_element
# Create an instance of ExtensionsBarQDockWidget
self.extensions_bar = ExtensionsBarQDockWidget()
redline_file_structure_text_browser = "Redline / Meta"
racoon_file_structure_text_browser = "Racoon Stealer"
whitesnake_file_structure_text_browser = "Whitesnake"
worldwind_file_structure_text_browser = "Worldwind / Prynt"
self.save_results_action_button.clicked.connect(self.open_save_directory_dialog)
self.app = QApplication.instance()
self.input_text = self.findChild(QTextEdit, "input_text")
self.output_text = self.findChild(QTextBrowser, "output_text")
self.removed_data_text = self.findChild(QTextBrowser, "removed_data_text")
self.input_text.textChanged.connect(self.update_line_count)
self.output_text.textChanged.connect(self.update_line_count)
self.removed_data_text.textChanged.connect(self.update_line_count)
self.enable_wordwrap_checkbox = self.findChild(QCheckBox, "enable_wordwrap_checkbox")
self.enable_wordwrap_checkbox.stateChanged.connect(self.toggle_word_wrap)
self.enable_remove_empty_lines_checkbox = self.findChild(QCheckBox, "remove_empty_lines_checkbox")
self.layout = QVBoxLayout()
self.actionLaunch_Browser.triggered.connect(self.open_browser)
self.actionInsomnia_HTTP_Client.triggered.connect(launch_insomnia)
self.windows_menu_actionDiamondPad.triggered.connect(self.launch_DiamondPad)
self.remove_trash_button = self.findChild(QPushButton, "remove_trash_button")
if self.remove_trash_button is not None:
self.remove_trash_button.clicked.connect(self.remove_trash_button_clicked)
self.display_function("MyFunction")
self.button = QtWidgets.QPushButton("Process Directory")
self.file_tree_view_button.clicked.connect(self.file_tree_structure_print)
#central_widget = QWidget(self)
#layout = QVBoxLayout(central_widget)
#self.count_error_lines = QLCDNumber(self)
##self.count_left_to_go = QLCDNumber(self)
#self.count_already_ran = QLCDNumber(self)
#self.totalLinesNumber = QLCDNumber(self)
#self.lcdNumber_1 = QLCDNumber(self)
menu_bar = self.menuBar()
# Create the search action and add it to the menu bar
search_action = QAction("Search", self)
search_action.triggered.connect(self.search_buttons)
menu_bar.addAction(search_action)
# Create the taskbar manager icon
menu = (
pystray.MenuItem("Show", self.on_show),
pystray.MenuItem("Minimize", self.on_minimize),
pystray.MenuItem("Quit", self.on_quit),
)
# Show the script window
self.show()
self.text_history = deque(maxlen=10) # Store the last 10 entered texts
# Connect the appropriate signal to update the history and text box
self.button.clicked.connect(self.update_directory_text)
directory_path = self.Directory_Path_Text_Element.toPlainText()
self.top_extensions = self.get_top_file_extensions(directory_path, 3) # Pass the value directly instead of using 'n=3'
self.set_directory_path_button.clicked.connect(self.open_directory_dialog)
self.create_username_button = QPushButton("Create Username List")
self.create_username_button.clicked.connect(self.create_username_list_button_clicked)
self.get_file_stats_button.clicked.connect(self.display_file_stats)
self.search_input_shortcut = QShortcut(QKeySequence("Ctrl+F"), self.input_text, context=Qt.WidgetShortcut)
self.search_input_shortcut.activated.connect(self.show_search_dialog_input)
self.search_output_shortcut = QShortcut(QKeySequence("Ctrl+F"), self.output_text, context=Qt.WidgetShortcut)
self.search_output_shortcut.activated.connect(self.show_search_dialog_output)
self.search_removed_shortcut = QShortcut(QKeySequence("Ctrl+F"), self.removed_data_text, context=Qt.WidgetShortcut)
self.search_removed_shortcut.activated.connect(self.show_search_dialog_removed)
self.import_requests_button.clicked.connect(self.import_requests_dialog)
self.import_requests_button = QPushButton("Import Requests")
self.sorting_cookies_sort_by_domain.clicked.connect(self.sort_cookies_by_domain)
def launch_minimize(self):
# Minimize the application window
self.showMinimized()
def create_menus(self):
# Create a submenu for Community actions
community_menu = QMenu("Community")
self.menuBar().addMenu(community_menu)
# Add actions for Launch Homepage, Chat, and Github to the Community submenu
self.create_action("Launch Homepage", self.launch_homepage, community_menu)
self.create_action("Launch Chat", self.launch_chat, community_menu)
self.create_action("Launch GitHub", self.launch_github, community_menu)
def create_action(self, title, handler, menu):
action = QAction(title, self)
action.triggered.connect(handler)
menu.addAction(action)
def launch_show_app(self):
# Check if the application is not at the top level
if self.windowState() == QtCore.Qt.WindowMinimized or self.isHidden():
self.setWindowState(QtCore.Qt.WindowActive)
self.showNormal()
def exit_application(self):
# Perform any necessary cleanup before exiting
self.tray_icon.hide()
sys.exit()
def launch_homepage(self):
# Open the homepage URL in the default browser
url = QUrl("https://opensourced.pro")
QDesktopServices.openUrl(url)
def launch_chat(self):
# Open the chat URL in the default browser
url = QUrl("https://t.me/+qHUEVtnXj3U2OGNh")
QDesktopServices.openUrl(url)
def launch_github(self):
# Open the GitHub URL in the default browser
url = QUrl("https://github.com/OpenSourcedPro")
QDesktopServices.openUrl(url)
def telegram_bot_token_extractor(input_text):
# Check if input_text is a string or bytes-like object
if not isinstance(input_text, (str, bytes)):
try:
input_text = str(input_text)
except Exception as e:
raise TypeError("Input text must be a string or bytes-like object") from e
# Rest of your code...
token_pattern = r'\b\d{9}:[\w-]{35}\b'
tokens = re.findall(token_pattern, input_text)
output_text = '\n'.join(tokens)
removed_data = re.sub(token_pattern, '', input_text)
removed_data_text = removed_data.strip()
return output_text, removed_data_text
def sort_cookies_by_domain(self):
# Function to be executed when the button is clicked
# Add your code for crawling the directory and searching for requests here
# Save the extracted lines in the appropriate folder and file structure
# Example code for demonstration purposes
directory_path_text_element = self.directory_path_text_element # Use the directory_path_text_element variable
user_requests = self.dialog_text_edit.toPlainText().split("\n") # Get user-submitted requests as a list
output_directory = self.savedResultsTextBox.text() # Get the output directory specified by the user
sorted_cookies_folder = "Sorted Cookies on Request"
# Create the sorted cookies folder if it doesn't exist
if not os.path.exists(sorted_cookies_folder):
os.mkdir(sorted_cookies_folder)
for request in user_requests:
if not request:
continue # Skip empty requests
request_folder = os.path.join(sorted_cookies_folder, request)
if not os.path.exists(request_folder):
os.makedirs(request_folder)
for root, dirs, files in os.walk(directory_path_text_element):
for file in files:
file_path = os.path.join(root, file)
with open(file_path, "r") as f:
lines = f.readlines()
# Find the lines that contain the request
matching_lines = [line for line in lines if request in line]
if matching_lines:
# Create the output file path
output_subdirectory = os.path.join(output_directory, request_folder)
if not os.path.exists(output_subdirectory):
os.makedirs(output_subdirectory)
output_file_path = os.path.join(output_subdirectory, file)
# Write the matching lines to the output file
with open(output_file_path, "w") as f:
f.writelines(matching_lines)
# Append to the console widget
self.console_widget_textedit.append("Sorting cookies by domain completed!")
def show_text_dialog(self):
# Display the multi-line text dialog
text, ok = QInputDialog.getMultiLineText(self, "Specify Requests", "Enter your requests (separate each one on a new line):")
if ok:
# Split the requests into a list
requests = text.split('\n')
# Crawl the file directory and search for requests
for root, dirs, files in os.walk(set_directory_path_element):
for file in files:
file_path = os.path.join(root, file)
with open(file_path, 'r') as f:
lines = f.readlines()
# Search for requests and save the extracted lines
for request in requests:
if request in lines:
# Create the directory structure for the extracted lines
request_folder = os.path.join('Sorted Cookies on Request', request.replace('/', '_'))
os.makedirs(request_folder, exist_ok=True)
# Save the extracted lines in the appropriate file
output_file_path = os.path.join(request_folder, f'{os.path.basename(root)}.txt')
with open(output_file_path, 'w') as f:
f.writelines(lines)
print("Extraction completed.")
def import_requests_dialog(self):
file_dialog = QFileDialog()
file_path, _ = file_dialog.getOpenFileName(self, "Select Text File", "", "Text Files (*.txt)")
if file_path:
with open(file_path, 'r', encoding='utf-8', errors='replace') as file:
self.input_text.clear() # Clear the existing text before importing
chunk_size = 1024 # Set the desired chunk size
while True:
chunk = file.read(chunk_size)
if not chunk:
break
self.input_text.insertPlainText(chunk)
QApplication.processEvents() # Allow the application to process other events
def show_search_dialog_input(self):
text, ok = QInputDialog.getText(self, 'Search', 'Enter search query:')
if ok:
query = text.strip()
if query:
cursor = self.input_text.textCursor()
if cursor.hasSelection():
cursor.clearSelection()
found = self.input_text.find(query, QTextDocument.FindWholeWords | QTextDocument.FindCaseSensitively)
if found:
self.input_text.setTextCursor(cursor)
self.input_text.ensureCursorVisible()
else:
QMessageBox.information(self, 'Search', 'The word was not found in the input text.')
def show_search_dialog_output(self):
text, ok = QInputDialog.getText(self, 'Search', 'Enter search query:')
if ok:
query = text.strip()
if query:
cursor = self.output_text.textCursor()
if cursor.hasSelection():
cursor.clearSelection()
found = self.output_text.find(query, QTextDocument.FindWholeWords | QTextDocument.FindCaseSensitively)
if found:
self.output_text.setTextCursor(cursor)
self.output_text.ensureCursorVisible()
else:
QMessageBox.information(self, 'Search', 'The word was not found in the output text.')
def show_search_dialog_removed(self):
text, ok = QInputDialog.getText(self, 'Search', 'Enter search query:')
if ok:
query = text.strip()
if query:
cursor = self.removed_data_text.textCursor()
if cursor.hasSelection():
cursor.clearSelection()
found = self.removed_data_text.find(query, QTextDocument.FindWholeWords | QTextDocument.FindCaseSensitively)
if found:
self.removed_data_text.setTextCursor(cursor)
self.removed_data_text.ensureCursorVisible()
else:
QMessageBox.information(self, 'Search', 'The word was not found in the removed data text.')
def display_file_stats(self):
directory_path = self.set_directory_path_element.toPlainText()
if os.path.exists(directory_path):
file_stats = []
for root, dirs, files in os.walk(directory_path):
file_stats.append(f"Folder: {root}")
for file in files:
file_path = os.path.join(root, file)
file_stats.append(f"File: {file_path}")
self.console_widget_textedit.setPlainText("\n".join(file_stats))
else:
self.console_widget_textedit.setPlainText("Invalid directory path.")
def open_directory_dialog(self):
directory = self.set_directory_path_element.toPlainText()
if directory:
print("Scanning files and folders...")
scan_files_folders(directory)
def scan_files_folders(directory):
counts = {
"file_count": 0,
"folder_count": 0,
"cookie_count": 0,
"new_text_document_count": 0,
"passwords_count": 0,
"profile_1_count": 0,
"dat_count": 0,
"compressed_count": 0
}
for root, dirs, files in tqdm(os.walk(directory), desc="Scanning files and folders", unit=" files"):
counts["folder_count"] += len(dirs)
counts["file_count"] += len(files)
for file in files:
counts["cookie_count"] += file.endswith(".txt")
counts["new_text_document_count"] += file.endswith(".txt") and not file.startswith("cookies")
counts["passwords_count"] += file == "Passwords.txt"
counts["profile_1_count"] += file == "Profile_1"
counts["dat_count"] += file.endswith(".dat")
counts["compressed_count"] += zipfile.is_zipfile(os.path.join(root, file))
print(f"Number of Folders: \033[91m{counts['folder_count']}\033[0m Number of Files: \033[92m{counts['file_count']}\033[0m Number of Cookies: \033[93m{counts['cookie_count']}\033[0m Number of New Text Documents: \033[94m{counts['new_text_document_count']}\033[0m")
print(f"Number of Passwords.txt: \033[95m{counts['passwords_count']}\033[0m Number of Profile_1: \033[96m{counts['profile_1_count']}\033[0m Number of .dat files: \033[97m{counts['dat_count']}\033[0m")
print(f"Number of Compressed Files: \033[33m{counts['compressed_count']}\033[0m")
def file_tree_structure_print(self):
directory_path = self.set_directory_path_element.text()
# Call the structure.py file with the directory path as a command-line argument
subprocess.run(["python", "./references/structure.py", directory_path])
def on_show(self):
# Show the script window if it is minimized or hidden
if self.isMinimized():
self.showNormal()
elif not self.isVisible():
self.show()
def on_minimize(self):
self.showMinimized()
def on_quit(self):
os._exit(0)
def update_directory_text(self):
text = self.input_text.toPlainText()
self.text_history.append(text)
self.set_directory_path_element.setText(text)
def submit_function(self):
text = self.input_text.toPlainText()
self.input_text.clear()
def search_buttons(self):
keyword, ok = QInputDialog.getText(self, "Search", "Enter a keyword:")
if ok:
found_buttons = []
for button in self.findChildren(QPushButton):
if keyword.lower() in button.text().lower():
found_buttons.append(button)
if found_buttons:
# Open the tab containing the first found button
tab_widget = self.findChild(QWidget, "tab_widget")
tab_index = tab_widget.indexOf(found_buttons[0].parentWidget())
if tab_index != -1:
tab_widget.setCurrentIndex(tab_index)
# Highlight the found buttons and connect the clicked signal to a slot
for found_button in found_buttons:
found_button.setStyleSheet("background-color: yellow;")
found_button.clicked.connect(self.reset_button_style)
else:
QMessageBox.information(self, "Search Results", "No buttons found matching the keyword.")
def reset_button_style(self):
sender = self.sender()
sender.setStyleSheet("") # Reset the style sheet
def launch_DiamondPad(self):
message_box = QtWidgets.QMessageBox()
message_box.setText("You are about to launch the built-in notepad. Continue?")
message_box.setWindowTitle("Diamond Pad")
message_box.setStandardButtons(QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No)
message_box.setDefaultButton(QtWidgets.QMessageBox.Yes)
result = message_box.exec_()
if result == QtWidgets.QMessageBox.Yes:
script_path = os.path.join(current_dir, "references", "scripts", "browser.py")
subprocess.Popen(["python", script_path])
def get_log_stats_function(self):
directory_path = self.set_directory_path_element.text()
if os.path.exists(directory_path):
folder_names = set()
text_documents = 0
for root, dirs, files in os.walk(directory_path):
for folder in dirs:
folder_names.add(folder)
for file in files:
if file.endswith('.txt'):
text_documents += 1
folder_names_count = len(folder_names)
text_documents_count = text_documents
self.console_widget_textedit.setPlainText(f"Multiple folder names detected: {folder_names_count}\nText documents found: {text_documents_count}")
else:
self.console_widget_textedit.setPlainText("Invalid directory path.")
def removeAfter_Tab_Space_clicked(self):
num_tabs, ok = QInputDialog.getInt(self, "Specify Number of Tab Spaces",
"Enter the number of Tab Spaces to move after:")
if ok:
lines = self.input_text.toPlainText().split('\n')
output_lines = []
removed_lines = []
for line in lines:
tab_count = line.count('\t')
if tab_count > num_tabs:
removed_lines.append(line)
else:
output_lines.append(line)
self.output_text.setPlainText('\n'.join(output_lines))
self.removed_data_text.setPlainText('\n'.join(removed_lines))
else:
print("User canceled the input dialog")
def display_function(self, function_name):
"""Update the text of the running_task_placeholder label."""
if function_name == self.redline_file_structure_text_browser:
self.stealer_log_file_structure_path.setText(self.redline_file_structure_text_browser)
elif function_name == self.racoon_file_structure_text_browser:
self.stealer_log_file_structure_path.setText(self.racoon_file_structure_text_browser)
elif function_name == self.whitesnake_file_structure_text_browser:
self.stealer_log_file_structure_path.setText(self.whitesnake_file_structure_text_browser)
elif function_name == self.worldwind_file_structure_text_browser:
self.stealer_log_file_structure_path.setText(self.worldwind_file_structure_text_browser)
def import_requests(self):
file_dialog = QFileDialog(self)
file_dialog.setFileMode(QFileDialog.ExistingFile)
file_dialog.setNameFilter("Text Files (*.txt)")
if file_dialog.exec_():
file_path = file_dialog.selectedFiles()[0]
with open(file_path, 'r') as file:
text = file.read()
self.input_text.setText(text)
def remove_trash_button_clicked(self):
"""Handle the button click event for remove_trash_button."""
options = ["Remove Unknown", "Remove ****", "Remove Short", "Remove Similar", "Remove User", "Remove Missing Value(U or P)", "Remove Lines Without :"] # Add the new option
# Create the custom dialog
dialog = QDialog(self)
dialog.setWindowTitle("Remove Trash Options") # Set the title of the dialog window
layout = QGridLayout(dialog) # Use QGridLayout for the layout
checkboxes = []
for i, option in enumerate(options):
checkbox = QCheckBox(option)
row = i // 4 # Calculate the row based on the index
col = i % 4 # Calculate the column based on the index
layout.addWidget(checkbox, row, col) # Add the checkbox to the layout
checkboxes.append(checkbox)
# Add OK and Cancel buttons
buttons = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
buttons.accepted.connect(dialog.accept)
buttons.rejected.connect(dialog.reject)
layout.addWidget(buttons, row + 1, 0, 1, 4) # Add the buttons to the layout
# Execute the dialog and get the selected options
if dialog.exec_() == QDialog.Accepted:
selected_options = [checkbox.text() for checkbox in checkboxes if checkbox.isChecked()]
# Start the removal process based on the selected options
self.start_removal(selected_options, similarity_threshold=0.8)
def start_removal(self, selected_options, similarity_threshold):
"""Perform the removal process based on the selected options."""
input_text = self.input_text.toPlainText()
removed_lines = []
for option in selected_options:
if option == "Remove Unknown":
input_text, removed = self.remove_unknown(input_text)
removed_lines.extend(removed)
elif option == "Remove ****":
input_text, removed = self.remove_consecutive_asterisks(input_text)
removed_lines.extend(removed)
elif option == "Remove Short":
input_text, removed = self.remove_short_lines(input_text)
removed_lines.extend(removed)
elif option == "Remove Similar":
input_text, removed = self.remove_similar_lines(input_text, similarity_threshold)
removed_lines.extend(removed)
elif option == "Passwords that has less that 3 characters":
input_text, removed = self.remove_weak_passwords(input_text)
removed_lines.extend(removed)
elif option == "Remove еÐâ":
input_text, removed = self.remove_non_english_lines(input_text)
removed_lines.extend(removed)
elif option == "Remove Illegal Usernames":
input_text, removed = self.remove_illegal_usernames(input_text)
removed_lines.extend(removed)
elif option == "Remove Lines Without :": # Handle the new option
input_text, removed = self.remove_lines_without_separator(input_text)
removed_lines.extend(removed)
self.output_text.setPlainText(input_text)
self.removed_data_text.setPlainText("\n".join(removed_lines))
def remove_unknown(self, text):
self.console_widget_textedit.appendPlainText("Removing lines with 'UNKNOWN'")
lines = text.split("\n")
removed_lines = [line for line in lines if "UNKNOWN" not in line]
cleaned_text = "\n".join(removed_lines)
output_text = self.findChild(QTextEdit, "output_text") # Replace "output_text" with the actual object name
removed_data_text = self.findChild(QTextBrowser, "removed_data_text") # Replace "removed_data_text" with the actual object name
if output_text is not None:
output_text.clear()
output_text.setPlainText(cleaned_text)
if removed_data_text is not None:
removed_data_text.clear()
removed_data_text.setPlainText("\n".join([line for line in lines if line not in removed_lines]))
return cleaned_text, [line for line in lines if line not in removed_lines]
def remove_consecutive_asterisks(self, text):
self.console_widget_textedit.appendPlainText("Removing lines with four or more consecutive asterisks")
lines = text.split("\n")
removed_lines = [line for line in lines if "****" not in line]
cleaned_text = "\n".join(removed_lines)
output_text = self.findChild(QTextEdit, "output_text") # Replace "output_text" with the actual object name
removed_data_text = self.findChild(QTextBrowser, "removed_data_text") # Replace "removed_data_text" with the actual object name
if output_text is not None:
output_text.clear()
output_text.setPlainText(cleaned_text)
if removed_data_text is not None:
removed_data_text.clear()
removed_data_text.setPlainText("\n".join([line for line in lines if line not in removed_lines]))
return cleaned_text, [line for line in lines if line not in removed_lines]
def remove_similar_lines(self, text, similarity_threshold):
self.console_widget_textedit.appendPlainText("Removing lines that are similar to other lines")
lines = text.split("\n")
cleaned_lines = []
removed_lines = []
for line in lines:
is_similar = False
for cleaned_line in cleaned_lines:
if self.are_lines_similar(line, cleaned_line):
is_similar = True
removed_lines.append(line)
break
if not is_similar:
cleaned_lines.append(line)
cleaned_text = "\n".join(cleaned_lines)
output_text = self.findChild(QTextEdit, "output_text") # Replace "output_text" with the actual object name
removed_data_text = self.findChild(QTextBrowser, "removed_data_text") # Replace "removed_data_text" with the actual object name
if output_text is not None:
output_text.clear()
output_text.setPlainText(cleaned_text)
if removed_data_text is not None:
removed_data_text.clear()
removed_data_text.setPlainText("\n".join(removed_lines))
return cleaned_text, removed_lines
def are_lines_similar(self, line1, line2):
similarity_score = difflib.SequenceMatcher(None, line1, line2).ratio()
similarity_threshold = 0.8
if similarity_score > similarity_threshold:
return True
else:
return False
def remove_lines_without_separator(self, text):
self.console_widget_textedit.appendPlainText("Removing lines without ':' separator")
lines = text.split("\n")
removed_lines = [line for line in lines if ":" in line]
cleaned_text = "\n".join(removed_lines)
output_text = self.findChild(QTextEdit, "output_text") # Replace "output_text" with the actual object name
removed_data_text = self.findChild(QTextBrowser, "removed_data_text") # Replace "removed_data_text" with the actual object name
if output_text is not None:
output_text.clear()
output_text.setPlainText(cleaned_text)