-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgui.py
More file actions
2830 lines (2519 loc) · 152 KB
/
Copy pathgui.py
File metadata and controls
2830 lines (2519 loc) · 152 KB
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 csv
import json
import os
import platform
import queue
import shutil
import subprocess
import threading
import time
import uuid
import requests
from collections import defaultdict, deque
from concurrent.futures import TimeoutError as FuturesTimeoutError, ThreadPoolExecutor, as_completed
from datetime import datetime, timedelta
from pathlib import Path
import tkinter as tk
from tkinter import filedialog, messagebox, ttk
from app_logging import logger
from logging import write_detailed_log, write_privacy_log
from config import DATA_DIR, HITS_DIR, LOGS_DIR, PROCESSED_SITES_FILE, config, download_gost, ensure_hydra_available, ensure_nordvpn_cli, force_retry_hydra, get_effective_proxy, get_intercept_proxy, get_vpn_control, save_config
from extract import extract_login_form, test_credentials_for_site
from burp import BURP_DOWNLOAD_URL, launch_burp, run_burp_with_project
from zap import import_data_to_zap, launch_zap, run_zap_active_scan
from install_tools import check_nordvpn_onion_support, detect_tor_installation, install_burp, install_hydra, install_tor_dependencies, install_zap
from helpers import COMMON_LOGIN_PATHS, RELEVANT_SCOPE_KEYS, SETTING_SCOPE_OPTIONS, classify_onion_reachability, get_base_url, get_scoped_value, get_site_filename, get_user_agent_library, is_onion_url, log_once, normalize_and_validate_target, normalize_site, resolve_user_agent, scope_applies, split_three_fields
from tor_manager import detect_tor_executable, is_tor_running, start_tor, stop_tor
from runner import RunnerMixin
from proxies import ProxyManager
from project_io import (
AutosaveWorker,
atomic_write_json,
build_project_payload,
diagnostics_summary,
export_rows_csv,
export_rows_json,
export_run_summaries_csv,
export_timeline_csv,
load_project_payload,
parse_project_json,
site_report_rows,
summarize_status_counts,
top_failing_domains,
utc_now_iso,
)
from run_summary import RunSummary, compute_run_summary, from_dict as run_summary_from_dict
from timeline import in_time_window, make_event, normalize_event, parse_ts
def apply_theme(root):
style = ttk.Style(root)
available = set(style.theme_names())
preferred = "vista" if platform.system() == "Windows" and "vista" in available else "clam"
if preferred in available:
style.theme_use(preferred)
base_pad = 8
style.configure("TFrame", padding=base_pad)
style.configure("TLabelframe", padding=base_pad)
style.configure("TLabelframe.Label", font=("Segoe UI", 10, "bold"))
style.configure("TLabel", font=("Segoe UI", 10))
style.configure("Header.TLabel", font=("Segoe UI Semibold", 15))
style.configure("TButton", padding=(12, 6), font=("Segoe UI", 10))
style.configure("Treeview", font=("Segoe UI", 10), rowheight=30)
style.configure("Treeview.Heading", font=("Segoe UI Semibold", 10))
style.map("Treeview", background=[("selected", "#d9ebff")], foreground=[("selected", "#1f2937")])
style.configure("TNotebook.Tab", padding=(16, 8), font=("Segoe UI Semibold", 10))
class ToolTip:
def __init__(self, widget, text):
self.widget = widget
self.text = text
self.tipwindow = None
widget.bind("<Enter>", self.show, add="+")
widget.bind("<Leave>", self.hide, add="+")
def show(self, _event=None):
if self.tipwindow or not self.text:
return
x = self.widget.winfo_rootx() + 20
y = self.widget.winfo_rooty() + self.widget.winfo_height() + 4
self.tipwindow = tw = tk.Toplevel(self.widget)
tw.wm_overrideredirect(True)
tw.wm_geometry(f"+{x}+{y}")
label = ttk.Label(tw, text=self.text, justify="left", relief="solid", borderwidth=1, padding=6, background="#fff8dc")
label.pack()
def hide(self, _event=None):
if self.tipwindow:
self.tipwindow.destroy()
self.tipwindow = None
class CollapsibleFrame(ttk.Frame):
def __init__(self, parent, title):
super().__init__(parent)
self._visible = tk.BooleanVar(value=True)
self.toggle = ttk.Checkbutton(self, text=title, variable=self._visible, command=self._update, style="Toolbutton")
self.toggle.pack(fill="x", anchor="w")
self.body = ttk.Frame(self)
self.body.pack(fill="both", expand=True, pady=(6, 0))
def _update(self):
if self._visible.get():
self.body.pack(fill="both", expand=True, pady=(6, 0))
else:
self.body.pack_forget()
class CombinedParserGUI(RunnerMixin):
def __init__(self, root):
self.root = root
apply_theme(self.root)
self.root.title("Ultimate Combo → Hydra Pipeline")
self.root.geometry("1450x980")
self.root.minsize(1200, 720)
self.input_path = tk.StringVar()
self.output_path = tk.StringVar()
self.forms_output_path = tk.StringVar()
self.status_text = tk.StringVar(value="Ready.")
self.state_text = tk.StringVar(value="Idle")
self.header1 = tk.StringVar(value="site")
self.header2 = tk.StringVar(value="user")
self.header3 = tk.StringVar(value="pass")
self.create_combo = tk.BooleanVar(value=True)
self.extract_forms = tk.BooleanVar(value=True)
self.skip_blank = tk.BooleanVar(value=True)
self.trim_whitespace = tk.BooleanVar(value=True)
self.use_proxy = tk.BooleanVar(value=get_vpn_control(config) == "nordvpn")
self.proxy_url = tk.StringVar(value=config.get("proxy_url", ""))
self.enable_onion_processing = tk.BooleanVar(value=bool(config.get("enable_onion_processing", False)))
self.use_nordvpn_onion_only = tk.BooleanVar(value=bool(config.get("use_nordvpn_onion_only", False)))
self.auto_launch_tor = tk.BooleanVar(value=bool(config.get("auto_launch_tor", True)))
self.tor_executable_path = tk.StringVar(value=str(config.get("tor_executable_path", "") or detect_tor_executable()))
self.random_user_agent = tk.BooleanVar(value=bool(config.get("random_user_agent", False)))
self.selected_user_agent = tk.StringVar(value=config.get("selected_user_agent", "") or (get_user_agent_library(config)[0] if get_user_agent_library(config) else ""))
self.custom_user_agent = tk.StringVar(value=config.get("custom_user_agent", ""))
self.user_agent_library = list(get_user_agent_library(config))
self.tld_only = tk.BooleanVar(value=True)
self.threads = tk.IntVar(value=4) # FIXED: safer default concurrency
self.strict_validation = tk.BooleanVar(value=True)
self.use_playwright_dynamic = tk.BooleanVar(value=bool(config.get("use_playwright_dynamic", False)))
self.advanced_extraction_mode = tk.BooleanVar(value=bool(config.get("advanced_extraction_mode", False)))
self.force_recheck = tk.BooleanVar(value=bool(config.get("force_recheck", False)))
self.burp_proxy = tk.StringVar(value=config.get("burp_proxy", ""))
self.use_burp = tk.BooleanVar(value=bool(config.get("use_burp", False)))
self.zap_proxy = tk.StringVar(value=config.get("zap_proxy", "http://127.0.0.1:8080"))
self.use_zap = tk.BooleanVar(value=bool(config.get("use_zap", False)))
self.zap_api_key = tk.StringVar(value=config.get("zap_api_key", ""))
self.auto_start_zap_daemon = tk.BooleanVar(value=bool(config.get("auto_start_zap_daemon", False)))
self.proxy_rotation = tk.BooleanVar(value=bool(config.get("proxy_rotation", False)))
self.proxy_list_file = tk.StringVar(value=config.get("proxy_list_file", ""))
self.show_debug_details = tk.BooleanVar(value=False)
self.extract_log_file = None
self.runner_log_file = None
self.proxy_manager = None
self.pipeline_running = False
self.pipeline_paused = False
self.pipeline_cancelled = False
self.cancel_event = threading.Event()
self.pause_event = threading.Event()
self.ui_queue = queue.Queue()
self._main_thread = threading.current_thread()
self.gost_process = None
self.tor_process = None
self.timeline_events = []
self.timeline_sort_state = {"column": "Time", "reverse": True}
self.timeline_row_ids = {}
self.timeline_coalesce = defaultdict(list)
self.timeline_coalesce_last_summary = {}
self.timeline_fetch_failures = deque()
self.timeline_last_fetch_burst_ts = 0.0
self.run_summaries = []
self.run_history_sort_state = {"column": "Started", "reverse": True}
self.active_run_context = None
self.selected_run_id = None
self.processed_file = PROCESSED_SITES_FILE
self.processed_data = self.load_processed_data()
self.sites_db = self.processed_data
self.current_project_path = None
self.current_project_name = "Untitled"
self.project_created_ts = utc_now_iso()
self.project_label_var = tk.StringVar(value="Project: Untitled")
self.autosave_enabled = tk.BooleanVar(value=bool(config.get("autosave_enabled", True)))
self.autosave_interval_minutes = tk.IntVar(value=int(config.get("autosave_interval_minutes", 2)))
self.autosave_worker = AutosaveWorker(self._autosave_now)
self.runner_tree = None
self.hydra_log = None
self.processing_thread = None
self.notebook = None
self.settings_window = None
self.runner_rows_all = []
self.runner_rows_view = []
self.runner_sort_state = {}
self.runner_last_sort_col = None
self.runner_active_process = None
self.runner_thread = None
self.runner_running = False
self.running_subprocesses = set()
# FIX: Guard cleanup/logging paths to prevent recursive shutdown loops.
self._cleaning_up = False
self._cleanup_log_emitted = False
self._build_ui()
self._build_menu()
self.root.after(100, self._drain_ui_queue)
self.root.after(500, self.refresh_runner_list) # slight delay to ensure widgets are ready
self.root.after(700, self.run_startup_checks)
self._schedule_autosave_tick()
self.root.protocol("WM_DELETE_WINDOW", self.on_exit)
# NEW: startup dependency checks for Hydra/Chromedriver/NordVPN/proxy
def run_startup_checks(self):
"""Run startup checks in the background so the UI stays responsive."""
if not bool(config.get("startup_dependency_checks", True)):
return
self.status_text.set("Running startup checks (Hydra, chromedriver, VPN, proxy, Tor)...")
self.record_event("INFO", "ui", "startup_check_begin", "Startup checks started", {"async": True})
results: queue.Queue[tuple[list[str], str]] = queue.Queue(maxsize=1)
def _worker():
issues = []
final_status = "Ready."
try:
hydra_status = ensure_hydra_available(log_func=self._write_log_threadsafe)
if not hydra_status.get("available"):
issues.append("Hydra unavailable (runner will not work)")
else:
self._write_log_threadsafe(f"Hydra check: {hydra_status.get('message')}")
driver_path = (config.get("chrome_driver_path") or "").strip()
if driver_path:
self._write_log_threadsafe(f"Chromedriver check: ready ({driver_path})")
else:
issues.append("Chromedriver path not initialized at startup")
if bool(config.get("auto_install_security_tools", False)):
burp_state = install_burp()
zap_state = install_zap()
self._write_log_threadsafe(f"Burp check: {burp_state.get('message', burp_state.get('path', 'not found'))}")
self._write_log_threadsafe(f"ZAP check: {zap_state.get('message', zap_state.get('path', 'not found'))}")
if get_vpn_control(config) == "nordvpn":
nord = ensure_nordvpn_cli(log_func=self._write_log_threadsafe)
if not nord.get("available"):
issues.append("NordVPN CLI missing (install required for vpn_control=nordvpn)")
if bool(config.get("enable_onion_processing", False)):
if is_tor_running():
self._write_log_threadsafe("Tor check: SOCKS proxy reachable on 127.0.0.1:9050")
else:
issues.append("Tor is required for .onion processing but is not running on 127.0.0.1:9050")
# FIXED: Proxy fallback + single chromedriver check
proxy_url = str(config.get("proxy_url", "")).strip()
if proxy_url:
proxy_cfg = {"http": proxy_url, "https": proxy_url}
try:
requests.get("https://httpbin.org/ip", proxies=proxy_cfg, timeout=5)
self._write_log_threadsafe("Proxy check: reachable via httpbin")
except Exception as proxy_exc:
config["proxy_url"] = ""
save_config()
issues.append("Configured proxy failed startup health check and was disabled")
self._write_log_threadsafe(f"[Proxy Fallback] Using direct connection ({proxy_exc})")
if issues:
final_status = f"Startup checks finished with {len(issues)} warning(s)."
else:
final_status = "Startup checks complete. Ready."
except Exception as exc:
issues.append(f"Startup checks failed: {exc}")
final_status = "Startup checks failed. See log for details."
results.put((issues, final_status))
def _poll_results():
try:
issues, final_status = results.get_nowait()
except queue.Empty:
self.root.after(200, _poll_results)
return
self.status_text.set(final_status)
if issues:
self.record_event("WARN", "ui", "startup_check", "Startup dependency warnings", {"count": len(issues)})
messagebox.showwarning("Startup checks", "\n".join(issues))
else:
self.record_event("INFO", "ui", "startup_check", "Startup dependency checks passed")
threading.Thread(target=_worker, name="gui-startup-checks", daemon=True).start()
self.root.after(200, _poll_results)
def register_running_process(self, process):
if process:
self.running_subprocesses.add(process)
def unregister_running_process(self, process):
if process and process in self.running_subprocesses:
self.running_subprocesses.remove(process)
def terminate_all_running_processes(self, reason):
# FIX: Re-entrancy guard to stop recursive terminate/log loops on close/cancel.
self._cleaning_up = getattr(self, '_cleaning_up', False)
if self._cleaning_up:
return
self._cleaning_up = True
try:
for proc in list(self.running_subprocesses):
try:
if proc.poll() is None:
proc.terminate()
time.sleep(0.5)
if proc.poll() is None:
proc.kill()
except Exception:
pass
finally:
self.unregister_running_process(proc)
if self.gost_process:
try:
if self.gost_process.poll() is None:
self.gost_process.terminate()
time.sleep(0.2)
if self.gost_process.poll() is None:
self.gost_process.kill()
except Exception:
pass
finally:
self.gost_process = None
if self.tor_process:
try:
stop_tor()
except Exception:
pass
finally:
self.tor_process = None
if not self._cleanup_log_emitted:
self._cleanup_log_emitted = True
try:
self._write_log_threadsafe(f"Terminated subprocesses: {reason}")
except Exception:
# FIX: Avoid recursive logging failures during teardown.
print(f"[cleanup] Terminated subprocesses: {reason}")
finally:
self._cleaning_up = False
def load_processed_data(self):
legacy_file = Path(__file__).resolve().parent / "processed_sites.json"
if legacy_file.exists() and not self.processed_file.exists():
try:
shutil.copy2(legacy_file, self.processed_file)
migrated_count = len(json.loads(self.processed_file.read_text(encoding="utf-8")) or {})
self.record_event("INFO", "cache", "migrate", "Cache migrated (root -> DATA_DIR)", {"site_count": migrated_count})
except Exception:
pass
if self.processed_file.exists():
try:
raw = json.loads(self.processed_file.read_text(encoding='utf-8'))
migrated = self._migrate_processed_schema(raw)
self.record_event("INFO", "cache", "load", "Cache loaded", {"site_count": len(migrated)})
return migrated
except Exception:
return {}
return {}
def save_processed_data(self):
self.processed_file.write_text(json.dumps(self.processed_data, indent=2), encoding='utf-8')
def record_event(self, level, category, action, message, metrics=None, allow_coalesce=True):
if hasattr(self, "_main_thread") and threading.current_thread() is not self._main_thread:
self.ui_queue.put(("timeline_event", {
"level": level,
"category": category,
"action": action,
"message": message,
"metrics": metrics,
"allow_coalesce": allow_coalesce,
}))
return
event = make_event(level, category, action, message, metrics=metrics)
self.timeline_events.append(event)
if allow_coalesce and event["level"] in {"WARN", "ERROR"}:
self._record_coalesced_summary(event)
if hasattr(self, "timeline_tree"):
self.refresh_timeline_view()
def _record_coalesced_summary(self, event):
key = (event.get("category"), event.get("action"), event.get("level"))
now = time.time()
bucket = [ts for ts in self.timeline_coalesce.get(key, []) if now - ts <= 300]
bucket.append(now)
self.timeline_coalesce[key] = bucket
last_summary = self.timeline_coalesce_last_summary.get(key, 0.0)
if len(bucket) >= 6 and (now - last_summary) >= 60:
self.record_event(
"WARN",
event.get("category", "network"),
"summary",
f"{event.get('action')} x{len(bucket)} in last 5m",
metrics={"count": len(bucket), "window_minutes": 5},
allow_coalesce=False,
)
self.timeline_coalesce_last_summary[key] = now
self.timeline_coalesce[key] = []
def _timeline_known_categories(self):
default = ["project", "run", "ui", "network", "cache", "export", "proxy", "dns", "tls"]
observed = sorted({str((e or {}).get("category") or "") for e in self.timeline_events if (e or {}).get("category")})
return ["All"] + sorted(set(default + observed))
def _build_menu(self):
menu_bar = tk.Menu(self.root)
file_menu = tk.Menu(menu_bar, tearoff=0)
file_menu.add_command(label="New Project", command=self.new_project)
file_menu.add_command(label="Open Project", command=self.open_project)
file_menu.add_command(label="Save Project", command=self.save_project)
file_menu.add_command(label="Save Project As", command=lambda: self.save_project(as_new=True))
export_menu = tk.Menu(file_menu, tearoff=0)
export_menu.add_command(label="JSON", command=self.export_report_json)
export_menu.add_command(label="CSV", command=self.export_report_csv)
export_menu.add_command(label="Run Summaries CSV", command=self.export_run_summaries_csv)
export_menu.add_command(label="Timeline CSV", command=self.export_timeline_csv)
file_menu.add_cascade(label="Export", menu=export_menu)
file_menu.add_separator()
file_menu.add_command(label="Exit", command=self.on_exit)
menu_bar.add_cascade(label="File", menu=file_menu)
self.root.config(menu=menu_bar)
def _migrate_processed_schema(self, raw):
migrated = {}
for site, entry in (raw or {}).items():
if not isinstance(entry, dict):
entry = {}
extracted = entry.get("extracted") or {}
if not extracted and entry.get("form_found"):
extracted = {
"action_url": entry.get("action") or entry.get("hydra_action"),
"confidence": entry.get("confidence"),
}
status = entry.get("status")
if not status:
if entry.get("form_found"):
status = "success"
elif entry.get("failed_urls"):
status = "fetch_failed"
else:
status = "pending"
migrated[site] = {
"first_seen_ts": entry.get("first_seen_ts") or entry.get("last_processed") or datetime.now().isoformat(),
"last_checked_ts": entry.get("last_checked_ts") or entry.get("last_processed"),
"status": status,
"extracted": extracted,
"last_error_code": entry.get("last_error_code"),
"last_error_hint": entry.get("last_error_hint"),
"last_error_detail": entry.get("last_error_detail") or entry.get("last_error_message"),
"last_error_stacktrace": entry.get("last_error_stacktrace"),
"combo_count": entry.get("combo_count", 0),
"combo_path": entry.get("combo_path", ""),
"hydra_command_template": entry.get("hydra_command_template", ""),
"form_found": bool(entry.get("form_found")),
}
return migrated
def _is_cache_fresh(self, entry, ttl_days):
checked = entry.get("last_checked_ts")
if not checked:
return False
try:
checked_dt = datetime.fromisoformat(checked)
except Exception:
return False
return (datetime.now() - checked_dt) <= timedelta(days=ttl_days)
def _cache_skip_reason(self, base, retry_failed_only=False):
if self.force_recheck.get():
return None
entry = self.processed_data.get(base) or {}
status = entry.get("status")
if retry_failed_only:
if status not in {"fetch_failed", "failed"}:
return "not failed"
return None
failed_ttl_days = int(config.get("failed_retry_ttl_days", 1))
if status in {"fetch_failed", "failed"} and self._is_cache_fresh(entry, failed_ttl_days):
return "recent fetch failure"
ttl_days = int(config.get("cache_ttl_days", 30))
if status in {"success", "success_form", "success_loginish", "no_form"} and self._is_cache_fresh(entry, ttl_days):
if status in {"success", "success_form"} and not (entry.get("extracted") or {}).get("action_url"):
return None
return "already cached"
return None
def _write_log_threadsafe(self, text):
# FIX: Avoid recursive UI/log churn while shutdown cleanup is active.
if getattr(self, "_cleaning_up", False) and text.startswith("Terminated subprocesses:") and self._cleanup_log_emitted:
print(f"[cleanup-log] {text}")
return
if self.extract_log_file:
with self.extract_log_file.open("a", encoding="utf-8") as fh:
fh.write(text + "\n")
write_detailed_log(text, "INFO")
write_privacy_log(text, "INFO")
self.ui_queue.put(("extractor_log", text + "\n"))
def _update_status_threadsafe(self, text):
self.ui_queue.put(("status", text))
def _update_progress_threadsafe(self, mode=None, maximum=None, value=None, stop=False):
self.ui_queue.put(("progress", {"mode": mode, "maximum": maximum, "value": value, "stop": stop}))
def _show_progress_threadsafe(self, show):
self.ui_queue.put(("progress_visible", bool(show)))
def _drain_ui_queue(self):
while True:
try:
event, payload = self.ui_queue.get_nowait()
except queue.Empty:
break
if event == "extractor_log":
self.log.insert(tk.END, payload)
self.log.see(tk.END)
elif event == "hydra_log":
self.hydra_log.insert(tk.END, payload)
self.hydra_log.see(tk.END)
if self.runner_log_file:
with self.runner_log_file.open("a", encoding="utf-8") as fh:
fh.write(payload)
elif event == "status":
self.status_text.set(payload)
elif event == "runner_hit":
hit = payload or {}
if hasattr(self, "hits_tree") and self.hits_tree is not None:
self.hits_tree.insert("", "end", values=(hit.get("domain", ""), hit.get("username", ""), hit.get("password", ""), hit.get("timestamp", "")))
elif event == "progress":
if payload["mode"] is not None:
self.progress["mode"] = payload["mode"]
if payload["maximum"] is not None:
self.progress["maximum"] = payload["maximum"]
if payload["value"] is not None:
self.progress["value"] = payload["value"]
if payload["stop"]:
self.progress.stop()
elif event == "progress_visible":
if payload:
self.progress.grid()
else:
self.progress.grid_remove()
elif event == "pipeline_done":
self.cleanup_after_pipeline(payload)
elif event == "runner_done":
self.finish_runner_execution(payload)
elif event == "runner_refresh":
self.apply_runner_filters_and_sort()
elif event == "critical_error":
messagebox.showerror("Error", payload)
elif event == "timeline_event":
self.record_event(
payload.get("level"),
payload.get("category"),
payload.get("action"),
payload.get("message"),
metrics=payload.get("metrics"),
allow_coalesce=bool(payload.get("allow_coalesce", True)),
)
self.root.after(100, self._drain_ui_queue)
def _build_ui(self):
self.root.columnconfigure(0, weight=1)
self.root.rowconfigure(0, weight=1)
container = ttk.Frame(self.root, padding=8)
container.grid(row=0, column=0, sticky="nsew")
container.columnconfigure(0, weight=1)
container.rowconfigure(0, weight=1)
container.rowconfigure(1, weight=0)
notebook = ttk.Notebook(container)
self.notebook = notebook
notebook.grid(row=0, column=0, sticky="nsew")
extractor_tab = ttk.Frame(notebook)
notebook.add(extractor_tab, text="Extractor")
runner_tab = ttk.Frame(notebook)
notebook.add(runner_tab, text="Hydra Runner")
burp_tab = ttk.Frame(notebook)
notebook.add(burp_tab, text="Burp Tester")
zap_tab = ttk.Frame(notebook)
notebook.add(zap_tab, text="ZAP Tester")
tools_tab = ttk.Frame(notebook)
notebook.add(tools_tab, text="Tools")
troubleshooting_tab = ttk.Frame(notebook)
notebook.add(troubleshooting_tab, text="Troubleshooting")
timeline_tab = ttk.Frame(notebook)
notebook.add(timeline_tab, text="Timeline")
self.build_extractor_tab(extractor_tab)
self.build_runner_tab(runner_tab)
self.build_burp_tab(burp_tab)
self.build_zap_tab(zap_tab)
self.build_tools_tab(tools_tab)
self.build_troubleshooting_tab(troubleshooting_tab)
self.build_timeline_tab(timeline_tab)
status_bar = ttk.Frame(container, padding=(8, 4))
status_bar.grid(row=1, column=0, sticky="ew")
status_bar.columnconfigure(0, weight=1)
ttk.Label(status_bar, textvariable=self.status_text).grid(row=0, column=0, sticky="w")
ttk.Label(status_bar, textvariable=self.project_label_var).grid(row=0, column=1, sticky="e", padx=(4, 20))
ttk.Label(status_bar, textvariable=self.state_text).grid(row=0, column=2, sticky="e")
def on_tab_changed(event):
selected_tab = notebook.select()
if selected_tab == notebook.tabs()[1]:
try:
self.refresh_runner_list()
except AttributeError:
pass
notebook.bind("<<NotebookTabChanged>>", on_tab_changed)
def _bind_scroll_wheel(self, widget, y_target=None, x_target=None):
y_target = y_target or widget
x_target = x_target or widget
def _scroll_vertical(units):
y_target.yview_scroll(units, "units")
return "break"
def _scroll_horizontal(units):
x_target.xview_scroll(units, "units")
return "break"
system = platform.system()
if system in {"Windows", "Darwin"}:
def on_mousewheel(event):
delta = event.delta
if system == "Darwin":
units = -1 if delta > 0 else 1
else:
units = int(-1 * (delta / 120)) if delta else 0
if units:
return _scroll_vertical(units)
def on_shift_mousewheel(event):
delta = event.delta
if system == "Darwin":
units = -1 if delta > 0 else 1
else:
units = int(-1 * (delta / 120)) if delta else 0
if units:
return _scroll_horizontal(units)
widget.bind("<MouseWheel>", on_mousewheel, add="+")
widget.bind("<Shift-MouseWheel>", on_shift_mousewheel, add="+")
else:
widget.bind("<Button-4>", lambda _e: _scroll_vertical(-1), add="+")
widget.bind("<Button-5>", lambda _e: _scroll_vertical(1), add="+")
widget.bind("<Shift-Button-4>", lambda _e: _scroll_horizontal(-1), add="+")
widget.bind("<Shift-Button-5>", lambda _e: _scroll_horizontal(1), add="+")
def build_extractor_tab(self, tab):
tab.columnconfigure(0, weight=1)
tab.rowconfigure(0, weight=1)
main = ttk.Frame(tab, padding=12)
main.grid(row=0, column=0, sticky="nsew")
main.columnconfigure(0, weight=1)
main.rowconfigure(4, weight=1)
ttk.Label(main, text="Combo Parser + Advanced Form Extractor", style="Header.TLabel").grid(row=0, column=0, sticky="w", pady=(0, 8))
io_grid = ttk.Frame(main)
io_grid.grid(row=1, column=0, sticky="ew", pady=(0, 8))
for idx in range(3):
io_grid.columnconfigure(idx, weight=1)
inp_f = ttk.LabelFrame(io_grid, text="Input (file or folder)")
inp_f.grid(row=0, column=0, sticky="nsew", padx=(0, 8))
inp_f.columnconfigure(0, weight=1)
ttk.Entry(inp_f, textvariable=self.input_path).grid(row=0, column=0, sticky="ew", padx=(0, 8))
ttk.Button(inp_f, text="File", command=self.choose_input_file).grid(row=0, column=1, padx=(0, 4))
ttk.Button(inp_f, text="Folder", command=self.choose_input_folder).grid(row=0, column=2)
out_f = ttk.LabelFrame(io_grid, text="Main CSV Output")
out_f.grid(row=0, column=1, sticky="nsew", padx=4)
out_f.columnconfigure(0, weight=1)
ttk.Entry(out_f, textvariable=self.output_path).grid(row=0, column=0, sticky="ew", padx=(0, 8))
ttk.Button(out_f, text="Save As", command=self.choose_output_file).grid(row=0, column=1)
forms_f = ttk.LabelFrame(io_grid, text="Hydra Forms CSV")
forms_f.grid(row=0, column=2, sticky="nsew", padx=(8, 0))
forms_f.columnconfigure(0, weight=1)
ttk.Entry(forms_f, textvariable=self.forms_output_path).grid(row=0, column=0, sticky="ew", padx=(0, 8))
ttk.Button(forms_f, text="Save As", command=self.choose_forms_output_file).grid(row=0, column=1)
mid_grid = ttk.Frame(main)
mid_grid.grid(row=2, column=0, sticky="ew", pady=(0, 8))
for idx in range(3):
mid_grid.columnconfigure(idx, weight=1)
head_f = ttk.LabelFrame(mid_grid, text="CSV Headers")
head_f.grid(row=0, column=0, sticky="nsew", padx=(0, 8))
for i, txt, var in zip(range(3), ["Column 1 (site)", "Column 2 (user)", "Column 3 (pass)"], [self.header1, self.header2, self.header3]):
ttk.Label(head_f, text=txt).grid(row=i, column=0, sticky="w", padx=(0, 6), pady=4)
ttk.Entry(head_f, textvariable=var, width=40).grid(row=i, column=1, sticky="ew", pady=4)
head_f.columnconfigure(1, weight=1)
opt_f = ttk.LabelFrame(mid_grid, text="Options")
opt_f.grid(row=0, column=1, sticky="nsew", padx=4)
ttk.Checkbutton(opt_f, text="Skip blank lines", variable=self.skip_blank).pack(anchor="w")
ttk.Checkbutton(opt_f, text="Trim whitespace", variable=self.trim_whitespace).pack(anchor="w")
ttk.Checkbutton(opt_f, text="Create user:pass combo.txt per site", variable=self.create_combo).pack(anchor="w", pady=4)
ttk.Checkbutton(opt_f, text="Extract login forms", variable=self.extract_forms).pack(anchor="w", pady=4)
ttk.Checkbutton(opt_f, text="Strict form validation", variable=self.strict_validation).pack(anchor="w", pady=4)
ttk.Checkbutton(opt_f, text="Use Playwright dynamic rendering fallback", variable=self.use_playwright_dynamic).pack(anchor="w", pady=4)
ttk.Checkbutton(opt_f, text="Advanced extraction mode (deeper login discovery)", variable=self.advanced_extraction_mode).pack(anchor="w", pady=4)
ttk.Checkbutton(opt_f, text="Force recheck (ignore cache TTL)", variable=self.force_recheck).pack(anchor="w", pady=4)
ttk.Checkbutton(opt_f, text="Show debug details", variable=self.show_debug_details).pack(anchor="w", pady=4)
proxy_f = ttk.LabelFrame(mid_grid, text="Proxy / VPN (NordVPN Auto)")
proxy_f.grid(row=0, column=2, sticky="nsew", padx=(8, 0))
ttk.Label(proxy_f, text="VPN behavior is controlled by Settings → vpn_control").pack(anchor="w")
ttk.Label(proxy_f, text="Use proxy_url for an already-running SOCKS/HTTP proxy").pack(anchor="w")
thread_f = ttk.LabelFrame(main, text="Extraction Speed")
thread_f.grid(row=3, column=0, sticky="ew", pady=(0, 8))
thread_f.columnconfigure(0, weight=1)
ttk.Label(thread_f, text="Threads (4-8 recommended):").grid(row=0, column=0, sticky="w")
ttk.Scale(thread_f, from_=1, to=12, orient="horizontal", variable=self.threads, command=lambda v: self.threads.set(int(round(float(v))))).grid(row=1, column=0, sticky="ew", padx=8)
ttk.Label(thread_f, textvariable=self.threads).grid(row=0, column=1, rowspan=2, sticky="e", padx=(8, 0))
action_row = ttk.Frame(main)
action_row.grid(row=4, column=0, sticky="nsew")
action_row.columnconfigure(0, weight=1)
action_row.rowconfigure(2, weight=1)
btn_f = ttk.Frame(action_row)
btn_f.grid(row=0, column=0, sticky="e", pady=(0, 8))
self.start_button = ttk.Button(btn_f, text="Start Pipeline", command=self.start_pipeline)
self.start_button.pack(side="left", padx=4)
self.pause_button = ttk.Button(btn_f, text="Pause", command=self.toggle_pause, state="disabled")
self.pause_button.pack(side="left", padx=4)
self.cancel_button = ttk.Button(btn_f, text="Cancel", command=self.cancel_pipeline, state="disabled")
self.cancel_button.pack(side="left", padx=(12, 4))
self.retry_button = ttk.Button(btn_f, text="Resume Failed", command=self.resume_failed)
self.retry_button.pack(side="left", padx=4)
ttk.Button(btn_f, text="Settings", command=self.open_settings).pack(side="left", padx=4)
ttk.Button(btn_f, text="Test Credentials (Selected Site)", command=self.on_test_credentials_selected).pack(side="left", padx=4)
ttk.Button(btn_f, text="Clear Log", command=self.clear_log).pack(side="left", padx=4)
self.progress = ttk.Progressbar(action_row, orient="horizontal", mode="determinate")
self.progress.grid(row=1, column=0, sticky="ew", pady=(0, 8))
self.progress.grid_remove()
log_f = ttk.LabelFrame(action_row, text="Extraction Log")
log_f.grid(row=2, column=0, sticky="nsew")
log_f.columnconfigure(0, weight=1)
log_f.rowconfigure(0, weight=1)
self.log = tk.Text(log_f, height=18, wrap="none", font=("Consolas", 10), padx=8, pady=8)
self.log.grid(row=0, column=0, sticky="nsew")
log_y = ttk.Scrollbar(log_f, orient="vertical", command=self.log.yview)
log_y.grid(row=0, column=1, sticky="ns")
log_x = ttk.Scrollbar(log_f, orient="horizontal", command=self.log.xview)
log_x.grid(row=1, column=0, sticky="ew")
self.log.configure(yscrollcommand=log_y.set, xscrollcommand=log_x.set)
self._bind_scroll_wheel(self.log)
def on_test_credentials_selected(self):
if not self.runner_rows_all:
self.refresh_runner_list()
selected = [r.get("site") for r in self.runner_rows_all if r.get("selected")]
if not selected:
messagebox.showinfo("Credential Test", "Select a site in Hydra Runner first.")
return
site = selected[0]
pdata = (self.processed_data or {}).get(site) or {}
extracted = pdata.get("extracted") or {}
combo_path = pdata.get("combo_path")
if not combo_path or not Path(combo_path).exists():
messagebox.showerror("Credential Test", f"Combo file missing for {site}")
return
combos = [ln.strip() for ln in Path(combo_path).read_text(encoding="utf-8", errors="replace").splitlines() if ln.strip()]
result = test_credentials_for_site(extracted, combos)
messagebox.showinfo("Credential Test", f"{site}: hits={result.get('hits',0)} status={result.get('status')}")
def open_settings(self):
if self.settings_window and self.settings_window.winfo_exists():
if self.settings_window.state() == "iconic":
self.settings_window.deiconify()
self.settings_window.lift()
self.settings_window.focus_force()
return
settings_window = tk.Toplevel(self.root)
self.settings_window = settings_window
settings_window.title("Settings")
settings_window.geometry("760x760")
settings_window.minsize(640, 520)
settings_window.protocol("WM_DELETE_WINDOW", self._close_settings_window)
outer = ttk.Frame(settings_window)
outer.pack(fill="both", expand=True)
canvas = tk.Canvas(outer, highlightthickness=0)
canvas.pack(side="left", fill="both", expand=True)
y_scroll = ttk.Scrollbar(outer, orient="vertical", command=canvas.yview)
y_scroll.pack(side="right", fill="y")
canvas.configure(yscrollcommand=y_scroll.set)
content = ttk.Frame(canvas, padding=12)
content_window = canvas.create_window((0, 0), window=content, anchor="nw")
def _refresh_scroll_region(_event=None):
canvas.configure(scrollregion=canvas.bbox("all"))
def _sync_content_width(event):
canvas.itemconfigure(content_window, width=event.width)
content.bind("<Configure>", _refresh_scroll_region)
canvas.bind("<Configure>", _sync_content_width)
self._bind_scroll_wheel(canvas, y_target=canvas)
self._bind_scroll_wheel(content, y_target=canvas)
creds_frame = ttk.LabelFrame(content, text="Credential & API Settings")
creds_frame.pack(fill="x", padx=6, pady=(0, 8))
ttk.Label(creds_frame, text="DeathByCaptcha Username").pack(anchor="w", padx=10, pady=(8, 2))
self.dbc_user = tk.StringVar(value=config.get("dbc_user", ""))
ttk.Entry(creds_frame, textvariable=self.dbc_user).pack(fill="x", padx=10, pady=(0, 8))
ttk.Label(creds_frame, text="DeathByCaptcha Password").pack(anchor="w", padx=10, pady=(0, 2))
self.dbc_pass = tk.StringVar(value=config.get("dbc_pass", ""))
ttk.Entry(creds_frame, textvariable=self.dbc_pass, show="*").pack(fill="x", padx=10, pady=(0, 8))
ttk.Label(creds_frame, text="NordVPN Token").pack(anchor="w", padx=10, pady=(0, 2))
self.nord_token = tk.StringVar(value=config.get("nord_token", ""))
ttk.Entry(creds_frame, textvariable=self.nord_token).pack(fill="x", padx=10, pady=(0, 8))
ttk.Label(creds_frame, text="2Captcha API Key (optional)").pack(anchor="w", padx=10, pady=(0, 2))
self.twocaptcha_key = tk.StringVar(value=config.get("twocaptcha_key", ""))
ttk.Entry(creds_frame, textvariable=self.twocaptcha_key).pack(padx=10, pady=(0, 8), fill="x")
ttk.Label(creds_frame, text="Anti-Captcha API Key (optional)").pack(anchor="w", padx=10, pady=(0, 2))
self.anticaptcha_key = tk.StringVar(value=config.get("anticaptcha_key", ""))
ttk.Entry(creds_frame, textvariable=self.anticaptcha_key).pack(padx=10, pady=(0, 8), fill="x")
ttk.Label(creds_frame, text="Capsolver API Key (optional)").pack(anchor="w", padx=10, pady=(0, 2))
self.capsolver_key = tk.StringVar(value=config.get("capsolver_key", ""))
ttk.Entry(creds_frame, textvariable=self.capsolver_key).pack(padx=10, pady=(0, 10), fill="x")
network_frame = ttk.LabelFrame(content, text="Network & Cache")
network_frame.pack(fill="x", padx=6, pady=8)
ttk.Label(network_frame, text="VPN Control").pack(anchor="w", padx=10, pady=(8, 2))
self.vpn_control = tk.StringVar(value=get_vpn_control(config))
ttk.Combobox(network_frame, textvariable=self.vpn_control, values=["none", "nordvpn"], state="readonly").pack(fill="x", padx=10, pady=(0, 8))
ttk.Label(network_frame, text="Proxy URL (optional, socks5/http)").pack(anchor="w", padx=10, pady=(0, 2))
self.proxy_url_setting = tk.StringVar(value=config.get("proxy_url", ""))
ttk.Entry(network_frame, textvariable=self.proxy_url_setting).pack(fill="x", padx=10, pady=(0, 8))
ttk.Label(network_frame, text="WSL Username (optional, for Hydra over WSL)").pack(anchor="w", padx=10, pady=(0, 2))
self.wsl_username = tk.StringVar(value=config.get("wsl_username", ""))
ttk.Entry(network_frame, textvariable=self.wsl_username).pack(fill="x", padx=10, pady=(0, 8))
ttk.Label(network_frame, text="WSL Password (optional, used for sudo install)").pack(anchor="w", padx=10, pady=(0, 2))
self.wsl_password = tk.StringVar(value=config.get("wsl_password", ""))
ttk.Entry(network_frame, textvariable=self.wsl_password, show="*").pack(fill="x", padx=10, pady=(0, 8))
self.proxy_required = tk.BooleanVar(value=bool(config.get("proxy_required", False)))
ttk.Checkbutton(network_frame, text="Require proxy (fail fast if unreachable)", variable=self.proxy_required).pack(anchor="w", padx=10, pady=3)
self.allow_nonstandard_ports = tk.BooleanVar(value=bool(config.get("allow_nonstandard_ports", False)))
ttk.Checkbutton(network_frame, text="Allow nonstandard ports during extraction", variable=self.allow_nonstandard_ports).pack(anchor="w", padx=10, pady=3)
ttk.Label(network_frame, text="Cache TTL days (success/no form)").pack(anchor="w", padx=10, pady=(6, 2))
self.cache_ttl_days = tk.IntVar(value=int(config.get("cache_ttl_days", 30)))
ttk.Entry(network_frame, textvariable=self.cache_ttl_days).pack(fill="x", padx=10, pady=(0, 8))
ttk.Label(network_frame, text="Retry TTL days (fetch failures)").pack(anchor="w", padx=10, pady=(0, 2))
self.failed_retry_ttl_days = tk.IntVar(value=int(config.get("failed_retry_ttl_days", 1)))
ttk.Entry(network_frame, textvariable=self.failed_retry_ttl_days).pack(fill="x", padx=10, pady=(0, 8))
ttk.Label(network_frame, text="Extraction timeout per site (seconds)").pack(anchor="w", padx=10, pady=(0, 2))
self.extract_site_timeout_seconds = tk.IntVar(value=int(config.get("extract_site_timeout_seconds", 300)))
ttk.Spinbox(network_frame, from_=30, to=900, textvariable=self.extract_site_timeout_seconds).pack(fill="x", padx=10, pady=(0, 10))
behavior_frame = ttk.LabelFrame(content, text="Behavior & Autosave")
behavior_frame.pack(fill="x", padx=6, pady=8)
self.debug_logging = tk.BooleanVar(value=bool(config.get("debug_logging", False)))
ttk.Checkbutton(behavior_frame, text="Enable debug logging", variable=self.debug_logging).pack(anchor="w", padx=10, pady=(8, 3))
self.autosave_enabled_setting = tk.BooleanVar(value=self.autosave_enabled.get())
ttk.Checkbutton(behavior_frame, text="Enable autosave for project files", variable=self.autosave_enabled_setting).pack(anchor="w", padx=10, pady=3)
ttk.Label(behavior_frame, text="Autosave interval (minutes)").pack(anchor="w", padx=10, pady=(6, 2))
self.autosave_interval_setting = tk.IntVar(value=self.autosave_interval_minutes.get())
ttk.Entry(behavior_frame, textvariable=self.autosave_interval_setting).pack(fill="x", padx=10, pady=(0, 10))
# FIXED: User-facing Windows Security exclusions guidance + gated action button
defender_frame = ttk.LabelFrame(content, text="Windows Security Exclusions")
defender_frame.pack(fill="x", padx=6, pady=8)
ttk.Label(
defender_frame,
text=(
"False positives common with headless browsers/proxies. Excluding folders prevents AV killing connections."
),
justify="left",
).pack(anchor="w", padx=10, pady=(8, 4))
ttk.Label(
defender_frame,
text="Only do this if needed; exclusions weaken AV protection.",
justify="left",
).pack(anchor="w", padx=10, pady=(0, 6))
self.defender_exclusions_ack = tk.BooleanVar(value=bool(config.get("defender_exclusions_ack", False)))
ttk.Checkbutton(
defender_frame,
text="I understand risks (exclusions weaken AV protection)",
variable=self.defender_exclusions_ack,
).pack(anchor="w", padx=10, pady=(0, 6))
self.exclusions_button = ttk.Button(defender_frame, text="Add Exclusions Now?", command=self.create_windows_exclusions, state="disabled")
self.exclusions_button.pack(anchor="w", padx=10, pady=(0, 10))
self.defender_exclusions_ack.trace_add("write", self._toggle_exclusions_button)
self._toggle_exclusions_button()
proxy_rotation_frame = ttk.LabelFrame(content, text="Proxy Routing")
proxy_rotation_frame.pack(fill="x", padx=6, pady=8)
ttk.Label(proxy_rotation_frame, text="Burp Proxy (optional, e.g. http://127.0.0.1:8080)").pack(anchor="w", padx=10, pady=(8, 2))
self.burp_proxy = tk.StringVar(value=config.get("burp_proxy", ""))
ttk.Entry(proxy_rotation_frame, textvariable=self.burp_proxy).pack(fill="x", padx=10, pady=(0, 8))
ttk.Checkbutton(proxy_rotation_frame, text="Enable Burp Proxy", variable=self.use_burp).pack(anchor="w", padx=10, pady=3)
ttk.Label(proxy_rotation_frame, text="ZAP Proxy (optional, e.g. http://127.0.0.1:8080)").pack(anchor="w", padx=10, pady=(8, 2))
self.zap_proxy = tk.StringVar(value=config.get("zap_proxy", "http://127.0.0.1:8080"))
ttk.Entry(proxy_rotation_frame, textvariable=self.zap_proxy).pack(fill="x", padx=10, pady=(0, 6))
ttk.Checkbutton(proxy_rotation_frame, text="Enable ZAP Proxy", variable=self.use_zap).pack(anchor="w", padx=10, pady=3)
ttk.Label(proxy_rotation_frame, text="ZAP API Key (optional)").pack(anchor="w", padx=10, pady=(6, 2))
ttk.Entry(proxy_rotation_frame, textvariable=self.zap_api_key).pack(fill="x", padx=10, pady=(0, 6))
ttk.Checkbutton(proxy_rotation_frame, text="Auto-start ZAP daemon", variable=self.auto_start_zap_daemon).pack(anchor="w", padx=10, pady=3)
ttk.Checkbutton(proxy_rotation_frame, text="Enable proxy rotation", variable=self.proxy_rotation).pack(anchor="w", padx=10, pady=3)
ttk.Label(proxy_rotation_frame, text="Proxy list file (one proxy per line)").pack(anchor="w", padx=10, pady=(6, 2))
proxy_file_row = ttk.Frame(proxy_rotation_frame)
proxy_file_row.pack(fill="x", padx=10, pady=(0, 10))
ttk.Entry(proxy_file_row, textvariable=self.proxy_list_file).pack(side="left", fill="x", expand=True)
ttk.Button(proxy_file_row, text="Browse", command=self.choose_proxy_list_file).pack(side="left", padx=(8, 0))
tor_frame = CollapsibleFrame(content, "Tor / Onion Support")
tor_frame.pack(fill="x", padx=6, pady=8)
self.onion_managed_widgets = []
onion_enable = ttk.Checkbutton(tor_frame.body, text="Enable .onion processing", variable=self.enable_onion_processing, command=self.update_onion_settings_state)
onion_enable.pack(anchor="w", padx=10, pady=(8, 4))
ToolTip(onion_enable, "When disabled, every .onion URL is skipped entirely during parsing and extraction.")
nord_status = ensure_nordvpn_cli(log_func=None)
nord_groups = check_nordvpn_onion_support(log_func=None) if nord_status.get("available") else {"ok": False}
self.nordvpn_onion_check = ttk.Checkbutton(tor_frame.body, text="Use NordVPN Onion-over-VPN for .onion sites only", variable=self.use_nordvpn_onion_only)
self.nordvpn_onion_check.pack(anchor="w", padx=10, pady=4)
ToolTip(self.nordvpn_onion_check, "Before onion extraction, run nordvpn connect --group Onion and restore the previous route afterwards.")
self.onion_managed_widgets.append(self.nordvpn_onion_check)
if not (nord_status.get("available") and nord_groups.get("ok")):
self.nordvpn_onion_check.configure(state="disabled")
random_ua_check = ttk.Checkbutton(tor_frame.body, text="Random User-Agent on every request", variable=self.random_user_agent)
random_ua_check.pack(anchor="w", padx=10, pady=4)
ToolTip(random_ua_check, "Rotate to a different realistic User-Agent for each request when the configured scope matches the target.")
self.onion_managed_widgets.append(random_ua_check)
ttk.Label(tor_frame.body, text="Pre-configured User-Agent").pack(anchor="w", padx=10, pady=(8, 2))
self.user_agent_dropdown = ttk.Combobox(tor_frame.body, textvariable=self.selected_user_agent, values=self.user_agent_library, state="readonly")
self.user_agent_dropdown.pack(fill="x", padx=10, pady=(0, 8))
ToolTip(self.user_agent_dropdown, "Choose the default browser identity to use when random rotation is disabled for the target scope.")
self.onion_managed_widgets.append(self.user_agent_dropdown)