-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathrun_GUI.py
More file actions
115 lines (93 loc) · 3.87 KB
/
Copy pathrun_GUI.py
File metadata and controls
115 lines (93 loc) · 3.87 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
import os
from PySide6.QtWidgets import (
QStackedWidget,
QApplication,
QMainWindow,
QFileDialog,
QVBoxLayout,
QWidget,
QLabel,
QLineEdit,
QToolBar,
)
from PySide6.QtGui import QAction, QIcon
import sys
from KeyboardDecrypt import KeyboardDecryptWindow
from MouseDecrypt import MouseDecryptWindow
from ctypes import windll
class MainWindow(QMainWindow):
global base_dir
base_dir = os.path.dirname(__file__)
def __init__(self):
super(MainWindow, self).__init__()
self.setWindowTitle("USB流量分析 Modified by s1rius")
self.keyboardDecryptWindow = KeyboardDecryptWindow(self)
self.keyboardDecryptWindow.file_dropped.connect(self.set_file)
self.mouseDecryptWindow = MouseDecryptWindow()
self.mouseDecryptWindow.file_dropped.connect(self.set_file)
self.stackedWidget = QStackedWidget(self)
self.stackedWidget.addWidget(self.keyboardDecryptWindow)
self.stackedWidget.addWidget(self.mouseDecryptWindow)
self.typeToolBar = QToolBar(self)
self.keyboardAction = QAction("键盘流量解密", self)
self.mouseAction = QAction("鼠标流量解密", self)
self.keyboardAction.triggered.connect(lambda: self.switch_window(0))
self.mouseAction.triggered.connect(lambda: self.switch_window(1))
self.typeToolBar.addAction(self.keyboardAction)
self.typeToolBar.addAction(self.mouseAction)
self.addToolBar(self.typeToolBar)
# 文件选择功能
self.fileToolBar = QToolBar(self)
self.select_file_label = QLabel("选择或拖拽文件")
self.fileToolBar.addWidget(self.select_file_label)
self.file_name = QLineEdit()
self.file_name.setReadOnly(True)
self.fileToolBar.addWidget(self.file_name)
self.select_file_button = QAction("浏览文件", self)
self.select_file_button.triggered.connect(self.select_file)
self.fileToolBar.addAction(self.select_file_button)
self.addToolBar(self.fileToolBar)
layout = QVBoxLayout()
layout.addWidget(self.stackedWidget)
self.setWindowIcon(QIcon("img/myico.ico"))
self.setStyleSheet(
"""MainWindow {background-image: url("img/mybg.jpg")}
QPushButton {background-color: transparent}
QTextEdit {background-color: rgba(255, 255, 255, 200)}
QLineEdit {background-color: rgba(255, 255, 255, 200)}
"""
)
windll.shell32.SetCurrentProcessExplicitAppUserModelID("myappid")
centralWidget = QWidget(self)
centralWidget.setLayout(layout)
self.setCentralWidget(centralWidget)
# 设置窗口大小
self.resize(600, 450)
def switch_window(self, index):
self.stackedWidget.setCurrentIndex(index)
def select_file(self):
options = QFileDialog.Options()
fileName, _ = QFileDialog.getOpenFileName(
self,
"选择文件",
"",
"Wireshark pcapng (*.ntar *.ntar.* *.pcapng.gz *.pcapng.zst *.pcapng.lz4 *.pcapng);;tcpdump pcap (*.dmp.* *.dmp *.cap.* *.cap *.pcap.* *.pcap);;other (*.*)",
options=options,
)
if fileName:
self.file_name.setText(fileName) # 更新file_name文本框的文本
self.keyboardDecryptWindow.set_file(fileName)
self.mouseDecryptWindow.set_file(fileName)
def set_file(self, file_name):
self.file_name.setText(file_name)
self.keyboardDecryptWindow.set_file(file_name)
self.mouseDecryptWindow.set_file(file_name)
if getattr(sys, "frozen", False):
base_path = sys._MEIPASS
else:
base_path = os.path.dirname(__file__)
os.chdir(base_path)
app = QApplication(sys.argv)
window = MainWindow()
window.show()
app.exec()