-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsqlmap_gui.py
More file actions
3063 lines (2545 loc) · 118 KB
/
sqlmap_gui.py
File metadata and controls
3063 lines (2545 loc) · 118 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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
SQLMap 中文图形化界面
版本: 2.2.0
支持完整的sqlmap功能,包括os-shell、文件操作、注册表、二阶注入、DNS泄露、MSF集成等深度功能
"""
import os
import sys
import re
import json
import random
import subprocess
import warnings
from datetime import datetime
from pathlib import Path
from typing import Optional, List, Dict
warnings.filterwarnings("ignore", category=DeprecationWarning)
from PyQt5.QtCore import Qt, QThread, pyqtSignal, QSize, QTimer
from PyQt5.QtWidgets import (
QApplication, QMainWindow, QWidget, QVBoxLayout, QHBoxLayout,
QTabWidget, QLabel, QLineEdit, QPushButton, QCheckBox, QComboBox,
QTextEdit, QPlainTextEdit, QGroupBox, QRadioButton, QButtonGroup,
QSplitter, QFileDialog, QMessageBox, QDialog, QTableWidget,
QTableWidgetItem, QHeaderView, QProgressBar, QStatusBar, QToolBar,
QAction, QSpinBox, QFormLayout, QScrollArea, QGridLayout,
QInputDialog, QSizePolicy
)
from PyQt5.QtGui import QFont, QColor, QTextCharFormat, QSyntaxHighlighter, QTextCursor, QPixmap, QImage, QDesktopServices
from PyQt5.QtCore import QRegularExpression, QUrl
VERSION = "2.2.0"
APP_DIR = Path(__file__).parent.resolve()
LOGS_DIR = APP_DIR / "logs"
CONFIG_FILE = APP_DIR / "data" / "gui_config.json"
LOGS_DIR.mkdir(exist_ok=True)
class SqlmapHighlighter(QSyntaxHighlighter):
def __init__(self, parent=None):
super().__init__(parent)
self.highlightingRules = []
formats = [
(r"\[CRITICAL\].*|\[ERROR\].*|\[严重\].*|\[错误\].*", "#FF0000", True),
(r"\[WARNING\].*|\[警告\].*", "#FFA500", False),
(r"\[INFO\].*|\[信息\].*", "#00AA00", False),
(r"\[DEBUG\].*|\[调试\].*", "#0000FF", False),
(r"\[PAYLOAD\].*|\[\*\].*|\[载荷\].*|\[发现\].*", "#800080", True),
(r"sql-shell|os-shell|os-pwn|os-cmd", "#0066CC", True),
]
for pattern, color, bold in formats:
fmt = QTextCharFormat()
fmt.setForeground(QColor(color))
if bold:
fmt.setFontWeight(QFont.Bold)
self.highlightingRules.append((QRegularExpression(pattern), fmt))
def highlightBlock(self, text):
for pattern, fmt in self.highlightingRules:
match = pattern.match(text)
if match.hasMatch():
self.setFormat(match.capturedStart(), match.capturedLength(), fmt)
class CommandThread(QThread):
output_ready = pyqtSignal(str)
command_finished = pyqtSignal(int)
def __init__(self, parent=None):
super().__init__(parent)
self.command: List[str] = []
self.process: Optional[subprocess.Popen] = None
self._stopped = False
def set_command(self, command: List[str]):
self.command = command
self._stopped = False
def stop(self):
self._stopped = True
if self.process:
try:
if sys.platform == "win32":
subprocess.run(
["taskkill", "/F", "/T", "/PID", str(self.process.pid)],
capture_output=True,
timeout=5
)
else:
self.process.terminate()
self.process.wait(timeout=3)
except:
try:
self.process.kill()
except:
pass
def run(self):
try:
self.process = subprocess.Popen(
self.command,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
stdin=subprocess.PIPE,
universal_newlines=True,
bufsize=1,
encoding='utf-8',
errors='replace',
cwd=str(APP_DIR)
)
for line in iter(self.process.stdout.readline, ''):
if self._stopped:
break
self.output_ready.emit(line.rstrip())
self.process.stdout.close()
return_code = self.process.wait()
self.command_finished.emit(return_code)
except Exception as e:
self.output_ready.emit(f"[错误] 命令执行出错: {str(e)}")
self.command_finished.emit(1)
finally:
self.process = None
class InteractiveThread(QThread):
output_ready = pyqtSignal(str)
command_finished = pyqtSignal(int)
def __init__(self, parent=None):
super().__init__(parent)
self.command: List[str] = []
self.process: Optional[subprocess.Popen] = None
self._stopped = False
self._input_queue: List[str] = []
def set_command(self, command: List[str]):
self.command = command
self._stopped = False
def send_input(self, text: str):
if self.process and self.process.poll() is None:
try:
self.process.stdin.write(text + "\n")
self.process.stdin.flush()
except:
pass
def stop(self):
self._stopped = True
if self.process:
try:
if sys.platform == "win32":
subprocess.run(
["taskkill", "/F", "/T", "/PID", str(self.process.pid)],
capture_output=True,
timeout=5
)
else:
self.process.terminate()
self.process.wait(timeout=3)
except:
try:
self.process.kill()
except:
pass
def run(self):
try:
self.process = subprocess.Popen(
self.command,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
stdin=subprocess.PIPE,
universal_newlines=True,
bufsize=1,
encoding='utf-8',
errors='replace',
cwd=str(APP_DIR)
)
for line in iter(self.process.stdout.readline, ''):
if self._stopped:
break
self.output_ready.emit(line.rstrip())
self.process.stdout.close()
return_code = self.process.wait()
self.command_finished.emit(return_code)
except Exception as e:
self.output_ready.emit(f"[错误] 命令执行出错: {str(e)}")
self.command_finished.emit(1)
finally:
self.process = None
class Translations:
TRANSLATIONS = {
"starting": "开始", "the target URL": "目标URL",
"testing connection to the target URL": "测试与目标URL的连接",
"checking if the target is protected by some kind of WAF/IPS": "检查目标是否受WAF/IPS保护",
"testing if the target URL content is stable": "测试目标URL内容是否稳定",
"target URL content is stable": "目标URL内容稳定",
"parameter": "参数", "is dynamic": "是动态的",
"appears to be dynamic": "似乎是动态的",
"heuristic test shows that": "启发式测试表明",
"might be injectable": "可能可注入",
"testing for SQL injection": "测试SQL注入",
"injection point": "注入点", "back-end DBMS": "后端DBMS",
"identified": "已识别", "the back-end DBMS is": "后端DBMS是",
"current user": "当前用户", "current database": "当前数据库",
"hostname": "主机名", "is DBA": "是DBA",
"dumping data": "导出数据", "dumped data": "已导出数据",
"entries": "条目", "connection timed out": "连接超时",
"execution finished": "执行完成",
"vulnerability found": "发现漏洞",
"no SQL injection vulnerability detected": "未检测到SQL注入漏洞",
"error occurred": "发生错误", "connection error": "连接错误",
"success": "成功", "failed": "失败",
"critical": "严重",
"debug": "调试", "payload": "载荷",
"retrieved": "已检索", "available databases": "可用数据库",
"available tables": "可用表",
"available columns": "可用列",
"database management system users": "数据库管理系统用户",
"database user": "数据库用户", "password hash": "密码哈希",
"privilege": "权限",
"found": "找到", "not found": "未找到",
"injectable": "可注入", "not injectable": "不可注入",
"the target is": "目标是",
"protected by some kind of WAF/IPS": "受某种WAF/IPS保护",
"the following injection point": "以下注入点",
"has been found": "已被发现", "is vulnerable": "是脆弱的",
"type: ": "类型: ", "title: ": "标题: ",
"payload: ": "载荷: ", "vector: ": "向量: ",
"considerable lagging": "明显延迟",
"HTTP error code": "HTTP错误代码",
"all tested parameters": "所有测试的参数",
"do not appear to be injectable": "似乎不可注入",
"try to increase values for": "尝试增加值",
"level": "检测级别", "risk": "风险级别",
"Internal Server Error": "内部服务器错误",
"times": "次", "ending": "结束",
"operating system": "操作系统",
"web application technology": "Web应用技术",
"web server operating system": "Web服务器操作系统",
"fetching": "获取", "reading file": "读取文件",
"writing file": "写入文件", "done": "完成",
"please enter": "请输入", "command": "命令",
"prompt": "提示符",
"banner": "Banner",
"Database:": "数据库:",
"Table:": "表:",
"Column:": "列:",
"Entry:": "条目:",
}
@classmethod
def translate(cls, text: str) -> str:
sorted_items = sorted(cls.TRANSLATIONS.items(), key=lambda x: -len(x[0]))
for eng, chn in sorted_items:
if len(eng) <= 3:
pattern = r'\b' + re.escape(eng) + r'\b'
text = re.sub(pattern, chn, text, flags=re.IGNORECASE)
else:
text = text.replace(eng, chn)
return text
class SqlmapGUI(QMainWindow):
def __init__(self):
super().__init__()
self.scanning = False
self.interactive_mode = False
self.current_log_file: Optional[Path] = None
self.recent_targets: List[str] = []
self._extracting_dbs = False
self._extracting_tables = False
self._extracting_columns = False
self._extracting_users = False
self._current_db_for_tables = ""
self._info_dirty = False
self._log_buffer: List[str] = []
self._is_dark_mode = False
self.extracted_info = {
"target": "",
"dbms": "",
"dbms_version": "",
"banner": "",
"os": "",
"web_server": "",
"current_user": "",
"current_db": "",
"hostname": "",
"is_dba": "",
"injection_points": [],
"databases": [],
"tables": [],
"columns": [],
"users": [],
"passwords": [],
}
self._info_timer = QTimer(self)
self._info_timer.timeout.connect(self._update_info_if_dirty)
self._info_timer.start(500)
self.command_thread = CommandThread(self)
self.command_thread.output_ready.connect(self.update_output)
self.command_thread.command_finished.connect(self.on_command_finished)
self.interactive_thread = InteractiveThread(self)
self.interactive_thread.output_ready.connect(self.update_output)
self.interactive_thread.command_finished.connect(self.on_command_finished)
self.load_config()
self.setup_ui()
self.check_time_and_set_theme()
self.new_log_file()
self.update_output(f"[信息] SQLMap中文图形化界面 v{VERSION} 已启动")
self.update_output(f"[信息] 支持完整功能: os-shell, sql-shell, 文件操作, 注册表操作, 二阶注入, DNS泄露, MSF集成等")
def setup_ui(self):
self.setWindowTitle(f"SQLMap 中文图形化界面 v{VERSION}")
self.resize(1400, 900)
self.setup_statusbar()
self.setup_toolbar()
self.setup_main_layout()
def check_time_and_set_theme(self):
current_hour = datetime.now().hour
is_night = current_hour >= 19 or current_hour < 7
if is_night:
self.apply_dark_theme()
QMessageBox.information(
self,
"护眼提示",
"当前是夜晚时段,已自动切换为暗色主题保护您的眼睛。\n\n"
"建议:\n"
"• 适当降低屏幕亮度\n"
"• 保持良好坐姿\n"
"• 每工作45分钟休息5分钟\n\n"
"祝您工作愉快!"
)
def apply_dark_theme(self):
self._is_dark_mode = True
dark_style = """
QMainWindow {
background-color: #1a1a2e;
}
QWidget {
background-color: #16213e;
color: #e8e8e8;
font-family: "Microsoft YaHei", "Segoe UI", sans-serif;
}
QTabWidget::pane {
border: 2px solid #0f3460;
background-color: #1a1a2e;
border-radius: 8px;
margin-top: -1px;
}
QTabBar::tab {
background: qlineargradient(x1:0, y1:0, x2:0, y2:1,
stop:0 #2d3a4f, stop:1 #1a2332);
color: #a0a0a0;
border: 1px solid #0f3460;
border-bottom: none;
border-top-left-radius: 6px;
border-top-right-radius: 6px;
padding: 10px 20px;
margin-right: 2px;
font-weight: bold;
}
QTabBar::tab:selected {
background: qlineargradient(x1:0, y1:0, x2:0, y2:1,
stop:0 #0f3460, stop:1 #1a1a2e);
color: #00d9ff;
border-color: #00d9ff;
}
QTabBar::tab:hover:!selected {
background: qlineargradient(x1:0, y1:0, x2:0, y2:1,
stop:0 #3d4a5f, stop:1 #2a3342);
color: #c0c0c0;
}
QGroupBox {
border: 2px solid #0f3460;
border-radius: 8px;
margin-top: 12px;
padding: 15px 10px 10px 10px;
background-color: #1f2940;
font-weight: bold;
}
QGroupBox::title {
subcontrol-origin: margin;
subcontrol-position: top left;
left: 15px;
padding: 0 8px;
color: #00d9ff;
background-color: #1f2940;
border-radius: 4px;
}
QLineEdit {
background-color: #0d1b2a;
color: #e8e8e8;
border: 2px solid #1b3a5c;
border-radius: 6px;
padding: 8px 12px;
selection-background-color: #00d9ff;
selection-color: #0d1b2a;
}
QLineEdit:hover {
border-color: #2a5a8c;
}
QLineEdit:focus {
border: 2px solid #00d9ff;
background-color: #0a1520;
}
QLineEdit:disabled {
background-color: #1a1a2e;
color: #5a5a5a;
border-color: #1a2332;
}
QTextEdit, QPlainTextEdit {
background-color: #0a0f1a;
color: #b8d4e8;
border: 2px solid #1b3a5c;
border-radius: 6px;
padding: 8px;
selection-background-color: #00d9ff;
selection-color: #0a0f1a;
}
QTextEdit:focus, QPlainTextEdit:focus {
border-color: #00d9ff;
}
QComboBox {
background: qlineargradient(x1:0, y1:0, x2:0, y2:1,
stop:0 #2d3a4f, stop:1 #1a2332);
color: #e8e8e8;
border: 2px solid #1b3a5c;
border-radius: 6px;
padding: 6px 12px;
min-width: 100px;
}
QComboBox:hover {
border-color: #2a5a8c;
}
QComboBox:on {
border-color: #00d9ff;
}
QComboBox::drop-down {
border: none;
width: 30px;
border-top-right-radius: 6px;
border-bottom-right-radius: 6px;
}
QComboBox::down-arrow {
image: none;
border-left: 6px solid transparent;
border-right: 6px solid transparent;
border-top: 8px solid #00d9ff;
margin-right: 8px;
}
QComboBox QAbstractItemView {
background-color: #1a2332;
color: #e8e8e8;
selection-background-color: #0f3460;
selection-color: #00d9ff;
border: 2px solid #0f3460;
border-radius: 6px;
padding: 4px;
}
QSpinBox {
background-color: #0d1b2a;
color: #e8e8e8;
border: 2px solid #1b3a5c;
border-radius: 6px;
padding: 6px 10px;
}
QSpinBox:hover {
border-color: #2a5a8c;
}
QSpinBox:focus {
border-color: #00d9ff;
}
QSpinBox::up-button, QSpinBox::down-button {
background-color: #1b3a5c;
border: none;
width: 20px;
border-radius: 3px;
}
QSpinBox::up-button:hover, QSpinBox::down-button:hover {
background-color: #2a5a8c;
}
QSpinBox::up-arrow {
image: none;
border-left: 5px solid transparent;
border-right: 5px solid transparent;
border-bottom: 6px solid #00d9ff;
}
QSpinBox::down-arrow {
image: none;
border-left: 5px solid transparent;
border-right: 5px solid transparent;
border-top: 6px solid #00d9ff;
}
QPushButton {
background: qlineargradient(x1:0, y1:0, x2:0, y2:1,
stop:0 #3a4a6a, stop:1 #2a3a5a);
color: #e8e8e8;
border: 2px solid #4a5a7a;
border-radius: 8px;
padding: 8px 16px;
font-weight: bold;
min-width: 90px;
}
QPushButton:hover {
background: qlineargradient(x1:0, y1:0, x2:0, y2:1,
stop:0 #4a5a7a, stop:1 #3a4a6a);
border-color: #00d9ff;
color: #00d9ff;
}
QPushButton:pressed {
background: qlineargradient(x1:0, y1:0, x2:0, y2:1,
stop:0 #2a3a5a, stop:1 #1a2a4a);
}
QPushButton:disabled {
background: #1a2332;
color: #4a4a4a;
border-color: #2a2a3a;
}
QCheckBox {
color: #e8e8e8;
spacing: 10px;
}
QCheckBox::indicator {
width: 22px;
height: 22px;
border: 2px solid #3a5a7a;
border-radius: 5px;
background-color: #0d1b2a;
}
QCheckBox::indicator:hover {
border-color: #00d9ff;
background-color: #1a2a3a;
}
QCheckBox::indicator:checked {
background-color: #00d9ff;
border-color: #00d9ff;
}
QCheckBox::indicator:disabled {
background-color: #1a1a2e;
border-color: #2a2a3a;
}
QRadioButton {
color: #e8e8e8;
spacing: 10px;
}
QRadioButton::indicator {
width: 22px;
height: 22px;
border: 2px solid #3a5a7a;
border-radius: 11px;
background-color: #0d1b2a;
}
QRadioButton::indicator:hover {
border-color: #00d9ff;
background-color: #1a2a3a;
}
QRadioButton::indicator:checked {
border: 3px solid #00d9ff;
background: qradialgradient(cx:0.5, cy:0.5, radius:0.4,
fx:0.5, fy:0.5,
stop:0 #00d9ff, stop:0.6 #00d9ff, stop:0.7 #0d1b2a);
}
QRadioButton::indicator:disabled {
background-color: #1a1a2e;
border-color: #2a2a3a;
}
QTableWidget {
background-color: #0a0f1a;
color: #b8d4e8;
gridline-color: #1b3a5c;
border: 2px solid #0f3460;
border-radius: 8px;
selection-background-color: #0f3460;
selection-color: #00d9ff;
}
QTableWidget::item {
padding: 8px;
border-bottom: 1px solid #1b3a5c;
}
QTableWidget::item:hover {
background-color: #1a2332;
}
QHeaderView::section {
background: qlineargradient(x1:0, y1:0, x2:0, y2:1,
stop:0 #2a3a5a, stop:1 #1a2a4a);
color: #00d9ff;
border: none;
border-bottom: 2px solid #0f3460;
padding: 10px;
font-weight: bold;
}
QHeaderView::section:hover {
background: qlineargradient(x1:0, y1:0, x2:0, y2:1,
stop:0 #3a4a6a, stop:1 #2a3a5a);
}
QProgressBar {
border: 2px solid #0f3460;
border-radius: 8px;
text-align: center;
background-color: #0d1b2a;
color: #e8e8e8;
font-weight: bold;
height: 24px;
}
QProgressBar::chunk {
background: qlineargradient(x1:0, y1:0, x2:1, y2:0,
stop:0 #00d9ff, stop:0.5 #00ff88, stop:1 #00d9ff);
border-radius: 6px;
}
QScrollBar:vertical {
background-color: #0a0f1a;
width: 14px;
border: none;
border-radius: 7px;
margin: 2px;
}
QScrollBar::handle:vertical {
background: qlineargradient(x1:0, y1:0, x2:1, y2:0,
stop:0 #1b3a5c, stop:1 #0f3460);
border-radius: 7px;
min-height: 40px;
}
QScrollBar::handle:vertical:hover {
background: qlineargradient(x1:0, y1:0, x2:1, y2:0,
stop:0 #2a5a8c, stop:1 #1b4a6c);
}
QScrollBar::add-line:vertical, QScrollBar::sub-line:vertical {
height: 0px;
}
QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical {
background: none;
}
QScrollBar:horizontal {
background-color: #0a0f1a;
height: 14px;
border: none;
border-radius: 7px;
margin: 2px;
}
QScrollBar::handle:horizontal {
background: qlineargradient(x1:0, y1:0, x2:0, y2:1,
stop:0 #1b3a5c, stop:1 #0f3460);
border-radius: 7px;
min-width: 40px;
}
QScrollBar::handle:horizontal:hover {
background: qlineargradient(x1:0, y1:0, x2:0, y2:1,
stop:0 #2a5a8c, stop:1 #1b4a6c);
}
QScrollBar::add-line:horizontal, QScrollBar::sub-line:horizontal {
width: 0px;
}
QToolBar {
background: qlineargradient(x1:0, y1:0, x2:0, y2:1,
stop:0 #1f2940, stop:1 #16213e);
border: none;
border-bottom: 2px solid #0f3460;
spacing: 8px;
padding: 8px;
}
QToolBar QToolButton, QToolBar QAction {
background: transparent;
color: #a0a0a0;
border: 2px solid transparent;
border-radius: 6px;
padding: 8px 12px;
font-weight: bold;
}
QToolBar QToolButton:hover {
background-color: #0f3460;
color: #00d9ff;
border-color: #00d9ff;
}
QToolBar QToolButton:pressed {
background-color: #1a2332;
}
QStatusBar {
background: qlineargradient(x1:0, y1:0, x2:1, y2:0,
stop:0 #0f3460, stop:0.5 #00d9ff, stop:1 #0f3460);
color: #ffffff;
font-weight: bold;
border-top: 2px solid #00d9ff;
}
QSplitter::handle {
background: qlineargradient(x1:0, y1:0, x2:1, y2:0,
stop:0 transparent, stop:0.4 #0f3460, stop:0.6 #0f3460, stop:1 transparent);
height: 4px;
}
QSplitter::handle:hover {
background: qlineargradient(x1:0, y1:0, x2:1, y2:0,
stop:0 transparent, stop:0.4 #00d9ff, stop:0.6 #00d9ff, stop:1 transparent);
}
QToolTip {
background-color: #1a2332;
color: #00d9ff;
border: 2px solid #0f3460;
border-radius: 6px;
padding: 6px 10px;
}
QMenu {
background-color: #1a2332;
color: #e8e8e8;
border: 2px solid #0f3460;
border-radius: 8px;
padding: 6px;
}
QMenu::item {
padding: 8px 30px 8px 20px;
border-radius: 4px;
}
QMenu::item:selected {
background-color: #0f3460;
color: #00d9ff;
}
QMenu::separator {
height: 2px;
background: #0f3460;
margin: 6px 10px;
}
QScrollBar QAbstractSlider {
background: transparent;
}
QFrame {
border-radius: 8px;
}
QFrame[frameShape="4"] {
background-color: #0f3460;
}
QFrame[frameShape="5"] {
background-color: #0f3460;
}
"""
self.setStyleSheet(dark_style)
def apply_light_theme(self):
self._is_dark_mode = False
self.setStyleSheet("")
def toggle_theme(self):
if self._is_dark_mode:
self.apply_light_theme()
else:
self.apply_dark_theme()
def setup_statusbar(self):
self.statusBar = QStatusBar()
self.setStatusBar(self.statusBar)
self.statusBar.showMessage("就绪")
def setup_toolbar(self):
self.toolbar = QToolBar("主工具栏")
self.toolbar.setIconSize(QSize(24, 24))
self.addToolBar(self.toolbar)
self.start_action = QAction("开始扫描", self)
self.start_action.triggered.connect(self.start_scan)
self.toolbar.addAction(self.start_action)
self.stop_action = QAction("停止", self)
self.stop_action.triggered.connect(self.stop_scan)
self.stop_action.setEnabled(False)
self.toolbar.addAction(self.stop_action)
self.toolbar.addSeparator()
self.save_config_action = QAction("保存配置", self)
self.save_config_action.triggered.connect(self.save_config)
self.toolbar.addAction(self.save_config_action)
self.toolbar.addSeparator()
self.report_action = QAction("生成报告", self)
self.report_action.triggered.connect(self.generate_report)
self.toolbar.addAction(self.report_action)
self.history_action = QAction("历史记录", self)
self.history_action.triggered.connect(self.show_history)
self.toolbar.addAction(self.history_action)
self.toolbar.addSeparator()
self.help_action = QAction("帮助", self)
self.help_action.triggered.connect(self.show_help)
self.toolbar.addAction(self.help_action)
self.toolbar.addSeparator()
self.theme_action = QAction("切换主题", self)
self.theme_action.triggered.connect(self.toggle_theme)
self.toolbar.addAction(self.theme_action)
self.toolbar.addSeparator()
self.contact_action = QAction("联系作者", self)
self.contact_action.triggered.connect(self.show_contact_dialog)
self.toolbar.addAction(self.contact_action)
def setup_main_layout(self):
main_widget = QWidget()
self.setCentralWidget(main_widget)
main_layout = QVBoxLayout(main_widget)
splitter = QSplitter(Qt.Horizontal)
main_layout.addWidget(splitter)
left_panel = self.create_left_panel()
splitter.addWidget(left_panel)
right_panel = self.create_right_panel()
splitter.addWidget(right_panel)
splitter.setSizes([500, 900])
self.progress_bar = QProgressBar()
self.progress_bar.setTextVisible(True)
self.progress_bar.setFormat("就绪")
self.progress_bar.setValue(0)
main_layout.addWidget(self.progress_bar)
def create_left_panel(self) -> QWidget:
panel = QWidget()
layout = QVBoxLayout(panel)
self.tabs = QTabWidget()
self.tabs.addTab(self.create_basic_tab(), "基本设置")
self.tabs.addTab(self.create_enumeration_tab(), "枚举选项")
self.tabs.addTab(self.create_os_access_tab(), "系统访问")
self.tabs.addTab(self.create_file_tab(), "文件操作")
self.tabs.addTab(self.create_registry_tab(), "注册表")
self.tabs.addTab(self.create_injection_tab(), "注入选项")
self.tabs.addTab(self.create_advanced_tab(), "高级设置")
self.tabs.addTab(self.create_command_tab(), "命令预览")
layout.addWidget(self.tabs)
buttons_layout = QHBoxLayout()
self.start_button = QPushButton("开始扫描")
self.start_button.clicked.connect(self.start_scan)
self.stop_button = QPushButton("停止")
self.stop_button.clicked.connect(self.stop_scan)
self.stop_button.setEnabled(False)
buttons_layout.addWidget(self.start_button)
buttons_layout.addWidget(self.stop_button)
layout.addLayout(buttons_layout)
return panel
def create_basic_tab(self) -> QWidget:
tab = QWidget()
layout = QVBoxLayout(tab)
layout.addWidget(self.create_target_group())
layout.addWidget(self.create_detection_group())
layout.addWidget(self.create_technique_group())
layout.addWidget(self.create_dbms_group())
layout.addStretch()
return tab
def create_target_group(self) -> QGroupBox:
group = QGroupBox("目标设置")
layout = QVBoxLayout(group)
url_layout = QHBoxLayout()
url_layout.addWidget(QLabel("URL:"))
self.url_input = QComboBox()
self.url_input.setEditable(True)
self.url_input.setInsertPolicy(QComboBox.InsertAtTop)
self.url_input.lineEdit().setPlaceholderText("http://example.com/page.php?id=1")
for target in self.recent_targets[:10]:
self.url_input.addItem(target)
url_layout.addWidget(self.url_input)
layout.addLayout(url_layout)
request_layout = QHBoxLayout()
request_layout.addWidget(QLabel("请求文件:"))
self.request_file_input = QLineEdit()
self.request_file_input.setPlaceholderText("选择包含HTTP请求的文件")
request_btn = QPushButton("浏览")
request_btn.clicked.connect(self.select_request_file)
request_layout.addWidget(self.request_file_input)
request_layout.addWidget(request_btn)
layout.addLayout(request_layout)
cookie_layout = QHBoxLayout()
cookie_layout.addWidget(QLabel("Cookie:"))
self.cookie_input = QLineEdit()
self.cookie_input.setPlaceholderText("PHPSESSID=xxx; security=low")
cookie_layout.addWidget(self.cookie_input)
layout.addLayout(cookie_layout)
data_layout = QHBoxLayout()
data_layout.addWidget(QLabel("POST数据:"))
self.post_data_input = QLineEdit()
self.post_data_input.setPlaceholderText("id=1&name=test")
data_layout.addWidget(self.post_data_input)
layout.addLayout(data_layout)
return group
def create_detection_group(self) -> QGroupBox:
group = QGroupBox("检测设置")
layout = QHBoxLayout(group)
level_group = QGroupBox("检测级别")
level_layout = QHBoxLayout(level_group)
self.level_buttons = QButtonGroup()
for i in range(1, 6):
rb = QRadioButton(str(i))
if i == 1:
rb.setChecked(True)
self.level_buttons.addButton(rb, i)
level_layout.addWidget(rb)
layout.addWidget(level_group)
risk_group = QGroupBox("风险级别")
risk_layout = QHBoxLayout(risk_group)
self.risk_buttons = QButtonGroup()
for i in range(1, 4):
rb = QRadioButton(str(i))
if i == 1:
rb.setChecked(True)
self.risk_buttons.addButton(rb, i)
risk_layout.addWidget(rb)
layout.addWidget(risk_group)
return group
def create_technique_group(self) -> QGroupBox:
group = QGroupBox("注入技术")
layout = QHBoxLayout(group)
self.technique_checkboxes: Dict[str, QCheckBox] = {}
techniques = [
("B", "布尔盲注"), ("E", "报错注入"), ("U", "联合查询"),
("S", "堆叠查询"), ("T", "时间盲注"), ("Q", "内联查询")
]
for code, name in techniques:
cb = QCheckBox(f"{name}")
cb.setChecked(True)
cb.setToolTip(f"{name} ({code})")
self.technique_checkboxes[code] = cb
layout.addWidget(cb)
return group
def create_dbms_group(self) -> QGroupBox:
group = QGroupBox("数据库类型")
layout = QHBoxLayout(group)
layout.addWidget(QLabel("DBMS:"))
self.dbms_combo = QComboBox()
self.dbms_combo.addItem("自动检测", "")
for dbms in ["MySQL", "Oracle", "PostgreSQL", "Microsoft SQL Server",
"SQLite", "IBM DB2", "Firebird", "Sybase", "HSQLDB", "Informix"]:
self.dbms_combo.addItem(dbms, dbms)
layout.addWidget(self.dbms_combo)
layout.addStretch()
return group
def create_enumeration_tab(self) -> QWidget:
tab = QWidget()
layout = QVBoxLayout(tab)
info_group = QGroupBox("信息获取")
info_layout = QHBoxLayout(info_group)