-
Notifications
You must be signed in to change notification settings - Fork 10
/
DiamondSorter.pyw
3469 lines (2803 loc) · 164 KB
/
DiamondSorter.pyw
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, 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
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 logto import LogtoClient, LogtoConfig, Storage
from flask import session
from keyauth.keyauth import api
import warnings
from PyQt5.QtGui import QKeySequence
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")
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 CrawlerThread(QThread):
finished = pyqtSignal()
copied = pyqtSignal(str)
not_copied = pyqtSignal(str)
def __init__(self, loaded_directory, folder_name, saved_directory, directory_path, input_textedit):
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:
# Perform crawling logic and find WordPress instances in the directory
results = self.set_directory_path_element(self.directory_path)
self.results_obtained.emit(results)
# Access clipboard and set text to input_textedit
clipboard = QtWidgets.QApplication.clipboard()
text = clipboard.text()
self.input_textedit.setPlainText(text)
except NameError:
# Display an error dialog if the function is not defined
error_message = "crawl_directory_for_wordpress function is not defined."
QMessageBox.critical(self, "Error", error_message)
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 AboutWindow(QDialog):
def __init__(self):
super().__init__()
self.setWindowTitle("About")
self.setFixedSize(400, 300) # Set the size of the window
layout = QVBoxLayout()
# Add labels with software information, user policy, and terms of service
software_info_label = QLabel("This is an example application.\nVersion 1.0")
layout.addWidget(software_info_label)
self.setLayout(layout)
class DiamondSorter(*top_classes):
finished = pyqtSignal(int)
def __init__(self):
super(DiamondSorter, self).__init__()
if INSTALLER_MODE:
self.setupUi(self)
else:
uic.loadUi(r'form.ui', self)
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.button.clicked.connect(self.handle_newtextdocuments)
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()
about_action = QAction("OpenSourced.Pro - About", self)
about_action.triggered.connect(self.show_about_message)
menu_bar.addAction(about_action)
def show_about_message(self):
about_text = """
<b>✨ This is an example application. ✨</b>
<br>
<i>🚀 Released by: <a href="https://opensourced.pro">Opensourced.Pro Forums</a> 🚀</i>
<br>
Get the best opensourced:
<br>
- Scripts 📜
<br>
- Configs ⚙️
<br>
- Codes 💻
<br>
...and more. 🌟
<br>
<br>
<b>💎 Diamond Sorter 💎</b>
<br>
Part of the Diamond Series
<br>
<b>Version 1.8.7</b>
"""
QMessageBox.about(self, "About", about_text)
search_action = QAction("Search", self)
search_action.triggered.connect(self.search_buttons)
self.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")
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 open_about_window(self):
about_window = AboutWindow()
about_window.exec_()
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.toPlainText()
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 Simalar", "Remove User", "Remove Missing Value(U or P)"] # Replace with your specific options
# 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)
def start_removal(self, selected_options):
"""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)
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)
self.output_text.setPlainText(input_text)
self.removed_data_text.setPlainText("\n".join(removed_lines))
def remove_unknown(self, text):
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)
return cleaned_text, [line for line in lines if line not in removed_lines]
def remove_consecutive_asterisks(self, text):
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)
return cleaned_text, [line for line in lines if line not in removed_lines]
def remove_short_lines(self, text):
console_widget_textedit.appendPlainText("Removing lines with 3 or less characters")
lines = text.split("\n")
removed_lines = [line for line in lines if len(line.strip()) > 3]
cleaned_text = "\n".join(removed_lines)
return cleaned_text, [line for line in lines if line not in removed_lines]
def remove_similar_lines(self, text):
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)
return cleaned_text, removed_lines
def are_lines_similar(self, line1, line2):
# Implement the logic to check similarity between two lines
# You can use string comparison algorithms like Levenshtein distance or difflib
# Example code for similarity check using exact match:
return line1 == line2
def remove_weak_passwords(self, text):
print("Removing lines with weak passwords")
lines = text.split("\n")
cleaned_lines = [line for line in lines if len(line.split(":")[-1].strip()) > 3]
cleaned_text = "\n".join(cleaned_lines)
return cleaned_text, [line for line in lines if line not in cleaned_lines]
def remove_non_english_lines(self, text):
console_widget_textedit.appendPlainText("Removing lines with non-English characters")
lines = text.split("\n")
cleaned_lines = [line for line in lines if self.is_english(line)]
cleaned_text = "\n".join(cleaned_lines)
return cleaned_text, [line for line in lines if line not in cleaned_lines]
def remove_illegal_usernames(self, text):
console_widget_textedit.appendPlainText("Removing lines with illegal usernames")
lines = text.split("\n")
cleaned_lines = [line for line in lines if self.is_valid_username(line)]
cleaned_text = "\n".join(cleaned_lines)
return cleaned_text, [line for line in lines if line not in cleaned_lines]
def is_english(self, line):
return all(ord(c) < 128 for c in line)
def is_valid_username(self, line):
# Implement the logic to check if a username is valid
# You can use regular expressions or other validation rules
# Example code for checking if a username is valid:
return re.match(r"^[a-zA-Z0-9_-]{3,20}$", line.split(":")[0]) is not None
def update_output_text(self):
output_text = self.password_format_tab.output_text.toPlainText()
if self.remove_empty_lines_checkbox.isChecked():
output_text = "\n".join(line for line in output_text.split("\n") if line.strip())
self.password_format_tab.output_text.setPlainText(output_text)
def open_directory_dialog(self):
dialog = QFileDialog()
dialog.setFileMode(QFileDialog.Directory)
if dialog.exec_():
selected_directory = dialog.selectedFiles()[0]
self.set_directory_path_element.setPlainText(selected_directory)
def process_directory(self, directory):
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 # Initialize the count for compressed files
progress_bar = tqdm(total=100, desc="Scanning files and folders", unit="iteration")
for root, dirs, files in os.walk(directory):
folder_count += len(dirs)
file_count += len(files)
cookie_count += sum(file.endswith(".txt") for file in files)
new_text_document_count += sum(file.endswith(".txt") and not file.startswith("cookies") for file in files)
passwords_count += sum(file == "Passwords.txt" for file in files)
profile_1_count += sum(file == "Profile_1" for file in files)
dat_count += sum(file.endswith(".dat") for file in files)
compressed_count += sum(zipfile.is_zipfile(os.path.join(root, file)) for file in files) # Increment the compressed count for each ZIP file
# Update the progress bar
progress_bar.update(1)
progress_bar.close()
# Format the results for console log and widget
console_results = f"Folders: \033[91m{folder_count}\033[0m Files: \033[92m{file_count}\033[0m\n"
console_results += f"Profile_1: \033[93m{profile_1_count}\033[0m Cookies: \033[94m{cookie_count}\033[0m\n"
console_results += f"Passwords: \033[95m{passwords_count}\033[0m .dat files: \033[96m{dat_count}\033[0m\n"
console_results += f"Compressed Files: \033[33m{compressed_count}\033[0m\n"
widget_results = f"Folders: {folder_count} Files: {file_count}\n"
widget_results += f"Profile_1: {profile_1_count} Cookies: {cookie_count}\n"
widget_results += f"Passwords: {passwords_count} .dat files: {dat_count}\n"
widget_results += f"Compressed Files: {compressed_count}\n"
self.console_widget_textedit.appendPlainText(widget_results)
print(console_results)
def get_top_file_extensions(self, directory, n=3):
file_extensions = []
directory_path = self.directory_path_text_element.toPlainText()
if not directory_path:
self.console_widget_textedit.appendPlainText("Error: No directory path provided.")
return
for root, dirs, files in os.walk(directory_path):
for file in files:
_, extension = os.path.splitext(file)
if extension: # Exclude blank extensions
file_extensions.append(extension)
counter = Counter(file_extensions)
top_extensions = counter.most_common(3)
result = "Top 3 File Extensions:\n"
for extension, count in top_extensions:
result += f"Extension: {extension} | Count: {count}\n"
self.console_widget_textedit.appendPlainText(result)
def open_save_directory_dialog(self):
directory = QFileDialog.getExistingDirectory(self, "Select Directory")
if directory:
self.savedResultsTextBox.setText(directory)
def open_browser(self):
message_box = QtWidgets.QMessageBox()
message_box.setText("You are about to launch the built-in browser. 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:
required_modules = ["stem", "adblock"]
missing_modules = []
for module in required_modules:
spec = importlib.util.find_spec(module)
if spec is None:
missing_modules.append(module)
if missing_modules:
error_message = "The following modules are missing: {}".format(", ".join(missing_modules))
QtWidgets.QMessageBox.critical(self, "Missing Modules", error_message, QtWidgets.QMessageBox.Ok)
else:
script_path = os.path.join(current_dir, "scripts", "browser.py")
subprocess.Popen(["python", script_path])
def cleanup(self):
"""Cleanup the input text."""
try:
# Ask for confirmation
reply = QMessageBox.question(
self,
"Confirmation",
"Are you sure you want to perform the cleanup action?",
QMessageBox.Yes | QMessageBox.No,
QMessageBox.No
)
if reply == QMessageBox.Yes:
input_text = self.findChild(QTextEdit, "input_text") # Replace "input_text" with the actual object name
output_text = self.findChild(QTextEdit, "output_text") # Replace "output_text" with the actual object name
if input_text is not None and output_text is not None:
text = input_text.toPlainText()
lines = text.split("\n")
cleaned_lines = [line.strip() for line in lines if line.strip()]
output_text.clear()
output_text.setPlainText("\n".join(cleaned_lines))
self.update_line_count() # Assuming update_line_count is a method in your class
# Display the pop-up window with checkboxes
dialog = QDialog(self)
layout = QVBoxLayout(dialog)
# Add checkboxes
checkbox1 = QCheckBox("Checkbox 1")
checkbox2 = QCheckBox("Checkbox 2")
checkbox3 = QCheckBox("Checkbox 3")
checkbox4 = QCheckBox("Checkbox 4")
checkbox5 = QCheckBox("Checkbox 5")
checkbox6 = QCheckBox("Checkbox 6")
checkbox7 = QCheckBox("Checkbox 7")
layout.addWidget(checkbox1)
layout.addWidget(checkbox2)
layout.addWidget(checkbox3)
layout.addWidget(checkbox4)
layout.addWidget(checkbox5)
layout.addWidget(checkbox6)
layout.addWidget(checkbox7)
# Add OK and Cancel buttons
buttons = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
buttons.accepted.connect(dialog.accept)
buttons.rejected.connect(dialog.reject)
layout.addWidget(buttons)
if dialog.exec_() == QDialog.Accepted:
# OK button pressed, perform further actions based on the checkbox states
if checkbox1.isChecked():
# Handle checkbox 1 checked
pass
if checkbox2.isChecked():
# Handle checkbox 2 checked
pass
# ... handle other checkboxes
except Exception as e:
console_widget_textedit.appendPlainText("An error occurred: {e}")
def number_password(self):
"""Create a list of number values that could be phone numbers."""
try:
input_text = self.findChild(QTextEdit, "input_text") # Replace "input_text" with the actual object name
output_text = self.findChild(QTextEdit, "output_text") # Replace "output_text" with the actual object name
removed_text = self.findChild(QTextBrowser, "removed_data_text") # Replace "removed_data_text" with the actual object name
if input_text is not None and output_text is not None and removed_text is not None:
text = input_text.toPlainText()
lines = text.split("\n")
number_list = []
removed_list = []
for line in lines:
numbers = re.findall(r"\d{3}-\d{3}-\d{4}", line) # Assuming phone numbers are in the format XXX-XXX-XXXX
if numbers:
number_list.extend(numbers)
removed_list.append(line)
output_text.clear()
output_text.setPlainText("\n".join(number_list))
removed_text.clear()
removed_text.setLineWrapMode(QTextEdit.WidgetWidth)
removed_text.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
removed_text.setPlainText("\n".join(removed_list))
except Exception as e:
print(f"An error occurred: {e}")
def create_passwordlist(self):
"""Create a list of values after the specified value."""
try:
specified_value, ok = QInputDialog.getText(self, "Create Password List", "Enter the specified value:")
if ok and specified_value: