-
Notifications
You must be signed in to change notification settings - Fork 5
/
ComboToolPro GUI v1.1.1.py
318 lines (234 loc) · 11.3 KB
/
ComboToolPro GUI v1.1.1.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
import tkinter as tk
from tkinter import ttk
from tkinter import simpledialog
import re
import os
def update_output():
output_text.delete(1.0, tk.END)
output_text.insert(tk.END, input_text.get(1.0, tk.END))
update_line_count()
def update_line_count():
input_lines.set(f"Input Lines: {len(input_text.get(1.0, tk.END).splitlines())}")
output_lines.set(f"Output Lines: {len(output_text.get(1.0, tk.END).splitlines())}")
root = tk.Tk()
root.title("ComboToolPro GUI v1.1.1 by noarch")
root.geometry("1130x480")
root.resizable(False, False)
root.configure(bg="#333")
style = ttk.Style(root)
style.configure(
"TFrame", background="#333"
)
style.configure(
"TLabel", background="#333", foreground="#ddd"
)
style.configure(
"TButton", background="#555", foreground="black"
)
style.configure(
"TText", background="#444", foreground="#ddd", insertbackground='white'
)
main_frame = ttk.Frame(root)
main_frame.pack(padx=10, pady=10, fill=tk.BOTH, expand=True)
input_label = ttk.Label(main_frame, text="Input:")
input_label.grid(row=0, column=0, sticky=tk.W, pady=5)
output_label = ttk.Label(main_frame, text="Output:")
output_label.grid(row=2, column=0, sticky=tk.W, pady=5)
input_text = tk.Text(main_frame, wrap=tk.WORD, height=10)
input_text.grid(row=1, column=0, pady=5, sticky=tk.EW)
input_text.bind("<KeyRelease>", lambda e: update_line_count())
output_text = tk.Text(main_frame, wrap=tk.WORD, height=10)
output_text.grid(row=3, column=0, pady=5, sticky=tk.EW)
input_lines = tk.StringVar()
input_lines_label = ttk.Label(main_frame, textvariable=input_lines)
input_lines_label.grid(row=0, column=0, sticky=tk.W, pady=5)
output_lines = tk.StringVar()
output_lines_label = ttk.Label(main_frame, textvariable=output_lines)
output_lines_label.grid(row=2, column=0, sticky=tk.W, pady=5)
def paste_to_input():
"""Paste content from clipboard to input_text widget."""
try:
clipboard_content = root.clipboard_get()
input_text.delete(1.0, tk.END)
input_text.insert(tk.END, clipboard_content)
update_line_count()
except tk.TclError:
pass
def copy_from_output():
"""Copy content from output_text widget to clipboard."""
output_content = output_text.get(1.0, tk.END)
root.clipboard_clear()
root.clipboard_append(output_content)
def remove_duplicates():
"""Remove duplicate lines from input and display in output."""
lines = input_text.get(1.0, tk.END).splitlines()
unique_lines = list(dict.fromkeys(lines))
output_text.delete(1.0, tk.END)
output_text.insert(tk.END, "\n".join(unique_lines))
update_line_count()
def extract_by_search():
"""Function to extract lines by a search term and save to file."""
search_term = simpledialog.askstring("Search", "Enter the term to search for:")
if search_term:
matched_lines = [line for line in input_text.get(1.0, tk.END).splitlines() if search_term.lower() in line.lower()]
with open(f"{search_term}.txt", "a", encoding="utf-8") as file: # "a" mode appends to the file
for line in matched_lines:
file.write(line + '\n')
with open(f"{search_term}.txt", "r", encoding="utf-8") as file:
lines = file.readlines()
cleaned_lines = list(dict.fromkeys(lines))
with open(f"{search_term}.txt", "w", encoding="utf-8") as file:
file.writelines(cleaned_lines)
output_text.delete(1.0, tk.END)
output_text.insert(tk.END, ''.join(cleaned_lines))
update_line_count()
def extract_32_chars_after_colon():
"""Extract lines where the content after the colon is exactly 32 characters and save to file."""
pattern = re.compile(r":.{32}$")
matched_lines = [line for line in input_text.get(1.0, tk.END).splitlines() if pattern.search(line)]
with open("_Extracted_MD5_.txt", "a", encoding="utf-8") as file: # "a" mode appends to the file
for line in matched_lines:
file.write(line + '\n')
with open("_Extracted_MD5_.txt", "r", encoding="utf-8") as file:
lines = file.readlines()
cleaned_lines = list(dict.fromkeys(lines))
with open("_Extracted_MD5_.txt", "w", encoding="utf-8") as file:
file.writelines(cleaned_lines)
output_text.delete(1.0, tk.END)
output_text.insert(tk.END, ''.join(cleaned_lines))
update_line_count()
def show_domain_statistics():
"""Display domain statistics in the output_text widget in descending order."""
lines = input_text.get(1.0, tk.END).splitlines()
domains = [re.search(r"@(.+?)\.", line, re.IGNORECASE) for line in lines]
domain_list = [match.group(1).lower() for match in domains if match] # Convert to lowercase
domain_stats = {}
total = len(domain_list)
for domain in domain_list:
if domain not in domain_stats:
domain_stats[domain] = 0
domain_stats[domain] += 1
sorted_stats = sorted(domain_stats.items(), key=lambda x: x[1], reverse=True)
stats_output = []
for domain, count in sorted_stats:
percentage = (count / total) * 100
stats_output.append(f"{count} {domain} Lines ({percentage:.2f}%)")
output_text.delete(1.0, tk.END)
output_text.insert(tk.END, '\n'.join(stats_output))
update_line_count()
def filter_colon_lines():
"""Keep only lines containing a colon and with 5 to 28 characters after the colon."""
lines = input_text.get(1.0, tk.END).splitlines()
filtered_lines = []
for line in lines:
if ":" in line:
_, _, after_colon = line.partition(":")
after_length = len(after_colon.strip())
if 5 <= after_length <= 28:
filtered_lines.append(line)
output_text.delete(1.0, tk.END)
output_text.insert(tk.END, '\n'.join(filtered_lines))
update_line_count()
def remove_after_space():
"""Remove content after the first space in each line."""
lines = input_text.get(1.0, tk.END).splitlines()
processed_lines = [line.split(" ")[0] for line in lines]
output_text.delete(1.0, tk.END)
output_text.insert(tk.END, '\n'.join(processed_lines))
update_line_count()
import random
from tkinter import simpledialog
def organize_lines():
"""Provide multiple sorting options and sort lines based on user's choice."""
options = ["A-Z", "Z-A", "0-9", "Shortest to longest", "Longest to shortest", "Randomize lines"]
choice = simpledialog.askstring("Organize", "Choose an option number:\n1. A-Z\n2. Z-A\n3. 0-9\n4. Short to long\n5. Long to short\n6. Randomize Lines", initialvalue="A-Z", parent=root)
lines = input_text.get(1.0, tk.END).splitlines()
if choice == "1":
sorted_lines = sorted(lines)
elif choice == "2":
sorted_lines = sorted(lines, reverse=True)
elif choice == "3":
sorted_lines = sorted(lines, key=lambda x: [int(t) if t.isdigit() else t for t in re.split('(\d+)', x)])
elif choice == "4":
sorted_lines = sorted(lines, key=len)
elif choice == "5":
sorted_lines = sorted(lines, key=len, reverse=True)
elif choice == "6":
random.shuffle(lines)
sorted_lines = lines
else:
return
output_text.delete(1.0, tk.END)
output_text.insert(tk.END, '\n'.join(sorted_lines))
update_line_count()
def split_by_lines():
"""Split content based on user-defined number of lines and save to a specified directory."""
num_lines = simpledialog.askinteger("Split", "How many lines for each split?", parent=root)
if not num_lines:
return
split_name = simpledialog.askstring("Name", "What to name the split?", parent=root)
if not split_name:
return
directory = os.path.join("split", split_name)
if not os.path.exists(directory):
os.makedirs(directory)
lines = input_text.get(1.0, tk.END).splitlines()
for index, start_line in enumerate(range(0, len(lines), num_lines), 1):
file_path = os.path.join(directory, f"{split_name}_{index}.txt")
with open(file_path, "w", encoding="utf-8") as file:
file.write('\n'.join(lines[start_line:start_line + num_lines]))
def combine_files():
"""Combine all text files from 'toCombine' directory, save to '_combined_.txt' and remove duplicates."""
combined_content = []
dir_path = "toCombine"
for filename in os.listdir(dir_path):
if filename.endswith(".txt"):
with open(os.path.join(dir_path, filename), "r", encoding="utf-8") as file:
combined_content.extend(file.readlines())
with open("_combined_.txt", "w", encoding="utf-8") as file:
file.writelines(combined_content)
with open("_combined_.txt", "r", encoding="utf-8") as file:
lines = file.readlines()
unique_lines = list(dict.fromkeys(lines))
with open("_combined_.txt", "w", encoding="utf-8") as file:
file.writelines(unique_lines)
output_text.delete(1.0, tk.END)
output_text.insert(tk.END, ''.join(unique_lines))
update_line_count()
def save_output():
"""Save the content of output_text to a file named after user's input."""
filename = simpledialog.askstring("Save As", "Enter the name for the file:", parent=root)
if not filename:
return
if not filename.endswith(".txt"):
filename += ".txt"
with open(filename, "w", encoding="utf-8") as file:
file.write(output_text.get(1.0, tk.END))
button_frame = ttk.Frame(main_frame)
button_frame.grid(row=5, column=0, pady=10, columnspan=2)
paste_btn = ttk.Button(button_frame, text="Paste Input", command=paste_to_input)
paste_btn.pack(side=tk.LEFT, padx=5)
copy_btn = ttk.Button(button_frame, text="Copy Output", command=copy_from_output)
copy_btn.pack(side=tk.LEFT, padx=5)
remove_dup_btn = ttk.Button(button_frame, text="Remove Duplicates", command=remove_duplicates)
remove_dup_btn.pack(side=tk.LEFT, padx=5)
extract_search_btn = ttk.Button(button_frame, text="Extract Domain", command=extract_by_search)
extract_search_btn.pack(side=tk.LEFT, padx=5)
extract_32chars_btn = ttk.Button(button_frame, text="Extract MD5", command=extract_32_chars_after_colon)
extract_32chars_btn.pack(side=tk.LEFT, padx=5)
domain_stats_btn = ttk.Button(button_frame, text="Statistics", command=show_domain_statistics)
domain_stats_btn.pack(side=tk.LEFT, padx=5)
filter_colon_btn = ttk.Button(button_frame, text="Cleanup", command=filter_colon_lines)
filter_colon_btn.pack(side=tk.LEFT, padx=5)
remove_capture_btn = ttk.Button(button_frame, text="Remove capture", command=remove_after_space)
remove_capture_btn.pack(side=tk.LEFT, padx=5)
organize_btn = ttk.Button(button_frame, text="Organize", command=organize_lines)
organize_btn.pack(side=tk.LEFT, padx=5)
split_btn = ttk.Button(button_frame, text="Split", command=split_by_lines)
split_btn.pack(side=tk.LEFT, padx=5)
combine_btn = ttk.Button(button_frame, text="Combine", command=combine_files)
save_output_btn = ttk.Button(button_frame, text="Save Output", command=save_output)
save_output_btn.pack(side=tk.LEFT, padx=5)
combine_btn.pack(side=tk.LEFT, padx=5)
update_line_count()
root.mainloop()