-
Notifications
You must be signed in to change notification settings - Fork 59
/
Copy pathfrmBruteZLib.frm
822 lines (720 loc) · 24 KB
/
frmBruteZLib.frm
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
VERSION 5.00
Object = "{3B7C8863-D78F-101B-B9B5-04021C009402}#1.2#0"; "RICHTX32.OCX"
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "mscomctl.ocx"
Begin VB.Form frmBruteZLib
Caption = "Zlib Brute Forcer - find zlib compressed sections of file"
ClientHeight = 8055
ClientLeft = 60
ClientTop = 345
ClientWidth = 14175
LinkTopic = "Form1"
ScaleHeight = 8055
ScaleWidth = 14175
StartUpPosition = 3 'Windows Default
Begin VB.OptionButton optLZW
Caption = "lzw"
Height = 255
Left = 10140
TabIndex = 24
Top = 120
Width = 735
End
Begin VB.OptionButton optZlib
Caption = "zlib"
Height = 255
Left = 9300
TabIndex = 23
Top = 120
Value = -1 'True
Width = 675
End
Begin VB.Frame fraReplaceStream
Caption = "Replace Stream "
Height = 2490
Left = 3735
TabIndex = 10
Top = 2250
Visible = 0 'False
Width = 8430
Begin VB.OptionButton Option1
Caption = "after recompression"
Height = 285
Index = 1
Left = 3510
TabIndex = 20
Top = 2025
Width = 1860
End
Begin VB.OptionButton Option1
Caption = "before recompression"
Height = 285
Index = 0
Left = 1440
TabIndex = 19
Top = 2025
Value = -1 'True
Width = 1860
End
Begin VB.CommandButton Command4
Caption = "Update Stream"
Height = 330
Left = 6930
TabIndex = 18
Top = 2025
Width = 1410
End
Begin VB.TextBox txtPadChar
Height = 285
Left = 4860
TabIndex = 17
Text = "20"
Top = 1665
Width = 690
End
Begin VB.CheckBox chkPadifSmaller
Caption = "if replacment stream is smaller pad with hex char"
Height = 285
Left = 1080
TabIndex = 16
Top = 1665
Width = 3750
End
Begin VB.CommandButton cmdLoadNewStream
Caption = "..."
Height = 285
Left = 7650
TabIndex = 15
Top = 630
Width = 645
End
Begin VB.TextBox txtNewStream
Height = 285
Left = 1080
TabIndex = 14
Top = 630
Width = 6450
End
Begin VB.Label lblNewStatsLine2
Height = 285
Left = 1035
TabIndex = 22
Top = 1305
Width = 7170
End
Begin VB.Label lblNewStream
Height = 330
Left = 1080
TabIndex = 21
Top = 990
Width = 6495
End
Begin VB.Label Label2
Caption = "New Stream;"
Height = 285
Left = 90
TabIndex = 13
Top = 630
Width = 1095
End
Begin VB.Label lblReplaceStats
Caption = "Label2"
Height = 375
Left = 180
TabIndex = 12
Top = 225
Width = 4020
End
Begin VB.Label lblClose
BackColor = &H00FFFFFF&
Caption = " X "
BeginProperty Font
Name = "MS Sans Serif"
Size = 13.5
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 7830
TabIndex = 11
Top = 45
Width = 465
End
End
Begin VB.CommandButton cmdStop
Caption = "Stop"
Height = 330
Left = 13230
TabIndex = 9
Top = 45
Width = 825
End
Begin MSComctlLib.ProgressBar pb
Height = 240
Left = 90
TabIndex = 8
Top = 450
Width = 13920
_ExtentX = 24553
_ExtentY = 423
_Version = 393216
Appearance = 0
End
Begin VB.CommandButton Command3
Caption = "?"
Height = 330
Left = 11565
TabIndex = 7
Top = 45
Width = 465
End
Begin RichTextLib.RichTextBox rtf
Height = 5280
Left = 3150
TabIndex = 6
Top = 2565
Width = 10905
_ExtentX = 19235
_ExtentY = 9313
_Version = 393217
ScrollBars = 2
TextRTF = $"frmBruteZLib.frx":0000
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "Courier"
Size = 9.75
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
End
Begin VB.CommandButton Command2
Caption = "..."
Height = 330
Left = 11025
TabIndex = 5
Top = 45
Width = 465
End
Begin VB.TextBox txtDetails
BeginProperty Font
Name = "Courier"
Size = 9.75
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 1725
Left = 3150
MultiLine = -1 'True
ScrollBars = 2 'Vertical
TabIndex = 4
Top = 720
Width = 10905
End
Begin MSComctlLib.ListView lv
Height = 7125
Left = 90
TabIndex = 3
Top = 720
Width = 2985
_ExtentX = 5265
_ExtentY = 12568
View = 3
LabelEdit = 1
MultiSelect = -1 'True
LabelWrap = -1 'True
HideSelection = 0 'False
FullRowSelect = -1 'True
GridLines = -1 'True
_Version = 393217
ForeColor = -2147483640
BackColor = -2147483643
BorderStyle = 1
Appearance = 1
NumItems = 1
BeginProperty ColumnHeader(1) {BDD1F052-858B-11D1-B16A-00C0F0283628}
Object.Width = 2540
EndProperty
End
Begin VB.CommandButton Command1
Caption = "Zlib Brute"
Height = 330
Left = 12060
TabIndex = 2
Top = 45
Width = 1140
End
Begin VB.TextBox txtFile
Height = 330
Left = 810
OLEDropMode = 1 'Manual
TabIndex = 1
Text = "Drag And Drop file here"
Top = 45
Width = 8100
End
Begin VB.Label Label1
Caption = "Load File"
Height = 285
Left = 45
TabIndex = 0
Top = 45
Width = 870
End
Begin VB.Menu mnuPopup
Caption = "mnuPopup"
Visible = 0 'False
Begin VB.Menu mnuStrings
Caption = "Strings"
Visible = 0 'False
End
Begin VB.Menu mnuSearchStreams
Caption = "Search Streams"
End
Begin VB.Menu mnuSaveToFile
Caption = "Save Stream"
End
Begin VB.Menu mnuSaveAll
Caption = "Save All"
End
Begin VB.Menu mnuSpacer
Caption = "-"
End
Begin VB.Menu mnuReplaceStream
Caption = "Replace Stream"
End
Begin VB.Menu mnuCopyAllStats
Caption = "Copy Stats for all Streams"
End
Begin VB.Menu mnuCompareWithMain
Caption = "Compare to Streams in Main UI"
End
End
End
Attribute VB_Name = "frmBruteZLib"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim selli As ListItem
Dim abort As Boolean
Dim replacementStream As CPDFStream
Private Sub cmdLoadNewStream_Click()
Dim f As Long
Dim b() As Byte
Dim c As CPDFStream
On Error Resume Next
Set c = selli.tag
If c Is Nothing Then
fraReplaceStream.Visible = False
Exit Sub
End If
txtNewStream.Text = Form1.dlg.OpenDialog(AllFiles, , , Me.hwnd)
If fso.FileExists(txtNewStream) Then
Set replacementStream = New CPDFStream
f = FreeFile
Open txtNewStream For Binary As f
ReDim b(LOF(f))
Get f, , b()
Close f
With replacementStream
.DecompressedData = StrConv(b(), vbUnicode, LANG_US)
.DecompressedSize = Len(.DecompressedData)
.OriginalData = SimpleCompress(.DecompressedData)
.CompressedSize = Len(.OriginalData)
lblNewStream = "RawSize: " & Hex(.DecompressedSize) & " Compressed: " & Hex(.CompressedSize)
lblNewStatsLine2 = "Replacement stream is " & Abs(c.CompressedSize - .CompressedSize) & _
" " & IIf(c.CompressedSize > .CompressedSize, "SMALLER", "BIGGER") & _
" than original"
If .CompressedSize > c.CompressedSize Then
chkPadifSmaller.Value = 0
chkPadifSmaller.enabled = False
End If
End With
End If
End Sub
Private Sub cmdStop_Click()
abort = True
End Sub
Private Sub Command1_Click()
If Not fso.FileExists(txtFile) Then Exit Sub
On Error Resume Next
If Not csharp.Initilized Then
MsgBox csharp.ErrorMessage, vbExclamation
Exit Sub
End If
Dim f As Long
Dim b() As Byte
Dim bOut() As Byte
Dim tmp() As Byte
Dim d As String
Dim c As CPDFStream
Dim li As ListItem
Dim i As Long
abort = False
lv.ListItems.Clear
pb.Value = 0
rtf.Text = Empty
txtDetails = Empty
f = FreeFile
Open txtFile For Binary As f
ReDim b(LOF(f))
Get f, , b()
Close f
For i = 0 To UBound(b)
setPB i, UBound(b)
DoEvents
Me.Refresh
DoEvents
If abort Then Exit For
If csharp.QuickDeflate(b(), bOut(), i, optZlib.Value) Then
Module4.CompressData bOut, tmp 'figure out how big compressed block was
Set c = New CPDFStream
c.startOffset = i - 1
If Not AryIsEmpty(tmp) Then
c.EndOffset = i + UBound(tmp) - 1
Erase tmp
Else
c.EndOffset = 0
End If
c.DecompressedSize = UBound(bOut)
c.DecompressedData = StrConv(bOut, vbUnicode, LANG_US)
c.DecompressedDataCRC = CRC32(c.DecompressedData)
c.CompressedSize = c.EndOffset - c.startOffset
Set li = lv.ListItems.Add(, , "offset: 0x" & Hex(c.startOffset) & " sz: 0x" & Hex(c.DecompressedSize))
Set li.tag = c
If c.EndOffset <> 0 Then i = c.EndOffset 'advance file pointer to after this chunk
csharp.DecodedBuffer = Empty
End If
Next
pb.Value = 0
MsgBox lv.ListItems.Count & " Streams found!", vbInformation
End Sub
'Private Sub Command1_Click()
'
' If Not fso.FileExists(txtFile) Then Exit Sub
'
' On Error Resume Next
'
' If Not csharp.Initilized Then
' MsgBox csharp.ErrorMessage, vbExclamation
' Exit Sub
' End If
'
' Dim f As Long
' Dim b() As Byte
' Dim bOut() As Byte
' Dim tmp() As Byte
' Dim d As String
'
' Dim c As CPDFStream
'
' Dim li As ListItem
' Dim i As Long
'
' abort = False
' lv.ListItems.Clear
' pb.Value = 0
' rtf.Text = Empty
' txtDetails = Empty
'
' f = FreeFile
' Open txtFile For Binary As f
' ReDim b(LOF(f))
' Get f, , b()
' Close f
'
' 'this can be horrbily slow on large byte buffers since we are doing it all as string
' 'manipulations and then converting back and forth ALLOT..I should optimize this to make it faster
' 'but this is just an add on right now using existing code, this can be much improved..but for now
' 'it is what it is...the native zlib class didnt work for this for some reason. would be way faster
'
' d = StrConv(b, vbUnicode, LANG_US)
'
' For i = 0 To UBound(b)
'
' csharp.decode Mid(d, i), FlateDecode
'
' 'Module4.UncompressData b, bout, i
' setPB i, UBound(b)
' DoEvents
' Me.Refresh
' DoEvents
' If abort Then Exit For
'
' 'If Not AryIsEmpty(bout) Then
' If Len(csharp.DecodedBuffer) > 0 Then
' bOut = StrConv(csharp.DecodedBuffer, vbFromUnicode, LANG_US)
' Module4.CompressData bOut, tmp 'figure out how big compressed block was
' Set c = New CPDFStream
' c.startOffset = i - 1
'
' If Not AryIsEmpty(tmp) Then
' c.EndOffset = i + UBound(tmp) - 1
' Erase tmp
' Else
' c.EndOffset = 0
' End If
'
' c.DecompressedSize = UBound(bOut)
' c.DecompressedData = StrConv(bOut, vbUnicode, LANG_US)
' c.DecompressedDataCRC = CRC32(c.DecompressedData)
'
' Set li = lv.ListItems.Add(, , "offset: 0x" & Hex(c.startOffset) & " sz: 0x" & Hex(c.DecompressedSize))
' Set li.tag = c
'
' If c.EndOffset <> 0 Then i = c.EndOffset 'advance file pointer to after this chunk
' csharp.DecodedBuffer = Empty
'
' End If
' Next
'
' pb.Value = 0
' MsgBox lv.ListItems.Count & " Streams found!", vbInformation
'
'
'End Sub
Function AryIsEmpty(ary) As Boolean
On Error Resume Next
x = UBound(ary)
If x = -1 Or Err.Number <> 0 Then AryIsEmpty = True
End Function
Sub setPB(i, tot)
On Error Resume Next
pcent = CInt((i / tot) * 100)
If pcent >= 100 Then pb.Value = 0 Else pb.Value = pcent
End Sub
Private Sub Command2_Click()
f = Form1.dlg.OpenDialog(AllFiles, , , Me.hwnd)
If Len(f) = 0 Then Exit Sub
txtFile = f
Command1_Click
End Sub
Private Sub Command3_Click()
Const msg = "This interface will go through a file byte by byte trying to\n" & _
" find sections compressed with ZLIB. Found offsets will be added to \n" & _
"the list on the left, details on top, hexdump on bottom. Right click on \n" & _
"listview to save data to file.\n\n" & _
"This can be slow on large files, progress can jump quickly however as it \n" & _
"skips past compressed blocks it finds"
MsgBox Replace(msg, "\n", vbCrLf), vbInformation
End Sub
Private Sub Command4_Click()
If replacementStream Is Nothing Then
MsgBox "No replacement stream loaded yet.", vbInformation
Exit Sub
End If
On Error Resume Next
Dim c As CPDFStream
Set c = selli.tag
Dim f As String
Dim fNew As Long, fBase As Long
Dim b() As Byte, new_bytes() As Byte
txtNew = Form1.dlg.SaveDialog(AllFiles, fso.GetParentFolder(txtFile), , , Me.hwnd, _
"mod_" & fso.GetBaseName(txtFile) & "." & fso.GetExtension(txtFile))
If Len(txtNew) = 0 Then Exit Sub
With replacementStream
If .CompressedSize < c.CompressedSize And chkPadifSmaller.Value = 1 Then
If Option1(0).Value = True Then 'pad before recompression...
MsgBox "do stuff here"
Exit Sub
Else
diff = c.CompressedSize - .CompressedSize
.OriginalData = .OriginalData & String(diff, Chr(CLng("&h" & txtPadChar)))
.CompressedSize = Len(.OriginalData)
If .CompressedSize <> c.CompressedSize Then Stop
End If
End If
new_bytes() = StrConv(replacementStream.OriginalData, vbFromUnicode, LANG_US)
fBase = FreeFile
Open txtFile For Binary As fBase
fNew = FreeFile
Open txtNew For Binary As fNew
ReDim b(c.startOffset)
Get fBase, , b() 'load the file up to the original stream
Put fNew, , b() 'save it to the new file
Put fNew, , new_bytes() 'save our new stream to new file
'ReDim b(stream.CompressedSize)
'Get f, , b() 'advance file pointer size of orginal compressed data
ReDim b(LOF(fBase) - c.EndOffset)
Get fBase, c.EndOffset + 1, b() 'load teh rest of the original file
Put fNew, , b() 'save rest of file to new file
Close fBase
Close fNew
End With
If Err.Number <> 0 Then
MsgBox "Error: " & Err.Description, vbExclamation
Else
MsgBox "File successfully created.", vbInformation
fraReplaceStream.Visible = False
lv.enabled = True
End If
End Sub
Private Sub Form_Load()
Me.Icon = Form1.Icon
pb.Value = 0
lv.ColumnHeaders(1).Width = lv.Width - 100
txtFile = Form1.txtPDFPath
optLZW.Visible = isIde()
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
abort = True
End Sub
Private Sub lblClose_Click()
fraReplaceStream.Visible = False
lv.enabled = True
End Sub
Private Sub lv_ItemClick(ByVal Item As MSComctlLib.ListItem)
On Error Resume Next
Dim c As CPDFStream
Set selli = Nothing
Set c = Item.tag
If c Is Nothing Then Exit Sub
rtf.Text = Empty
Set selli = Item
r = "Start Offset: 0x" & Hex(c.startOffset) & " (" & c.startOffset & ")" & vbCrLf
r = r & "End Offset: 0x" & Hex(c.EndOffset) & " (" & c.EndOffset & ")" & vbCrLf
r = r & "DecompressedSize: 0x" & Hex(c.DecompressedSize) & " (" & c.DecompressedSize & ")" & vbCrLf
r = r & "DecompressedDataCRC: " & c.DecompressedDataCRC & vbCrLf
txtDetails = r
rtf.Text = HexDump(c.DecompressedData)
End Sub
Private Sub lv_MouseUp(Button As Integer, Shift As Integer, x As Single, Y As Single)
If Button = 2 Then PopupMenu mnuPopup
End Sub
Private Sub mnuCompareWithMain_Click()
On Error Resume Next
Dim c As CPDFStream
Dim li As ListItem
Dim matches As Long
If lv.ListItems.Count = 0 Then
MsgBox "No streams loaded in zlib brute. This feature will compare streams found by bruting with streams found by pdf parsing and remove all common streams from this form to see if any were hidden.", vbInformation
Exit Sub
End If
If Form1.lv.ListItems.Count = 0 Then
MsgBox "No streams loaded in main UI listview nothing to do", vbInformation
Exit Sub
End If
For i = lv.ListItems.Count To 1 Step -1
Set li = lv.ListItems(i)
Set c = li.tag
If FindStreamInMain(c) Then
lv.ListItems.Remove i
matches = matches + 1
End If
Next
MsgBox matches & " made - " & lv.ListItems.Count & " hidden streams identified!"
End Sub
Function FindStreamInMain(c As CPDFStream) As Boolean
Dim m As CPDFStream
For Each li In Form1.lv.ListItems
Set m = li.tag
If m.isCompressed Then
If m.startOffset = c.startOffset + 1 Then
FindStreamInMain = True
Exit Function
End If
End If
Next
End Function
Private Sub mnuCopyAllStats_Click()
On Error Resume Next
Dim c As CPDFStream
Dim li As ListItem
If lv.ListItems.Count = 0 Then Exit Sub
For Each li In lv.ListItems
Set c = li.tag
r = r & "Start Offset: 0x" & Hex(c.startOffset) & " (" & c.startOffset & ")" & vbCrLf
r = r & "End Offset: 0x" & Hex(c.EndOffset) & " (" & c.EndOffset & ")" & vbCrLf
r = r & "DecompressedSize: 0x" & Hex(c.DecompressedSize) & " (" & c.DecompressedSize & ")" & vbCrLf
r = r & "DecompressedDataCRC: " & c.DecompressedDataCRC & vbCrLf & vbCrLf
Next
Clipboard.Clear
Clipboard.SetText r
MsgBox Len(r) & " bytes saved to clipboard", vbInformation
End Sub
Private Sub mnuReplaceStream_Click()
If selli Is Nothing Then Exit Sub
If InStr(1, App.path, "ftp_root", vbTextCompare) < 1 Then
MsgBox "Not quite debugged yet..", vbInformation
Exit Sub
End If
Dim c As CPDFStream
Set c = selli.tag
lblReplaceStats = "Start Offsest: " & Hex(c.startOffset) & " Compressed Size: " & Hex(c.CompressedSize)
lv.enabled = False 'dont want selli to be updated...
Set replacementStream = Nothing
fraReplaceStream.Visible = True
End Sub
Private Sub mnuSaveAll_Click()
On Error Resume Next
Dim c As CPDFStream
Dim li As ListItem
Dim d As String
Dim f As String
Dim ok As Long
If lv.ListItems.Count = 0 Then Exit Sub
d = Form1.dlg.FolderDialog(, Me.hwnd)
If Len(d) = 0 Then Exit Sub
For Each li In lv.ListItems
Set c = li.tag
f = d & "\zbrute_" & Hex(c.startOffset) & ".dat"
If fso.FileExists(f) Then Kill f
If SaveStream(c, f) Then ok = ok + 1
Next
MsgBox ok & "/" & lv.ListItems.Count & " Streams saved successfully!", vbInformation
End Sub
Private Sub mnuSaveToFile_Click()
On Error Resume Next
Dim c As CPDFStream
If selli.tag Is Nothing Then Exit Sub
Set c = selli.tag
f = Form1.dlg.SaveDialog(AllFiles, , "Save file as", , Me.hwnd, "zbrute_" & Hex(c.startOffset) & ".dat")
If Len(f) = 0 Then Exit Sub
MsgBox "Saved to file: " & SaveStream(c, f)
End Sub
Function SaveStream(c As CPDFStream, fPath) As Boolean
On Error Resume Next
Dim b() As Byte
Dim f As Long
b() = StrConv(c.DecompressedData, vbFromUnicode, LANG_US)
f = FreeFile
Open fPath For Binary As f
Put f, , b()
Close f
SaveStream = IIf(Err.Number = 0, True, False)
End Function
Private Sub mnuSearchStreams_Click()
On Error Resume Next
Dim c As CPDFStream
Dim li As ListItem
Dim d As String
Dim f As String
Dim ok As Long
If lv.ListItems.Count = 0 Then Exit Sub
d = InputBox("Search for:")
If Len(d) = 0 Then Exit Sub
For Each li In lv.ListItems
Set c = li.tag
ok = InStr(1, c.DecompressedData, d, vbTextCompare)
If ok > 0 Then
f = f & li.Text & " offset: 0x" & Hex(ok) & vbCrLf
End If
Next
If Len(f) > 0 Then
MsgBox "Found " & d & " in: " & vbCrLf & vbCrLf & f
Else
MsgBox "String fragment not found in any streams", vbInformation
End If
End Sub
Private Sub txtFile_OLEDragDrop(Data As DataObject, Effect As Long, Button As Integer, Shift As Integer, x As Single, Y As Single)
On Error Resume Next
txtFile = Data.Files(1)
Command1_Click
End Sub