-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.py
205 lines (165 loc) · 7.29 KB
/
main.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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from PyQt5.QtGui import *
from PyQt5.QtCore import *
from PyQt5.QtWidgets import *
import subprocess
import sys
import design
class StartScanThread(QThread):
def __init__(self, process_list):
QThread.__init__(self)
self.process_list = process_list
def start_scan(self):
print(self.process_list) # for debugging
subprocess.check_output(self.process_list)
def run(self):
self.start_scan()
class BrunnhildeApp(QMainWindow, design.Ui_Brunnhilde):
def __init__(self, parent=None):
super(BrunnhildeApp, self).__init__(parent)
self.setupUi(self)
# build browse functionality buttons
self.dirSourceBtn.clicked.connect(self.browse_dirsource)
self.diskImageSourceBtn.clicked.connect(self.browse_diskimage)
self.dirDestinationBtn.clicked.connect(self.browse_dirdest)
self.diskImageDestinationBtn.clicked.connect(self.browse_diskimagedest)
# build start functionalities
self.dirStartScanBtn.clicked.connect(self.start_scan_dir)
self.diskImageStartScan.clicked.connect(self.start_scan_diskimage)
# about menu functionality
self.actionAbout.triggered.connect(self.about_dialog)
# Set buttons
self.dirCancelBtn.setEnabled(False)
self.dirStartScanBtn.setEnabled(True)
self.diskImageCancelBtn.setEnabled(False)
self.diskImageStartScan.setEnabled(True)
def about_dialog(self):
QMessageBox.information(self, "About",
"Brunnhilde GUI v.2.1.0\nTessa Walsh, 2017-2023\nMIT License\nhttps://github.com/tw4l/brunnhilde-gui\nCompatible with Brunnhilde 1.6.1+")
def browse_dirsource(self):
self.dirSource.clear() # clear directory source text
directory = QFileDialog.getExistingDirectory(self, "Select folder")
if directory: # if user didn't pick directory don't continue
self.dirSource.setText(directory)
def browse_diskimage(self):
self.diskImageSource.clear() # clear existing disk image source text
diskimage = QFileDialog.getOpenFileName(self, "Select disk image")[0]
if diskimage:
self.diskImageSource.setText(diskimage)
def browse_dirdest(self):
self.dirDestination.clear() # clear existing report destination text
directory = QFileDialog.getExistingDirectory(self, "Select folder")
if directory: # if user didn't pick directory don't continue
self.dirDestination.setText(directory)
def browse_diskimagedest(self):
self.diskImageDestination.clear() # clear existing report destination text
directory = QFileDialog.getExistingDirectory(self, "Select folder")
if directory: # if user didn't pick directory don't continue
self.diskImageDestination.setText(directory)
def done_dir(self):
self.dirCancelBtn.setEnabled(False)
self.dirStartScanBtn.setEnabled(True)
QMessageBox.information(self, "Finished", "Brunnhilde scan complete.")
self.dirStatus.setText('Finished')
def done_diskimage(self):
self.diskImageCancelBtn.setEnabled(False)
self.diskImageStartScan.setEnabled(True)
QMessageBox.information(self, "Finished", "Brunnhilde scan complete.")
self.diskImageStatus.setText('Finished')
def start_scan_dir(self):
# clear output window
self.dirStatus.clear()
# create list for process
self.process_list = list()
self.process_list.append("brunnhilde.py")
# give indication process has started
self.dirStatus.setText('Processing')
# universal option handling
if not self.virusScan.isChecked():
self.process_list.append('-n')
if self.largeFiles.isChecked():
self.process_list.append('-l')
if self.bulkExtractor.isChecked():
self.process_list.append('-b')
if self.scanArchives.isChecked():
self.process_list.append('-z')
if self.throttleSiegfried.isChecked():
self.process_list.append('-t')
if self.sfWarnings.isChecked():
self.process_list.append('-w')
if self.sha1.isChecked():
self.process_list.append('--hash')
self.process_list.append('sha1')
if self.sha256.isChecked():
self.process_list.append('--hash')
self.process_list.append('sha256')
if self.sha512.isChecked():
self.process_list.append('--hash')
self.process_list.append('sha512')
self.process_list.append(self.dirSource.text())
self.process_list.append(self.dirDestination.text())
self.process_list.append(self.dirIdentifier.text())
# process
self.get_thread = StartScanThread(self.process_list)
self.get_thread.finished.connect(self.done_dir)
self.get_thread.start()
self.dirCancelBtn.setEnabled(True)
self.dirCancelBtn.clicked.connect(self.get_thread.terminate)
self.dirStartScanBtn.setEnabled(False)
def start_scan_diskimage(self):
# clear output window
self.diskImageStatus.clear()
# create list for process
self.process_list = list()
self.process_list.append("brunnhilde.py")
# give indication process has started
self.diskImageStatus.setText('Processing')
# add disk image flag
self.process_list.append('-d')
# universal option handling
if not self.virusScan.isChecked():
self.process_list.append('-n')
if self.largeFiles.isChecked():
self.process_list.append('-l')
if self.bulkExtractor.isChecked():
self.process_list.append('-b')
if self.scanArchives.isChecked():
self.process_list.append('-z')
if self.throttleSiegfried.isChecked():
self.process_list.append('-t')
if self.sfWarnings.isChecked():
self.process_list.append('-w')
if self.sha1.isChecked():
self.process_list.append('--hash')
self.process_list.append('sha1')
if self.sha256.isChecked():
self.process_list.append('--hash')
self.process_list.append('sha256')
if self.sha512.isChecked():
self.process_list.append('--hash')
self.process_list.append('sha512')
# disk image option handling
if self.removeFiles.isChecked():
self.process_list.append('-r')
if self.hfsDisk.isChecked():
self.process_list.append('--hfs')
if self.resForks.isChecked():
self.process_list.append('--resforks')
self.process_list.append(self.diskImageSource.text())
self.process_list.append(self.diskImageDestination.text())
self.process_list.append(self.diskImageIdentifier.text())
# process
self.get_thread = StartScanThread(self.process_list)
self.get_thread.finished.connect(self.done_diskimage)
self.get_thread.start()
self.diskImageCancelBtn.setEnabled(True)
self.diskImageCancelBtn.clicked.connect(self.get_thread.terminate)
self.diskImageStartScan.setEnabled(False)
def main():
app = QApplication(sys.argv)
form = BrunnhildeApp()
form.show()
app.exec_()
if __name__ == '__main__':
main()