-
Notifications
You must be signed in to change notification settings - Fork 59
/
Copy pathForm2.frm
1893 lines (1563 loc) · 53.3 KB
/
Form2.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
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
VERSION 5.00
Object = "{0E59F1D2-1FBE-11D0-8FF2-00A0D10038BC}#1.0#0"; "msscript.ocx"
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 Form2
Caption = "PDF Stream Dumper - JS UI"
ClientHeight = 8310
ClientLeft = 165
ClientTop = 735
ClientWidth = 14460
LinkTopic = "Form2"
ScaleHeight = 8310
ScaleWidth = 14460
StartUpPosition = 3 'Windows Default
Begin MSComctlLib.ListView lv2
Height = 2670
Left = 30
TabIndex = 17
Top = 5580
Width = 2295
_ExtentX = 4048
_ExtentY = 4710
View = 3
LabelEdit = 1
LabelWrap = -1 'True
HideSelection = -1 'True
FullRowSelect = -1 'True
GridLines = -1 'True
_Version = 393217
ForeColor = -2147483640
BackColor = -2147483643
BorderStyle = 1
Appearance = 1
NumItems = 2
BeginProperty ColumnHeader(1) {BDD1F052-858B-11D1-B16A-00C0F0283628}
Text = "msg"
Object.Width = 2540
EndProperty
BeginProperty ColumnHeader(2) {BDD1F052-858B-11D1-B16A-00C0F0283628}
SubItemIndex = 1
Text = "data"
Object.Width = 2540
EndProperty
End
Begin MSScriptControlCtl.ScriptControl sc
Left = 13770
Top = 90
_ExtentX = 1005
_ExtentY = 1005
Language = "javascript"
End
Begin MSScriptControlCtl.ScriptControl sc2
Left = 13140
Top = 90
_ExtentX = 1005
_ExtentY = 1005
Language = "Javascript"
End
Begin PDFStreamDumper.ucScint txtJS
Height = 5865
Left = 2430
TabIndex = 16
Top = 270
Width = 11895
_ExtentX = 12171
_ExtentY = 6853
End
Begin VB.Frame splitter
BackColor = &H00808080&
Height = 75
Left = 2400
MousePointer = 7 'Size N S
TabIndex = 9
Top = 6840
Width = 11895
End
Begin VB.Frame Frame1
Caption = "THIS RUNS SCRIPTS LIVE -- NO SANDBOX -- (also watch for Adobe specific objects)"
ForeColor = &H00000080&
Height = 615
Left = 2400
TabIndex = 4
Top = 6180
Width = 11895
Begin VB.TextBox txtPageNum
Height = 285
Left = 5220
TabIndex = 15
Text = "0"
Top = 225
Width = 465
End
Begin VB.CheckBox chkNoResest
Caption = "No Reset"
Height = 195
Left = 10665
TabIndex = 13
ToolTipText = "Check this to not reset the script control between runs (reset clears vars from old scripts which may be needed)"
Top = 270
Width = 1005
End
Begin VB.ComboBox cboVersion
Height = 315
Left = 2790
TabIndex = 11
Top = 225
Width = 1320
End
Begin VB.CommandButton cmdRun
Caption = "Run"
Height = 375
Left = 8730
TabIndex = 5
Top = 180
Width = 1455
End
Begin VB.Label Label3
Caption = "this.pageNum"
Height = 285
Left = 4185
TabIndex = 14
Top = 270
Width = 1005
End
Begin VB.Label Label2
Caption = "app.viewerVersion :"
Height = 285
Left = 1350
TabIndex = 12
Top = 270
Width = 1455
End
Begin VB.Label lblToolbox
Caption = "Options"
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 400
Underline = -1 'True
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FF0000&
Height = 255
Index = 3
Left = 8010
TabIndex = 8
Top = 270
Width = 585
End
Begin VB.Label lblClipboard
Caption = "<-- to clipboard"
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 400
Underline = -1 'True
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FF0000&
Height = 255
Index = 1
Left = 120
TabIndex = 7
Top = 240
Width = 1215
End
Begin VB.Label lblClipboard
Caption = "^ to script pane"
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 400
Underline = -1 'True
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FF0000&
Height = 255
Index = 2
Left = 5805
TabIndex = 6
Top = 270
Width = 1230
End
End
Begin RichTextLib.RichTextBox old_txtJs
Height = 5895
Left = 2430
TabIndex = 3
Top = 270
Visible = 0 'False
Width = 11895
_ExtentX = 20981
_ExtentY = 10398
_Version = 393217
HideSelection = 0 'False
ScrollBars = 2
TextRTF = $"Form2.frx":0000
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "Courier New"
Size = 12
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
End
Begin MSComctlLib.ListView lv
Height = 2775
Left = 45
TabIndex = 1
Top = 270
Width = 2295
_ExtentX = 4048
_ExtentY = 4895
View = 3
LabelEdit = 1
MultiSelect = -1 'True
LabelWrap = -1 'True
HideSelection = 0 'False
_Version = 393217
ForeColor = -2147483640
BackColor = -2147483643
BorderStyle = 1
Appearance = 1
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "Courier New"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
NumItems = 1
BeginProperty ColumnHeader(1) {BDD1F052-858B-11D1-B16A-00C0F0283628}
Text = "Saved Scripts"
Object.Width = 2540
EndProperty
End
Begin RichTextLib.RichTextBox txtOut
Height = 1275
Left = 2400
TabIndex = 10
Top = 6960
Width = 11895
_ExtentX = 20981
_ExtentY = 2249
_Version = 393217
HideSelection = 0 'False
ScrollBars = 2
TextRTF = $"Form2.frx":0080
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "Courier New"
Size = 12
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
End
Begin MSComctlLib.ListView lvFunc
Height = 2490
Left = 60
TabIndex = 18
Top = 3060
Width = 2295
_ExtentX = 4048
_ExtentY = 4392
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}
Text = "Functions"
Object.Width = 2540
EndProperty
End
Begin VB.Label lblClipboard
Caption = "<-- to clipboard"
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 400
Underline = -1 'True
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FF0000&
Height = 255
Index = 0
Left = 2400
TabIndex = 2
Top = 0
Width = 1215
End
Begin VB.Label Label1
Caption = "Script"
BeginProperty Font
Name = "Courier New"
Size = 11.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 3600
TabIndex = 0
Top = 0
Width = 975
End
Begin VB.Menu mnuMainLoadFile
Caption = "Load"
Begin VB.Menu mnuLoadFile
Caption = "Load JavaScript"
End
Begin VB.Menu mnuLoadShellcode
Caption = "Load Shellcode"
End
End
Begin VB.Menu mnuBeautify
Caption = "Format_Javascript"
End
Begin VB.Menu mnuUnescapeSelection
Caption = "Unescape_Selection"
End
Begin VB.Menu mnuManualEscapes
Caption = "Manual_Escapes"
Begin VB.Menu mnuManualEscape
Caption = "HexString Unescape (Preserve White Space)"
Index = 0
End
Begin VB.Menu mnuManualEscape
Caption = "HexString Unescape (Strip White Space)"
Index = 1
End
Begin VB.Menu mnuManualEscape
Caption = "% Unescape"
Index = 2
End
Begin VB.Menu mnuManualEscape
Caption = "\x Unescape"
Index = 3
End
Begin VB.Menu mnuManualEscape
Caption = "\n Unescape"
Index = 4
End
Begin VB.Menu mnuManualEscape
Caption = "# Unescape"
Index = 5
End
Begin VB.Menu mnuManualEscape
Caption = "Octal UnEscape"
Index = 6
End
Begin VB.Menu mnuAddPercentoHexString
Caption = "Add % to HexString"
End
Begin VB.Menu mnuVarPrefix
Caption = "Prefix Sel Lines with var"
End
Begin VB.Menu mnuHex2Unicode
Caption = "HexString to %u encoded"
End
End
Begin VB.Menu mnuExploitScan
Caption = "Exploit_Scan"
End
Begin VB.Menu mnuSimplifySelection
Caption = "Simplify_Selection_Quotes"
End
Begin VB.Menu mnuShellcodeUI
Caption = "Shellcode_Analysis"
Begin VB.Menu mnuLaunchSclog
Caption = "scLog ( iDefense - Runs Live)"
Index = 0
End
Begin VB.Menu mnuLaunchSclog
Caption = "scDbg ( libEmu - Emulation )"
Index = 1
End
Begin VB.Menu mnuScSigs
Caption = "scSigs (Sig Check + libemu Unpack)"
End
Begin VB.Menu mnuXorBruteForce
Caption = "Xor BruteForcer"
End
Begin VB.Menu mnuspacer99
Caption = "-"
End
Begin VB.Menu mnuSaveShellcode
Caption = "Save Bytes to file"
End
Begin VB.Menu mnuSc2ExeMain
Caption = "Shellcode 2 Exe"
Begin VB.Menu mnuShellcode2Exe
Caption = "Simple Husk (sc 0x401000)"
Index = 0
End
Begin VB.Menu mnuShellcode2Exe
Caption = "Simple Husk w/Wsa Startup (sc 0x401020)"
Index = 1
End
Begin VB.Menu mnuShellcode2Exe
Caption = "New Husk (supports cmdline + 6k sc buf)"
Index = 2
End
End
Begin VB.Menu mnuSend2IDA
Caption = "Disassemble in IDA"
End
Begin VB.Menu mnuspacer2
Caption = "-"
End
Begin VB.Menu mnuSample
Caption = "Sample Shellcode"
Begin VB.Menu mnuShellcode
Caption = "Copy sc files to /sc_samples directory to load list"
Index = 0
End
Begin VB.Menu mnuShellcode
Caption = "samples removed due to AV alert"
Index = 1
End
End
End
Begin VB.Menu mnuReplace
Caption = "Find/Replace"
End
Begin VB.Menu mnuDeobTools
Caption = "Deobsfuscation Tools"
Begin VB.Menu mnuBasicRefactor
Caption = "Basic Refactor"
End
Begin VB.Menu mnuStripInlineDecoderCalls
Caption = "Strip Inline Decoder Calls"
End
End
Begin VB.Menu mnuPopup
Caption = "mnuPopup"
Visible = 0 'False
Begin VB.Menu mnuSaveAll
Caption = "Save All"
End
Begin VB.Menu mnuSaveToFile
Caption = "Save to file"
End
Begin VB.Menu mnuSpacer5
Caption = "-"
End
Begin VB.Menu mnuCopyToJs
Caption = "Copy to JS TextBox"
End
Begin VB.Menu mnuCopyToLower
Caption = "Copy To Lower TextBox"
End
Begin VB.Menu mnuSpacer4
Caption = "-"
End
Begin VB.Menu mnuRenameScript
Caption = "Rename Entry"
End
Begin VB.Menu mnuRemoveEntry
Caption = "Remove Entry"
End
Begin VB.Menu mnuClearAll
Caption = "Clear All"
End
End
Begin VB.Menu mnuPopup2
Caption = "mnuPopup2"
Visible = 0 'False
Begin VB.Menu mnuGotoLine
Caption = "Goto Line"
End
Begin VB.Menu mnuQuickEval
Caption = "Quick Eval"
End
Begin VB.Menu mnuCopyFuncsNames
Caption = "Copy Func Names"
End
Begin VB.Menu mnuShowHelp
Caption = "Show Help"
End
Begin VB.Menu mnuWordWrap
Caption = "Word Wrap"
End
Begin VB.Menu mnuCodeFolding
Caption = "Code Folding"
End
Begin VB.Menu mnuCollapseAll
Caption = "Collapse/Expand All"
End
Begin VB.Menu mnuScintillaOptions
Caption = "Scintilla Options"
End
Begin VB.Menu mnuIndentGuide
Caption = "Show Indent Guides"
End
Begin VB.Menu mnuAutoComplete
Caption = "AutoComplete on CtrlSpace"
End
End
Begin VB.Menu mnuPopup3
Caption = "mnuPopup3"
Visible = 0 'False
Begin VB.Menu mnuCopyAllDatalv2
Caption = "Copy All w/Data"
End
End
Begin VB.Menu mnuPopupFuncs
Caption = "mnuPopupFuncs"
Visible = 0 'False
Begin VB.Menu mnuFunctionScan
Caption = "Rescan"
End
Begin VB.Menu mnuRenameFunc
Caption = "Rename (N)"
End
Begin VB.Menu mnuExtractFunc
Caption = "Extract"
End
Begin VB.Menu mnuCopyFuncNames
Caption = "Copy All Names"
End
Begin VB.Menu mnuFindFuncRefs
Caption = "Find All References"
End
Begin VB.Menu mnuFindFuncDependancies
Caption = "Function Dependancies"
End
End
End
Attribute VB_Name = "Form2"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'Author: [email protected]
'Site: http://sandsprite.com
Dim dlg As New clsCmnDlg
Dim toolbox As New CScriptFunctions
'splitter code taken from sample by Bruce Fast, submitted to the public domain. thanks!
'todo: we could add our listview to the toolbox class so scripts can pull
'saved script variables directly from there via something like
' savedVar1 = tb.lv.listitems(index).tag
'even if i am the only one who would use that :P
Private Capturing As Boolean
Private Declare Function SetCapture Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function ReleaseCapture Lib "user32" () As Long
Private objsAdded As Boolean
Dim USING_MYMAIN As Boolean
Private Declare Function SetFilePointer Lib "kernel32" (ByVal hFile As Long, ByVal lDistanceToMove As Long, lpDistanceToMoveHigh As Long, ByVal dwMoveMethod As Long) As Long
Public Function StandardizeLineBreaks(ByVal x)
x = Replace(x, vbCrLf, Chr(5))
x = Replace(x, vbCr, Chr(5))
x = Replace(x, vbLf, Chr(5))
StandardizeLineBreaks = Replace(x, Chr(5), vbCrLf)
End Function
Private Sub lv2_ItemClick(ByVal Item As MSComctlLib.ListItem)
On Error Resume Next
If Len(Item.SubItems(1)) > 0 Then
txtOut.Text = Item.SubItems(1)
Else
txtOut.Text = Item.Text
End If
End Sub
Private Sub lv2_MouseUp(Button As Integer, Shift As Integer, x As Single, Y As Single)
If Button = 2 Then PopupMenu mnuPopup3
End Sub
Private Sub lvFunc_ColumnClick(ByVal ColumnHeader As MSComctlLib.ColumnHeader)
LV_ColumnSort lvFunc, ColumnHeader
End Sub
Private Sub lvFunc_DblClick()
On Error Resume Next
If Not lvFunc.SelectedItem Is Nothing Then
'txtJS.GotoLine lvFunc.SelectedItem.tag
txtJS.FirstVisibleLine = CLng(lvFunc.SelectedItem.tag)
txtJS.SelectLine
End If
End Sub
Private Sub lvFunc_KeyPress(KeyAscii As Integer)
If KeyAscii = Asc("N") Or KeyAscii = Asc("n") Then
mnuRenameFunc_Click
KeyAscii = 0
End If
End Sub
Private Sub lvFunc_MouseUp(Button As Integer, Shift As Integer, x As Single, Y As Single)
If Button = 2 Then PopupMenu mnuPopupFuncs
End Sub
Private Sub mnuAutoComplete_Click()
mnuAutoComplete.Checked = Not mnuAutoComplete.Checked
txtJS.AutoCompleteOnCTRLSpace = mnuAutoComplete.Checked
End Sub
Private Sub mnuCodeFolding_Click()
mnuCodeFolding.Checked = Not mnuCodeFolding.Checked
txtJS.Folding = mnuCodeFolding.Checked
End Sub
Private Sub mnuCollapseAll_Click()
If mnuCodeFolding.Checked = False Then mnuCodeFolding_Click
txtJS.SCI.FoldAll
End Sub
Private Sub mnuCopyAllDatalv2_Click()
On Error Resume Next
Dim li As ListItem
For Each li In lv2.ListItems
If Len(li.SubItems(1)) > 0 Then
ret = ret & li.SubItems(1) & vbCrLf
End If
Next
Clipboard.Clear
Clipboard.SetText ret
MsgBox Len(ret) & " bytes copied", vbInformation
End Sub
Private Sub mnuCopyFuncNames_Click()
Dim li As ListItem
Dim tmp
For Each li In lvFunc.ListItems
tmp = tmp & li.Text & vbCrLf
Next
Clipboard.Clear
Clipboard.SetText tmp
MsgBox Len(tmp) & " bytes copied", vbInformation
End Sub
Private Sub mnuCopyFuncsNames_Click()
On Error Resume Next
x = Split(txtJS.Text, vbCrLf)
For Each Y In x
If InStr(Y, "function") > 0 Then
tmp = tmp & Y & vbCrLf
End If
Next
tmp = Replace(tmp, vbTab, Empty)
Clipboard.Clear
Clipboard.SetText tmp
MsgBox UBound(Split(tmp, vbCrLf)) & " lines copied to clipboard"
End Sub
Private Sub mnuCopyToJs_Click()
On Error Resume Next
If lv.SelectedItem Is Nothing Then Exit Sub
txtJS.Text = lv.SelectedItem.tag
End Sub
Private Sub mnuCopyToLower_Click()
On Error Resume Next
If lv.SelectedItem Is Nothing Then Exit Sub
txtOut.Text = lv.SelectedItem.tag
End Sub
Private Function ExtractFunction(startLine As Long, Optional ByRef foundEnd) As String
data = vbCrLf & vbCrLf
startLine = startLine - 1
tmp = Split(txtJS.Text, vbCrLf)
i = -1
data = vbCrLf & vbCrLf
foundEnd = False
For Each x In tmp
i = i + 1
If i > startLine Then
data = data & x & vbCrLf
If RTrim(x) = "}" Then
foundEnd = True
Exit For
End If
End If
Next
ExtractFunction = data & vbCrLf & vbCrLf
End Function
Private Sub mnuExpandAll_Click()
If mnuCodeFolding.Checked = True Then mnuCodeFolding_Click
End Sub
Private Sub mnuExtractFunc_Click()
On Error Resume Next
If lvFunc.SelectedItem Is Nothing Then Exit Sub
Dim li As ListItem
Dim data As String
Dim foundEnd As Boolean
For Each li In lvFunc.ListItems
If li.selected Then
data = data & ExtractFunction(CLng(li.tag), foundEnd)
If Not foundEnd Then Exit Sub
End If
Next
tmp = fso.GetFreeFileName(Environ("temp"))
fso.writeFile tmp, data & vbCrLf & vbCrLf
Shell "notepad.exe " & tmp, vbNormalFocus
End Sub
Private Sub mnuFindFuncDependancies_Click()
On Error Resume Next
If lvFunc.SelectedItem Is Nothing Then Exit Sub
Dim li As ListItem
Dim data As String
Dim foundEnd As Boolean
Dim func() As String
startFunc = lvFunc.SelectedItem.Text
data = ExtractFunction(CLng(lvFunc.SelectedItem.tag), foundEnd)
For Each li In lvFunc.ListItems
If li.Text <> startFunc Then li.selected = False
If InStr(data, li.Text & "(") > 0 And li.Text <> startFunc Then
push func, li.Text
li.selected = True
End If
Next
report = "Non Recursive function references found within: " & startFunc & vbCrLf & vbCrLf
report = report & vbTab & Join(func, vbCrLf & vbTab)
tmp = fso.GetFreeFileName(Environ("temp"))
fso.writeFile tmp, report
Shell "notepad.exe " & tmp, vbNormalFocus
End Sub
Private Sub mnuFindFuncRefs_Click()
On Error Resume Next
If lvFunc.SelectedItem Is Nothing Then Exit Sub
Find = lvFunc.SelectedItem.Text
If Len(Find) = 0 Then Exit Sub
frmReplace.LaunchReplaceForm txtJS
frmReplace.Text1 = Find
frmReplace.cmdFindAll_Click
End Sub
Public Sub mnuFunctionScan_Click()
'very quick and dirty function scan, assumes you already ran format js
On Error Resume Next
Dim li As ListItem
lvFunc.ListItems.Clear
i = -1
tmp = Split(txtJS.Text, vbCrLf)
For Each x In tmp
i = i + 1
func = Empty
If x Like "function *(*)*" And GetCount(x, "function") = 2 Then
a = InStr(x, "(")
b = InStrRev(x, " ", a)
func = Trim(Mid(x, b, a - b))
If Len(func) > 0 Then
Set li = lvFunc.ListItems.Add(, , func)
li.tag = i
End If
End If
Next
End Sub
Private Sub mnuGotoLine_Click()
On Error Resume Next
x = InputBox("Enter line to goto:")
'txtJS.GotoLine CLng(x)
'txtJS.FirstVisibleLine = CLng(x) - 1
txtJS.GotoLineCentered CLng(x) - 1
End Sub
Private Sub mnuHex2Unicode_Click()
On Error Resume Next
x = Replace(txtJS.SelText, vbCrLf, Empty)
x = Replace(x, Chr(0), "")
If Len(x) = 0 Then
MsgBox "Nothing selected!"
Exit Sub
End If
While Len(x) Mod 2 <> 0
x = x & "0"
Wend
For i = 1 To Len(x) Step 4
a = Mid(x, i, 2)
b = Mid(x, i + 2, 2)
ret = ret & "%u" & b & a
Next
If right(ret, 2) = "%u" Then ret = Mid(ret, 1, Len(ret) - 2)
txtJS.SelText = ret
End Sub
Private Sub mnuIndentGuide_Click()
mnuIndentGuide.Checked = Not mnuIndentGuide.Checked
txtJS.LineIndentGuide = mnuIndentGuide.Checked
End Sub
Public Sub mnuLoadShellcode_Click()
Dim f As String
dlg.SetCustomFilter "Shellcode File (*.sc)", "*.sc"
f = dlg.OpenDialog(CustomFilter, "", "Open file", Me.hwnd)
If Len(f) = 0 Then Exit Sub
If Not fso.FileExists(f) Then Exit Sub
x = HexDump(fso.ReadFile(f), 1)
txtJS.Text = AddPercentToHexString(x)
txtJS.SelectAll
End Sub
Private Sub mnuQuickEval_Click()
On Error Resume Next
s = InputBox("Enter a script to execute in current script contect. You can use this to probe runtime variables like tb.alert(my_var) or tb.t(longtext_var)")
If Len(s) = 0 Then Exit Sub
sc.eval s
End Sub
Private Sub mnuRenameFunc_Click()
On Error Resume Next
If lvFunc.SelectedItem Is Nothing Then Exit Sub
oldname = lvFunc.SelectedItem.Text
NewName = InputBox("Enter new name for " & oldname, , oldname)
If Len(NewName) = 0 Then Exit Sub
For Each li In lvFunc.ListItems
If li.Text = NewName Then
MsgBox "This name is already taken"
Exit Sub
End If
Next
If InStr(txtJS.Text, NewName) > 0 Then
MsgBox "This string is already found in the current script please make unique"
Exit Sub
End If
txtJS.SelectLine
x = txtJS.CurrentLine 'if the user scrolls using scroll bar, this wont change...
fl = txtJS.FirstVisibleLine 'this can be buggy...
txtJS.Text = Replace(txtJS.Text, oldname, NewName)
'txtJS.GotoLine x
If x < 5 And fl = 0 Then
txtJS.FirstVisibleLine = CLng(lvFunc.SelectedItem.tag)
ElseIf x > 5800 Or fl = 0 Then
txtJS.GotoLineCentered x, False
Else
txtJS.FirstVisibleLine = fl
End If
'MsgBox txtJS.SCI.ReplaceAll(CStr(oldname), CStr(NewName), True) 'buggy...
lvFunc.SelectedItem.Text = NewName
End Sub
Private Sub mnuScintillaOptions_Click()
txtJS.ShowOptions
End Sub
Private Sub mnuSend2IDA_Click()
Dim h As String
Const def = "C:\Program Files\IDA\idag.exe"
On Error Resume Next
If Len(txtJS.SelText) = 0 Then
MsgBox "You must first select the shellcode to extract in the script window."
Exit Sub
End If
h = GetMySetting("idapath")
If Len(h) = 0 And fso.FileExists(def) Then h = def 'use default if found
If Len(h) = 0 Or Not fso.FileExists(h) Then
If MsgBox("You have not yet configured the path to IDA install. select it now?", vbYesNo) = vbNo Then Exit Sub
h = dlg.OpenDialog(exeFiles, , "Select IDA", Me.hwnd)
If fso.FileExists(h) Then
SaveMySetting "idapath", h
Else
Exit Sub
End If
End If
x = txtJS.SelText
x = PrepareShellcode(x) 'does not handle just hex blobs like 9090 other formats supported though with multiescape
scf = App.path & "\tmp.sc"
If fso.FileExists(scf) Then Kill scf
fso.writeFile scf, x
Shell h & " """ & scf & """", vbNormalFocus
If Err.Number <> 0 Then MsgBox Err.Description
End Sub
Private Sub mnuShellcode_Click(Index As Integer)
On Error Resume Next
cap = mnuShellcode(Index).Caption
If cap = "Copy sc files to /sc_samples directory to load list" Or _
cap = "samples removed due to AV alert" Then _
Exit Sub
pth = App.path & "\sc_samples\" & cap
If Not fso.FileExists(pth) Then
MsgBox "File not found: " & pth
Exit Sub
End If
tmp = fso.ReadFile(pth)
tmp = HexDump(tmp, 1)
txtJS.Text = AddPercentToHexString(tmp)
txtJS.SelectAll
End Sub
Private Sub mnuShowHelp_Click()
toolbox.Help
End Sub
Private Sub mnuStripInlineDecoderCalls_Click()
frmInlineDecoderCalls.Show
End Sub
Private Sub mnuVarPrefix_Click()
On Error Resume Next
If txtJS.SelLength = 0 Then
MsgBox "This is used for the refactor form, used to add var to the beginning of all lines selected.", vbInformation
Exit Sub
End If
x = txtJS.SelText
tmp = Split(x, vbCrLf)
For i = 0 To UBound(tmp)
tmp(i) = "var " & tmp(i)
Next
If Err.Number = 0 Then txtJS.SelText = Join(tmp, vbCrLf)
End Sub
Private Sub mnuWordWrap_Click()
mnuWordWrap.Checked = Not mnuWordWrap.Checked
txtJS.WordWrap = mnuWordWrap.Checked
End Sub
Private Sub mnuXorBruteForce_Click()