This repository has been archived by the owner on Jul 30, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
FileScanner.vb
356 lines (233 loc) · 13.5 KB
/
FileScanner.vb
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
Imports System.ComponentModel
Imports System.Diagnostics
Public Class FileScanner
Private WithEvents myProcess As Process
Private eventHandled As TaskCompletionSource(Of Boolean)
Public Shared ReadOnly Property LocalUserAppDataPath As String
Public ReadOnly Property CancellationPending As Boolean
Private Sub Scanner_Load(sender As Object, e As EventArgs) Handles Me.Load
'### Form umbenennen
If My.Settings.Eng = False Then
Me.Text = "Hashbull Scanner für verschlüsselte Dateien"
Button1.Text = "Einstellungen"
Button2.Text = "Dateien kopieren"
End If
Call ListLoad1()
End Sub
Private Sub ListLoad1()
'### Standartext #####
Dim s As String
If My.Settings.Eng = False Then
s = "################################=H A S H B U L L // Encrypted-File-Scanner=################################= =Hashbull scannt nun das gesamte Dateisystem, inkl. Netzlaufwerke der Zielperon um verschlüsselte=PDF-, Office-, 7z-, ZIP und RAR-Dateien zu finden.==Der Scanvorgang kann einige Zeit in Anspruch nehmen.=Über den Button ""Crack"" kann die ausgewählte Datei direkt an Hashbull weitergeleitet werden.==Folgende Dateien konnten auf dem System lokalisiert werden:"
Else
s = "################################=H A S H B U L L // Encrypted-File-Scanner=################################= =Hashbull now searches the target persons computer for encrypted files.=The scanning process may take some time.=The hits can be forwarded directly to Hashbull via the ""Crack"" button.= =The following files could be located on the system:"
End If
'### Standardtext wird auf die Items aufgeteilt durch =-Zeichen
Dim words As String() = s.Split(New Char() {"="c})
Dim word As String
For Each word In words
ListBox1.Items.Add(word)
Next
End Sub
Private Sub BackgroundWorker1_DoWork(sender As System.Object, e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
'### Der Backgroundworker durchsucht alle Laufwerke und fügt die Treffer der Listbox hinzu
Try
Dim start_info As New ProcessStartInfo()
Dim proc As New Process
Dim std_out As System.IO.StreamReader
My.Settings.Reload()
'### CMD läuft versteckt
start_info.FileName = ("cmd.exe")
start_info.Verb = "runas"
start_info.UseShellExecute = False
start_info.CreateNoWindow = True
start_info.RedirectStandardOutput = True
start_info.WindowStyle = ProcessWindowStyle.Hidden
start_info.WorkingDirectory = Application.StartupPath & "\Packages\JtR\run"
start_info.Arguments = ("/k " & Application.StartupPath & "\Packages\Hashbull_lib\EFS\EFS.bat")
'start_info.Arguments = (Param)
proc.StartInfo = start_info
proc.Start()
std_out = proc.StandardOutput
'### Schleife wird ausgeführt. Bei CancelP wird die Schleife verlassen. Letzte Eintrag wird autom. selek., damit die Liste autom. nach unten scrollt
Do
If Me.BackgroundWorker1.CancellationPending Then Exit Do
Dim line As String = std_out.ReadLine()
'ListBox1.Invoke(Sub() ListBox1.Items.Add(line))
ListBox1.Invoke(Sub()
ListBox1.Items.Add(line)
ListBox1.SelectedIndex = ListBox1.Items.Count - 1
End Sub)
Loop While proc.HasExited = False
Catch ex As Exception
End Try
End Sub
Public Sub StartKryptoBtn_Click(sender As Object, e As EventArgs) Handles StartKryptoBtn.Click
Call Save()
'### Es wird die Form neu geladen, da ansonsten bei einem erneuten Start der Worker noch läuft
Me.Controls.Clear() 'removes all the controls on the form
InitializeComponent() 'load all the controls again
Me.Show()
'### Für Neustart Listbox löschen
ListBox1.Items.Clear()
Call ListLoad1()
'### Worker starten
Me.BackgroundWorker1.RunWorkerAsync()
'### Radar einblenden
PictureBox1.Visible = True
'### Buttons deaktivieren
StartKryptoBtn.Enabled = False
ScannerStopBtn.Enabled = True
ScannerCrackBtn.Enabled = False
Button1.Enabled = False
Button2.Enabled = False
End Sub
Public Sub Save()
My.Settings.Reload()
Dim drives1 As String
Dim Perl As String
Dim PP2 As String
Dim PDFjohn As String
Dim OfficeJohn As String
Dim zJohn As String
Dim zipJohn As String
Dim rarJohn As String
drives1 = "Set sDrives=" & My.Settings.EFSDrives & vbNewLine
Perl = "Set Perl=" & vari.Perl
PP2 = "Set PP2=" & vari.PP2
PDFjohn = "Set PDFjohn=" & vari.JtR & "pdf2john.pl"
OfficeJohn = "Set OfficeJohn=" & vari.JtR & "office2john.py"
zJohn = "Set zJohn=" & vari.JtR & "7z2hashcat6414.exe"
zipJohn = "Set zipJohn=" & vari.JtR & "zip2john.exe"
rarJohn = "Set rarJohn=" & vari.JtR & "rar2john.exe"
Dim save As New IO.StreamWriter(New IO.FileStream(IO.Path.Combine(Application.StartupPath & "\Packages\Hashbull_lib\EFS\EFS.bat"), IO.FileMode.Create))
save.WriteLine(Label3.Text)
save.WriteLine(drives1)
save.WriteLine(Perl)
save.WriteLine(PP2)
save.WriteLine(PDFjohn)
save.WriteLine(OfficeJohn)
save.WriteLine(zJohn)
save.WriteLine(zipJohn)
save.WriteLine(rarJohn)
If My.Settings.EFS2 = True Then save.WriteLine(PDF.Text)
If My.Settings.EFS2 = True Then save.WriteLine(" %Perl% %PDFjohn% ""%%a""|findstr /ilc:""$p"" >nul 2>&1 && echo %%a")
If My.Settings.EFS2 = True Then save.WriteLine(" @ping -n 1 localhost> nul")
If My.Settings.EFS2 = True Then save.WriteLine(" )")
If My.Settings.EFS2 = True Then save.WriteLine(")")
If My.Settings.EFS3 = True Then save.WriteLine(DOC.Text)
If My.Settings.EFS3 = True Then save.WriteLine(" %PP2% %OfficeJohn% ""%%a""|findstr /ilc:""$o"" >nul 2>&1 && echo %%a")
If My.Settings.EFS3 = True Then save.WriteLine(" @ping -n 1 localhost> nul")
If My.Settings.EFS3 = True Then save.WriteLine(" )")
If My.Settings.EFS3 = True Then save.WriteLine(")")
If My.Settings.EFS4 = True Then save.WriteLine(XLS.Text)
If My.Settings.EFS4 = True Then save.WriteLine(" %PP2% %OfficeJohn% ""%%a""|findstr /ilc:""$o"" >nul 2>&1 && echo %%a")
If My.Settings.EFS4 = True Then save.WriteLine(" @ping -n 1 localhost> nul")
If My.Settings.EFS4 = True Then save.WriteLine(" )")
If My.Settings.EFS4 = True Then save.WriteLine(")")
If My.Settings.EFS5 = True Then save.WriteLine(Sieben.Text)
If My.Settings.EFS5 = True Then save.WriteLine(" %zJohn% ""%%a""|findstr /ilc:""$"" >nul 2>&1 && echo %%a")
If My.Settings.EFS5 = True Then save.WriteLine(" @ping -n 1 localhost> nul")
If My.Settings.EFS5 = True Then save.WriteLine(" )")
If My.Settings.EFS5 = True Then save.WriteLine(")")
If My.Settings.EFS6 = True Then save.WriteLine(zip.Text)
If My.Settings.EFS6 = True Then save.WriteLine(" %zipJohn% ""%%a""|findstr /ilc:""$"" >nul 2>&1 && echo %%a")
If My.Settings.EFS6 = True Then save.WriteLine(" @ping -n 1 localhost> nul")
If My.Settings.EFS6 = True Then save.WriteLine(" )")
If My.Settings.EFS6 = True Then save.WriteLine(")")
If My.Settings.EFS7 = True Then save.WriteLine(RAR.Text)
If My.Settings.EFS7 = True Then save.WriteLine(" %rarJohn% ""%%a""|findstr /ilc:""$"" >nul 2>&1 && echo %%a")
If My.Settings.EFS7 = True Then save.WriteLine(" @ping -n 1 localhost> nul")
If My.Settings.EFS7 = True Then save.WriteLine(" )")
If My.Settings.EFS7 = True Then save.WriteLine(")")
save.WriteLine(Label6.Text) '### Hashbull finsih
save.Close()
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles ScannerStopBtn.Click
'### Background worker wird gestoppt. Er läuft aber solange weiter, bis er einen nächsten Treffer hat. Daher der Umweg über Neustart
Me.BackgroundWorker1.CancelAsync()
'### Radar abschalten
PictureBox1.Visible = False
'### Msgbox
If My.Settings.Eng = False Then MsgBox("Der Scannvorgang wurde abgebrochen.")
If My.Settings.Eng = True Then MsgBox("The scanning process was canceled.")
'### Start Button wieder aktivieren
StartKryptoBtn.Enabled = True
ScannerCrackBtn.Enabled = True
Button1.Enabled = True
Button2.Enabled = True
End Sub
Private Sub ListBox1_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
'### Select Item in Textbox darstellen
Me.TextBox1.Text = Me.ListBox1.SelectedItem
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles ScannerCrackBtn.Click
'### Crack Buttob und Übergabe an Extraction
Extraction.Show()
Extraction.TextBox2.Text = TextBox1.Text
If My.Settings.Eng = False Then MsgBox("Bitte wählen Sie den Datei-Typ aus.")
If My.Settings.Eng = True Then MsgBox("Please Select the file type.")
'Me.Close()
'Welcome.Opacity = 0
End Sub
Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged
'### Ende überwachen durch Textbox1
If TextBox1.Text = "Hashbull-Scan finish ..." Then
Me.BackgroundWorker1.CancelAsync()
StartKryptoBtn.Enabled = True
Dim DateBatch As String = Format(Now, "yyyyMMdd_HHmmss")
Dim sav As String = (Application.StartupPath & "\Hashbull_Scanner\Hashbull_Encrypted_Files_" & DateBatch & ".txt")
Dim text As String = ""
'### Listbox wird in txt gespeichert
For Each Litem As String In ListBox1.Items
text &= vbCrLf & Litem
Next
IO.File.WriteAllText(sav, text)
'### Radar ausblenden
PictureBox1.Visible = False
'### Msgbox
If My.Settings.Eng = False Then MsgBox("Scanvorgang abgeschlossen. Die Ergebnisse wurden in den Ordner ""Hashbull_Scanner"" exportiert.")
If My.Settings.Eng = True Then MsgBox("The scanning process is finished. The results were exported to the Folder ""Hashbull_Scanner"".")
End If
End Sub
Private Sub ListBox1_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListBox1.DoubleClick
ScannerCrackBtn.PerformClick()
End Sub
Private Sub FileScanner_Closing(sender As Object, e As CancelEventArgs) Handles Me.Closing
WordlistUtility.Show()
End Sub
Private Sub Button1_Click_1(sender As Object, e As EventArgs) Handles Button1.Click
FileScannerSettings.Show()
End Sub
Private Sub Button2_Click_1(sender As Object, e As EventArgs) Handles Button2.Click
Try
My.Settings.Reload()
Dim CopyFolder1 As String = My.Settings.CopyFolder
Dim Msg As String = "Der Kopiervorgang wird nun durchgeführt und kann einige Zeit in Anspruch nehmen. Sobald der Kopiervorgang beendet ist bekommen Sie eine Mitteilung."
If My.Settings.Eng = False Then Msg = "Der Kopiervorgang wird nun durchgeführt und kann einige Zeit in Anspruch nehmen. Sobald der Kopiervorgang beendet ist bekommen Sie eine Mitteilung."
If My.Settings.Eng = True Then Msg = "The copying process will now be carried out and may take some time. As soon as the copying process is finished you will receive a message."
If My.Settings.CopyFolder = "" Then CopyFolder1 = (Application.StartupPath & "\Hashbull_Scanner\Copy_Folder")
Select Case MessageBox.Show(Msg, "Hashbull", MessageBoxButtons.OKCancel)
Case Windows.Forms.DialogResult.OK
Dim strPathTarget As String = CopyFolder1
For Each itm As String In ListBox1.Items
If System.IO.File.Exists(itm) Then
Dim dtSource As DateTime = System.IO.File.GetCreationTime(itm)
Dim dst As String = System.IO.Path.Combine(strPathTarget, System.IO.Path.GetFileName(itm))
Try
System.IO.File.Copy(itm, dst)
System.IO.File.SetCreationTime(dst, dtSource)
Catch ex As Exception
'MsgBox("Exception: " & ex.Message, MsgBoxStyle.Exclamation)
End Try
End If
Next
If My.Settings.Eng = False Then MsgBox("Der Kopiervorgang ist abgeschlossen. Sie finden die Dateien im Ordner ""Hashbull_Scanner\Copy_Folder\""")
If My.Settings.Eng = True Then MsgBox("The copying process is complete. You will find the files in the folder ""Hashbull_Scanner\Copy_Folder\""")
Case Windows.Forms.DialogResult.Cancel
Exit Sub
End Select
Catch ex As Exception
End Try
End Sub
End Class