View difference between Paste ID: bgjy2HaQ and 7keEgE10
SHOW: | | - or go back to the newest paste.
1-
1+
; Title: CryptoDragon AutoIt Obfuscator
2
; Version: v1.3.6
3
; Requirements: AutoIt Version 3.1.1.0 (Beta is NOT required)
4
; Date: November 5th, 2018
5
; Authors: Freak, taurus905
6
; Purpose: This script obfuscates an AutoIt script by identifying, counting and replacing all
7
;          variables and functions within that script, as well as encrypting strings., according to the following notes.
8
; Notes: Variables that are all UPPERCASE, such as, $GUI_EVENT_CLOSE, will not be obfuscated.
9
;        Functions to be obfuscated must start with an underscore "_".
10
;        Functions that are all UPPERCASE, such as, _DO_NOT_OBFUSCATE_THIS, will not be obfuscated.
11
;        All strings with single and double quotes are to be encrypted with a multikey XOR algo. (in order)
12
;        Add arguments in the "Functions_NOT_to_obfuscate_section:" to bypass these functions.
13
;        Uncomment: (in the script)
14
;             Global $Show_Messages = "Yes"
15
;                  to show Message Boxes and Array Displays during execution.
16
; Input:            An AutoIt Script --> OriginalScriptName.au3
17
; Output: Variables to be Obfuscated --> OriginalScriptName - Vars to Obfuscate.txt
18
;         Functions to be Obfuscated --> OriginalScriptName - Funcs to Obfuscate.txt
19
;                       Random Names --> OriginalScriptName - Random Names.txt
20
;           CryptoDragon Obfuscated Script --> OriginalScriptName - CryptoDragon Obfuscated.au3
21
; Modified by Freak to encrypt all strings in target program with multichar XOR, also added bug fixes.
22
; Changelog
23
; 	- Added improved speed in version v1.3.4
24
; 	- Improved functionality in version v1.3.5.1
25
;   - Added string length to _CryptoDragon_Crypt function for improved stability handling funny strings in version v1.3.6
26
; ===================================================================================================
27
#include <GUIConstants.au3>
28
#include <Array.au3>
29
Global $cryptLvl = 2
30
; Add this code to the obfuscated autoit file when finished
31
; ===================================================================================================
32
Func _CryptoDragon_Crypt($s_String, $s_Key, $iLen, $s_Level = 1)
33
    Local $s_Encrypted, $s_kc = 1
34
    If StringLen($s_Key) = 0 Or $s_Level < 1 Then Return 0
35
    $s_Key = StringSplit($s_Key,'')
36
    $s_String = StringSplit($s_String,'')
37
    For $x = 1 To $s_String[0]
38
        If $s_kc > $s_Key[0] Then $s_kc = 1
39
        $s_Encrypted &= Chr(BitXOR(Asc($s_String[$x]),Asc($s_Key[$s_kc])*$s_Level))
40
        $s_kc += 1
41
    Next
42
    Return StringLeft($s_Encrypted, $iLen)
43
EndFunc
44
;End of code
45
46
Global $Show_Messages = "No"
47
; Uncomment the following line to see progress messages and arrays during execution.
48
;Global $Show_Messages = "Yes"
49
; ===================================================================================================
50
51
Global $file_Script_to_Obfuscate
52
_Choose_Script_to_Obfuscate() ; Choose Script to Obfuscate
53
54
; ===================================================================================================
55
; Lines - Lines - Lines - Lines - Lines - Lines - Lines - Lines - Lines - Lines - Lines - Lines
56
57
Global $Num_of_Lines
58
_Count_Lines() ; Count Lines of Script to Obfuscate
59
If $Show_Messages = "Yes" Then MsgBox(0, "$Num_of_Lines", $Num_of_Lines)
60
61
Global $Array_of_Lines[$Num_of_Lines + 1]
62
_Read_Lines_to_Array() ; Read Lines to Array
63
If $Show_Messages = "Yes" Then _ArrayDisplay($Array_of_Lines, "$Array_of_Lines")
64
65
; Lines - Lines - Lines - Lines - Lines - Lines - Lines - Lines - Lines - Lines - Lines - Lines
66
; ===================================================================================================
67
; Vars - Vars - Vars - Vars - Vars - Vars - Vars - Vars - Vars - Vars - Vars - Vars - Vars - Vars
68
69
Global $Num_of_Vars
70
_Count_Vars() ; Count Variables in Script to Obfuscate
71
If $Show_Messages = "Yes" Then MsgBox(0, "$Num_of_Vars", $Num_of_Vars)
72
73
Global $Array_of_Vars[$Num_of_Vars + 1]
74
_Read_Vars_to_Array() ; Read Variables to Array
75
If $Show_Messages = "Yes" Then _ArrayDisplay($Array_of_Vars, "$Array_of_Vars")
76
77
_Sort_Array_of_Vars() ; Sort Array of Variables
78
If $Show_Messages = "Yes" Then _ArrayDisplay($Array_of_Vars, "$Array_of_Vars")
79
80
Global $Num_of_Unique_Vars
81
_Count_Unique_Vars() ; Count Unique Variables
82
If $Show_Messages = "Yes" Then MsgBox(0, "$Num_of_Unique_Vars", $Num_of_Unique_Vars)
83
84
Global $Array_of_Unique_Vars[$Num_of_Unique_Vars + 1]
85
_Read_Unique_Vars_to_Array() ; Read Unique Variables to Array
86
If $Show_Messages = "Yes" Then _ArrayDisplay($Array_of_Unique_Vars, "$Array_of_Unique_Vars")
87
88
_Write_Unique_Vars_to_File() ; Write Unique Variables to File
89
90
; Vars - Vars - Vars - Vars - Vars - Vars - Vars - Vars - Vars - Vars - Vars - Vars - Vars - Vars
91
; ===================================================================================================
92
; Funcs - Funcs - Funcs - Funcs - Funcs - Funcs - Funcs - Funcs - Funcs - Funcs - Funcs - Funcs
93
94
Global $Num_of_Funcs
95
_Count_Funcs() ; Count Functions in Script to Obfuscate
96
If $Show_Messages = "Yes" Then MsgBox(0, "$Num_of_Funcs", $Num_of_Funcs)
97
98
Global $Array_of_Funcs[$Num_of_Funcs + 1]
99
_Read_Funcs_to_Array() ; Read Functions to Array
100
If $Show_Messages = "Yes" Then _ArrayDisplay($Array_of_Funcs, "$Array_of_Funcs")
101
102
_Sort_Array_of_Funcs() ; Sort Array of Functions
103
If $Show_Messages = "Yes" Then _ArrayDisplay($Array_of_Funcs, "$Array_of_Funcs")
104
105
; Funcs - Funcs - Funcs - Funcs - Funcs - Funcs - Funcs - Funcs - Funcs - Funcs - Funcs - Funcs
106
; ===================================================================================================
107
; Random - Random - Random - Random - Random - Random - Random - Random - Random - Random - Random
108
109
Global $Num_of_Random_Names
110
_Find_Random_Name_Count() ; Find Random Name Count
111
112
Global $Random_Name[$Num_of_Random_Names + 1]
113
_Read_Random_Names_to_Array() ; Read Random Names to Array
114
If $Show_Messages = "Yes" Then _ArrayDisplay($Random_Name, "$Random_Name")
115
116
_Write_Random_Names_to_File() ; Write Random Names to File
117
118
; Random - Random - Random - Random - Random - Random - Random - Random - Random - Random - Random
119
; ===================================================================================================
120
; Replace - Replace - Replace - Replace - Replace - Replace - Replace - Replace - Replace - Replace
121
122
Global $New_Array_of_Lines[$Num_of_Lines + 1]
123
_Remove_Comments() ; Remove Comments
124
_ArraySortDblDel($Array_of_Unique_Vars)
125
_ArraySortDblDel($Array_of_Funcs)
126
$vars_finished = False
127
$func_finished = False
128
$Script_Data = _ArrayToString($Array_of_Lines, @CRLF)
129
For $iii = 0 To $Num_of_Lines
130
	For $jjj = UBound($Array_of_Unique_Vars) - 1 To 1 Step -1
131
		If $vars_finished Then ExitLoop
132
		If $Array_of_Unique_Vars[$jjj] <> $Array_of_Unique_Vars[1] Then
133
			If $Array_of_Unique_Vars[$jjj] <> "_" And $Array_of_Unique_Vars[$jjj] <> "$'" Then
134
				If StringInStr($Array_of_Unique_Vars[$jjj], ".") Then
135
					$temp = StringSplit($Array_of_Unique_Vars[$jjj], ".")
136
					$Array_of_Unique_Vars[$jjj] = $temp[1]
137
				EndIf
138
				If StringRight($Array_of_Unique_Vars[$jjj], 1) = "&" Then
139
					$Array_of_Unique_Vars[$jjj] = StringTrimRight($Array_of_Unique_Vars[$jjj], 1)
140
				EndIf
141
				$Script_Data = StringReplace($Script_Data, $Array_of_Unique_Vars[$jjj], "$" & $Random_Name[$jjj])
142
				ConsoleWrite($Array_of_Unique_Vars[$jjj] & ":$" & $Random_Name[$jjj] & @CRLF)
143
			EndIf
144
		Else
145
			If $Array_of_Unique_Vars[$jjj] <> "_" And $Array_of_Unique_Vars[$jjj] <> "$'" Then
146
				If StringInStr($Array_of_Unique_Vars[$jjj], ".") Then
147
					$temp = StringSplit($Array_of_Unique_Vars[$jjj], ".")
148
					$Array_of_Unique_Vars[$jjj] = $temp[1]
149
				EndIf
150
				If StringRight($Array_of_Unique_Vars[$jjj], 1) = "&" Then
151
					$Array_of_Unique_Vars[$jjj] = StringTrimRight($Array_of_Unique_Vars[$jjj], 1)
152
				EndIf
153
				$Script_Data = StringReplace($Script_Data, $Array_of_Unique_Vars[$jjj], "$" & $Random_Name[$jjj])
154
				ConsoleWrite($Array_of_Unique_Vars[$jjj] & ":$" & $Random_Name[$jjj] & @CRLF)
155
			EndIf
156
			$vars_finished = True
157
		EndIf
158
	Next
159
Next
160
For $iii = 0 To $Num_of_Lines
161
	For $jjj = UBound($Array_of_Funcs) - 1 To 1 Step -1
162
;		If StringLeft($Array_of_Funcs[$jjj], 1) = "_" Then ContinueLoop
163
		If $func_finished Then ExitLoop
164
		If $Array_of_Funcs[$jjj] <> $Array_of_Funcs[1] Then
165
			If StringInStr($Array_of_Funcs[$jjj], "=") Then ContinueLoop ; Au3wrapper, not a function.
166
			$Script_Data = StringReplace($Script_Data, $Array_of_Funcs[$jjj], $Random_Name[$jjj])
167
			ConsoleWrite($Array_of_Funcs[$jjj] & ":" & $Random_Name[$jjj] & @CRLF)
168
		Else
169
			If StringInStr($Array_of_Funcs[$jjj], "=") Then
170
				$func_finished = True
171
				ContinueLoop ; Au3wrapper, not a function.
172
			EndIf
173
			$Script_Data = StringReplace($Script_Data, $Array_of_Funcs[$jjj], $Random_Name[$jjj])
174
			ConsoleWrite($Array_of_Funcs[$jjj] & ":" & $Random_Name[$jjj] & @CRLF)
175
			$func_finished = True
176
		EndIf
177
	Next
178
Next
179
If $Show_Messages = "Yes" Then _ArrayDisplay($Array_of_Lines, "$New_Array_of_Lines")
180
181
; Replace - Replace - Replace - Replace - Replace - Replace - Replace - Replace - Replace - Replace
182
; ===================================================================================================
183
184
_Write_CryptoDragon_Obfuscated_File($Script_Data) ; Write CryptoDragon Obfuscated Script
185
Exit
186
Func _ArraySortDblDel(ByRef $ARRAY, $CASESENS=0, $iDESCENDING=0, $iDIM=0, $iSORT=0)
187
	Local $arTmp1D[1], $arTmp2D[1][2], $dbl = 0
188
	$arTmp1D[0] = ""
189
	$arTmp2D[0][0] = ""
190
	If $iDIM = 0 Then $iDIM = 1
191
	_ArraySort($ARRAY,$iDESCENDING,0,0,$iDIM,$iSORT)
192
	Switch $iDIM
193
		Case 1 ; 1D
194
			For $i = 0 To UBound($ARRAY)-1
195
				$dbl = 0
196
				For $k = 0 To UBound($arTmp1D)-1
197
					Switch $CASESENS
198
						Case 0
199
							If $arTmp1D[$k] = $ARRAY[$i] Then $dbl = 1
200
						Case 1
201
							If $arTmp1D[$k] == $ARRAY[$i] Then $dbl = 1
202
					EndSwitch
203
				Next
204
				If $dbl = 0 Then
205
					If $arTmp1D[0] = "" Then
206
						$arTmp1D[0] = $ARRAY[$i]
207
					Else
208
						_ArrayAdd($arTmp1D, $ARRAY[$i])
209
					EndIf
210
				Else
211
					$dbl = 0
212
				EndIf
213
			Next
214
			$ARRAY = $arTmp1D
215
		Case 2 ; 2D
216
			For $i = 0 To UBound($ARRAY)-1
217
				$dbl = 0
218
				For $k = 0 To UBound($arTmp2D)-1
219
					Switch $CASESENS
220
						Case 0
221
							If  ( $arTmp2D[$k][0] = $ARRAY[$i][0] ) And _
222
								( $arTmp2D[$k][1] = $ARRAY[$i][1] ) Then $dbl = 1
223
						Case 1
224
							If  ( $arTmp2D[$k][0] == $ARRAY[$i][0] ) And _
225
								( $arTmp2D[$k][1] == $ARRAY[$i][1] ) Then $dbl = 1
226
					EndSwitch
227
				Next
228
				If $dbl = 0 Then
229
					If $arTmp2D[0][0] = "" Then
230
						$arTmp2D[0][0] = $ARRAY[$i][0]
231
						$arTmp2D[0][1] = $ARRAY[$i][1]
232
					Else
233
						ReDim $arTmp2D[UBound($arTmp2D)+1][2]
234
						$arTmp2D[UBound($arTmp2D)-1][0] = $ARRAY[$i][0]
235
						$arTmp2D[UBound($arTmp2D)-1][1] = $ARRAY[$i][1]
236
					EndIf
237
				Else
238
					$dbl = 0
239
				EndIf
240
			Next
241
			$ARRAY = $arTmp2D
242
	EndSwitch
243
EndFunc ; ==>_ArraySortDblDel
244
; ###################################################################################################
245
; ===================================================================================================
246
Func _Choose_Script_to_Obfuscate() ; Choose Script to Obfuscate
247
	$file_Script_to_Obfuscate = FileOpenDialog("Choose an AutoIt Script to Obfuscate:", @ScriptDir, "Scripts (*.au3)", 1 + 2)
248
	If @error Then Exit
249
EndFunc ; ==> _Choose_Script_to_Obfuscate
250
; ===================================================================================================
251
; Lines - Lines - Lines - Lines - Lines - Lines - Lines - Lines - Lines - Lines - Lines - Lines
252
Func _Count_Lines() ; Count Lines of Script to Obfuscate
253
	FileOpen($file_Script_to_Obfuscate, 0) ; Open File to Obfuscate
254
	$Num_of_Lines = 0
255
	While 1
256
		$Num_of_Lines = $Num_of_Lines + 1
257
		FileReadLine($file_Script_to_Obfuscate, $Num_of_Lines) ; Read All Lines for Count
258
		If @error = -1 Then ExitLoop
259
	WEnd
260
EndFunc ; ==> _Count_Lines
261
; ===================================================================================================
262
Func _Read_Lines_to_Array() ; Read Lines to Array
263
	For $iii = 1 To $Num_of_Lines
264
		$Array_of_Lines[$iii] = FileReadLine($file_Script_to_Obfuscate, $iii) ; Read All Lines
265
	Next
266
	FileClose($file_Script_to_Obfuscate) ; Close File to Obfuscate
267
EndFunc ; ==> _Read_Lines_to_Array
268
; Lines - Lines - Lines - Lines - Lines - Lines - Lines - Lines - Lines - Lines - Lines - Lines
269
; ===================================================================================================
270
; Vars - Vars - Vars - Vars - Vars - Vars - Vars - Vars - Vars - Vars - Vars - Vars - Vars - Vars
271
Func _Count_Vars() ; Count Variables in Script to Obfuscate
272
	$Num_of_Vars = 0
273
	For $iii = 1 To $Num_of_Lines
274
		Local $quote_on = "No"
275
		$Array_of_Lines[0] = $Array_of_Lines[$iii]
276
		Local $line_length = StringLen($Array_of_Lines[0])
277
		For $jjj = 1 To $line_length
278
			Local $char = StringLeft($Array_of_Lines[0], 1)
279
			If $char = Chr(34) And $quote_on = "No" Then
280
				$quote_on = "Yes"
281
			ElseIf $char = Chr(34) And $quote_on = "Yes" Then
282
				$quote_on = "No"
283
			EndIf
284
			If $char = ";" And $quote_on = "No" Then ExitLoop
285
			If $char = "$" And $quote_on = "No" Then $Num_of_Vars = $Num_of_Vars + 1
286
			$Array_of_Lines[0] = StringTrimLeft($Array_of_Lines[0], 1)
287
		Next
288
	Next
289
EndFunc ; ==> _Count_Vars
290
; ===================================================================================================
291
Func _Read_Vars_to_Array() ; Read Variables to Array
292
	Local $var_ct = 0
293
	For $iii = 1 To $Num_of_Lines
294
		Local $quote_on = "No"
295
		$Array_of_Lines[0] = $Array_of_Lines[$iii]
296
		Local $line_length = StringLen($Array_of_Lines[0])
297
		For $jjj = 1 To $line_length
298
			Local $char = StringLeft($Array_of_Lines[0], 1)
299
			If $char = Chr(34) And $quote_on = "No" Then
300
				$quote_on = "Yes"
301
			ElseIf $char = Chr(34) And $quote_on = "Yes" Then
302
				$quote_on = "No"
303
			EndIf
304
			If $char = ";" And $quote_on = "No" Then ExitLoop
305
			If $char = "$" And $quote_on = "No" Then ; Read One Variable
306
				$var_ct = $var_ct + 1
307
				$Array_of_Vars[$var_ct] = ""
308
				For $kkk = 1 To 256
309
					$char = StringLeft($Array_of_Lines[0], 1)
310
					If $char = " " Or _
311
							$char = "	" Or _
312
							$char = "=" Or _
313
							$char = "[" Or _
314
							$char = "]" Or _
315
							$char = "," Or _
316
							$char = ")" Or _
317
							$char = ";" Or _
318
							$char = "+" Or _
319
							$char = "-" Or _
320
							$char = "*" Or _
321
							$char = "/" Or _
322
							$char = Chr(34) Then ExitLoop
323
					$Array_of_Vars[$var_ct] = $Array_of_Vars[$var_ct] & $char
324
					$Array_of_Lines[0] = StringTrimLeft($Array_of_Lines[0], 1)
325
				Next
326
			EndIf
327
			$Array_of_Lines[0] = StringTrimLeft($Array_of_Lines[0], 1)
328
		Next
329
	Next
330
EndFunc ; ==> _Read_Vars_to_Array
331
; ===================================================================================================
332
Func _Sort_Array_of_Vars() ; Sort Array of Variables
333
	_ArraySortDblDel($Array_of_Vars)
334
EndFunc ; ==> _Sort_Array_of_Vars
335
; ===================================================================================================
336
Func _Count_Unique_Vars() ; Count Unique Variables
337
	$Num_of_Unique_Vars = 0
338
	For $iii = 1 To UBound($Array_of_Vars) - 1
339
		If $Array_of_Vars[$iii] <> $Array_of_Vars[$iii - 1] Then
340
			If StringIsUpper(StringTrimLeft(StringReplace($Array_of_Vars[$iii], "_", ""), 1)) Then ContinueLoop ; Don't write any system variables that are all UPPERCASE, such as, $GUI_EVENT_CLOSE
341
			$Num_of_Unique_Vars = $Num_of_Unique_Vars + 1
342
		EndIf
343
	Next
344
EndFunc ; ==> _Count_Unique_Vars
345
; ===================================================================================================
346
Func _Read_Unique_Vars_to_Array() ; Read Unique Variables to Array
347
	Local $var_unique_ct = 0
348
	For $iii = 1 To UBound($Array_of_Vars) - 1
349
		If $Array_of_Vars[$iii] <> $Array_of_Vars[$iii - 1] Then
350
			If StringIsUpper(StringTrimLeft(StringReplace($Array_of_Vars[$iii], "_", ""), 1)) Then ContinueLoop ; Don't read any System Variables that are all UPPERCASE, such as, $GUI_EVENT_CLOSE
351
			$var_unique_ct = $var_unique_ct + 1
352
			$Array_of_Unique_Vars[$var_unique_ct] = $Array_of_Vars[$iii]
353
		EndIf
354
	Next
355
EndFunc ; ==> _Read_Unique_Vars_to_Array
356
; ===================================================================================================
357
Func _Write_Unique_Vars_to_File() ; Write Unique Variables to File
358
	Local $file_Unique_Vars = StringTrimRight($file_Script_to_Obfuscate, 4) & " - Vars to Obfuscate.txt" ; Create Unique Variables Filename
359
	FileOpen($file_Unique_Vars, 2) ; Open File to Write Unique Variables
360
	For $iii = 1 To $Num_of_Unique_Vars
361
		FileWrite($file_Unique_Vars, $Array_of_Unique_Vars[$iii] & @CRLF)
362
	Next
363
	FileClose($file_Unique_Vars) ; Close Unique Variables File
364
EndFunc ; ==> _Write_Unique_Vars_to_File
365
; Vars - Vars - Vars - Vars - Vars - Vars - Vars - Vars - Vars - Vars - Vars - Vars - Vars - Vars
366
; ===================================================================================================
367
; Funcs - Funcs - Funcs - Funcs - Funcs - Funcs - Funcs - Funcs - Funcs - Funcs - Funcs - Funcs
368
Func _Count_Funcs() ; Count Functions in Script to Obfuscate
369
	$Num_of_Funcs = 0
370
	For $iii = 1 To $Num_of_Lines
371
		Local $quote_on = "No"
372
		Local $var_on = "No"
373
		Local $func_on = "No"
374
		$Array_of_Lines[0] = $Array_of_Lines[$iii]
375
		Local $line_length = StringLen($Array_of_Lines[0])
376
		For $jjj = 1 To $line_length
377
			Local $char = StringLeft($Array_of_Lines[0], 1)
378
			If $char = "(" Or $char = " " Then $func_on = "No"
379
			If $char = "$" And $quote_on = "No" Then $var_on = "Yes"
380
			If $char = "@" And $quote_on = "No" Then $var_on = "Yes"
381
			If $char = "<" And $quote_on = "No" Then $var_on = "Yes"
382
			If $char = " " And $quote_on = "No" Then $var_on = "No"
383
			If $char = Chr(34) And $quote_on = "No" Then
384
				$quote_on = "Yes"
385
			ElseIf $char = Chr(34) And $quote_on = "Yes" Then
386
				$quote_on = "No"
387
			EndIf
388
			If $char = ";" And $quote_on = "No" Then ExitLoop
389
			If $quote_on = "No" And $func_on = "No" And $var_on = "No" Then
390
				$func_on = "Yes"
391
				$Num_of_Funcs = $Num_of_Funcs + 1
392
			EndIf
393
			$Array_of_Lines[0] = StringTrimLeft($Array_of_Lines[0], 1)
394
		Next
395
	Next
396
EndFunc ; ==> _Count_Funcs
397
; ===================================================================================================
398
Func _Read_Funcs_to_Array() ; Read Functions to Array
399
	Local $func_ct = 0
400
	For $iii = 1 To $Num_of_Lines
401
		Local $quote_on = "No"
402
		Local $var_on = "No"
403
		Local $func_on = "No"
404
		$Array_of_Lines[0] = $Array_of_Lines[$iii]
405
		Local $line_length = StringLen($Array_of_Lines[0])
406
		For $jjj = 1 To $line_length
407
			Local $char = StringLeft($Array_of_Lines[0], 1)
408
			If $char = "(" Or $char = " " Then $func_on = "No"
409
			If $char = "$" And $quote_on = "No" Then $var_on = "Yes"
410
			If $char = "@" And $quote_on = "No" Then $var_on = "Yes"
411
			If $char = "<" And $quote_on = "No" Then $var_on = "Yes"
412
			If $char = " " And $quote_on = "No" Then $var_on = "No"
413
			If $char = Chr(34) And $quote_on = "No" Then
414
				$quote_on = "Yes"
415
			ElseIf $char = Chr(34) And $quote_on = "Yes" Then
416
				$quote_on = "No"
417
			EndIf
418
			If $char = ";" And $quote_on = "No" Then ExitLoop
419
			If $char = "_" And $quote_on = "No" And $func_on = "No" And $var_on = "No" Then ; Read One Function
420
				$func_ct = $func_ct + 1
421
				$Array_of_Funcs[$func_ct] = ""
422
				For $kkk = 1 To 256
423
					$char = StringLeft($Array_of_Lines[0], 1)
424
					If $char = " " Or $char = "(" Then ExitLoop
425
					$Array_of_Funcs[$func_ct] = $Array_of_Funcs[$func_ct] & $char
426
					$Array_of_Lines[0] = StringTrimLeft($Array_of_Lines[0], 1)
427
				Next
428
				; Functions_NOT_to_obfuscate_section:
429
				; Add functions to the following lines that start with an underscore "_" that you
430
				;    do NOT want to be obfuscated. Example:
431
				; If $Array_of_Funcs[$func_ct] = "_ArraySortDblDel" Or _
432
				If $Array_of_Funcs[$func_ct] = "_ArraySortDblDel" Or _
433
						$Array_of_Funcs[$func_ct] = "_ArrayDisplay" Or _
434
						$Array_of_Funcs[$func_ct] = "_ChooseColor" Or _
435
						$Array_of_Funcs[$func_ct] = "_ChooseFont" Or _
436
						$Array_of_Funcs[$func_ct] = "_ImageGetSize" Or _
437
						$Array_of_Funcs[$func_ct] = "_IsPressed" Or _
438
						$Array_of_Funcs[$func_ct] = "_StringEncrypt" Or _
439
						$Array_of_Funcs[$func_ct] = "_" Then ; Do NOT Count Built-In Functions
440
					$func_ct = $func_ct - 1
441
				EndIf
442
			EndIf
443
			$Array_of_Lines[0] = StringTrimLeft($Array_of_Lines[0], 1)
444
		Next
445
	Next
446
EndFunc ; ==> _Read_Funcs_to_Array
447
; ===================================================================================================
448
Func _Sort_Array_of_Funcs() ; Sort Array of Functions
449
	_ArraySortDblDel($Array_of_Funcs)
450
EndFunc ; ==> _Sort_Array_of_Funcs
451
; ===================================================================================================
452
; Funcs - Funcs - Funcs - Funcs - Funcs - Funcs - Funcs - Funcs - Funcs - Funcs - Funcs - Funcs
453
; ===================================================================================================
454
455
Func _Find_Random_Name_Count() ; Find Random Name Count
456
	If $Num_of_Unique_Vars > $Num_of_Funcs Then
457
		$Num_of_Random_Names = $Num_of_Vars
458
	Else
459
		$Num_of_Random_Names = $Num_of_Funcs
460
	EndIf
461
EndFunc ; ==> _Find_Random_Name_Count
462
; ===================================================================================================
463
Func _Read_Random_Names_to_Array() ; Read Random Names to Array
464
	Local $random[9]
465
	For $iii = 1 To $Num_of_Random_Names
466
		$Random_Name[$iii] = ""
467
		For $jjj = 1 To 8 ; The number of random characters to use in each random name
468
			$random[$jjj] = Random(48, 122, 1)
469
			If $random[$jjj] > 64 And $random[$jjj] < 91 Or $random[$jjj] > 96 And $random[$jjj] < 123 Then
470
				$Random_Name[$iii] = $Random_Name[$iii] & Chr($random[$jjj])
471
			Else
472
				$jjj = $jjj - 1
473
				ContinueLoop
474
			EndIf
475
		Next
476
	Next
477
	Return $Random_Name
478
EndFunc ; ==> _Read_Random_Names_to_Array
479
; ===================================================================================================
480
Func _Write_Random_Names_to_File() ; Write Random Names to File
481
	Local $file_Random_Names = StringTrimRight($file_Script_to_Obfuscate, 4) & " - Random Names.txt" ; Create Random Names Filename
482
	FileOpen($file_Random_Names, 2) ; Open File to Write Random Names
483
	For $iii = 1 To $Num_of_Random_Names
484
		FileWrite($file_Random_Names, $Random_Name[$iii] & @CRLF)
485
	Next
486
	FileClose($file_Random_Names) ; Close Random Names File
487
	Return $Random_Name
488
EndFunc ; ==> _Write_Random_Names_to_File
489
490
; Random - Random - Random - Random - Random - Random - Random - Random - Random - Random - Random
491
; ===================================================================================================
492
; Replace - Replace - Replace - Replace - Replace - Replace - Replace - Replace - Replace - Replace
493
494
; ===================================================================================================
495
Func _Remove_Comments() ; Remove Comments
496
	For $iii = 1 To $Num_of_Lines
497
		Local $quote_on = "No"
498
		$Array_of_Lines[0] = $Array_of_Lines[$iii]
499
		Local $line_length = StringLen($Array_of_Lines[0])
500
		$New_Array_of_Lines[$iii] = ""
501
		For $jjj = 1 To $line_length
502
			Local $char = StringLeft($Array_of_Lines[0], 1)
503
			If $char = Chr(34) And $quote_on = "No" Then
504
				$quote_on = "Yes"
505
			ElseIf $char = Chr(34) And $quote_on = "Yes" Then
506
				$quote_on = "No"
507
			EndIf
508
			If $char = ";" And $quote_on = "No" Then ExitLoop
509
			$New_Array_of_Lines[$iii] = $New_Array_of_Lines[$iii] & $char
510
			$Array_of_Lines[0] = StringTrimLeft($Array_of_Lines[0], 1)
511
		Next
512
	Next
513
	Return $New_Array_of_Lines
514
EndFunc ; ==> _Remove_Comments
515
516
; Replace - Replace - Replace - Replace - Replace - Replace - Replace - Replace - Replace - Replace
517
; ===================================================================================================
518
Func _StringBetween($S_STRING, $S_START, $S_END, $V_CASE = -1)
519
	Local $S_CASE = ""
520
	If $V_CASE = Default Or $V_CASE = -1 Then $S_CASE = "(?i)"
521
	Local $S_PATTERN_ESCAPE = "(\.|\||\*|\?|\+|\(|\)|\{|\}|\[|\]|\^|\$|\\)"
522
	$S_START = StringRegExpReplace($S_START, $S_PATTERN_ESCAPE, "\\$1")
523
	$S_END = StringRegExpReplace($S_END, $S_PATTERN_ESCAPE, "\\$1")
524
	If $S_START = "" Then $S_START = "\A"
525
	If $S_END = "" Then $S_END = "\z"
526
	Local $A_RET = StringRegExp($S_STRING, "(?s)" & $S_CASE & $S_START & "(.*?)" & $S_END, 3)
527
	If @error Then Return SetError(1, 0, 0)
528
	Return $A_RET
529
EndFunc   ;==>_STRINGBETWEEN
530
Func _Add_Strings($aList, $AU3, $splitChar)
531
	Global $sPass = ""
532
	Dim $sRndChr[3]
533
	Local $Digits = 8
534
	For $i = 1 To $Digits
535
		$sRndChr[0] = Chr(Random(65, 90, 1))
536
		$sRndChr[1] = Chr(Random(97, 122, 1))
537
		$sRndChr[2] = Chr(Random(48, 57, 1))
538
		$sPass &= $sRndChr[Random(0, 2, 1)]
539
	Next
540
	Local $doneEncryption = False
541
	Local $newAU3 = $AU3
542
	_ArraySortDblDel($aList)
543
	For $A = 0 To UBound($aList) - 1
544
		If StringInStr($aList[$A], @CRLF) Then
545
			ContinueLoop
546
		ElseIf $aList[$A] <> "" And StringInStr($aList[$A], "_CryptoDragon_Crypt") = False And StringLeft($aList[$A], 1) <> "'" And StringRight($aList[$A], 1) <> "'" And StringLeft($aList[$A], 1) <> '"' And StringRight($aList[$A], 1) <> '"' And StringLen($aList[$A]) > 1 Then
547
			If StringInStr($aList[$A], "&") Then
548
				If StringRight($aList[$A], 1) = "&" Then
549
					$newAU3 = StringReplace($newAU3, $splitChar & StringTrimRight($aList[$A], 1) & $splitChar, " & _CryptoDragon_Crypt(BinaryToString('" & StringToBinary(_CryptoDragon_Crypt(StringTrimRight($aList[$A], 1), $sPass, StringLen(StringTrimRight($aList[$A], 1)), $cryptLvl)) & "'), BinaryToString('" & StringToBinary($sPass) & "'), " & String(StringLen($aList[$A]) - 1) & ", " & String($cryptLvl) & ")&")
550
					ConsoleWrite($splitChar & StringTrimRight($aList[$A], 1) & $splitChar & ":_CryptoDragon_Crypt(BinaryToString('" & StringToBinary(_CryptoDragon_Crypt(StringTrimRight($aList[$A], 1), $sPass, StringLen(StringTrimRight($aList[$A], 1)), $cryptLvl)) & "'), BinaryToString('" & StringToBinary($sPass) & "'), " & String(StringLen($aList[$A]) - 1) & ", " & String($cryptLvl) & ")&" & @CRLF)
551
				ElseIf StringRight($aList[$A], 2) = "& " Then
552
					$newAU3 = StringReplace($newAU3, $splitChar & StringTrimRight($aList[$A], 2) & $splitChar, "_CryptoDragon_Crypt(BinaryToString('" & StringToBinary(_CryptoDragon_Crypt(StringTrimRight($aList[$A], 2), $sPass, StringLen(String($aList[$A]) - 2), $cryptLvl)) & "'), BinaryToString('" & StringToBinary($sPass) & "'), " & String(StringLen($aList[$A]) - 2) & ", " & String($cryptLvl) & ") & ")
553
					ConsoleWrite($splitChar & StringTrimRight($aList[$A], 2) & $splitChar & ":_CryptoDragon_Crypt(BinaryToString('" & StringToBinary(_CryptoDragon_Crypt(StringTrimRight($aList[$A], 2), $sPass, StringLen(String($aList[$A]) - 2), $cryptLvl)) & "'), BinaryToString('" & StringToBinary($sPass) & "'), " & String(StringLen($aList[$A]) - 2) & ", " & String($cryptLvl) & ") &" & @CRLF)
554
				ElseIf StringLeft($aList[$A], 1) = "&" Then
555
					$newAU3 = StringReplace($newAU3, $splitChar & StringTrimLeft($aList[$A], 1) & $splitChar, "&_CryptoDragon_Crypt(BinaryToString('" & StringToBinary(_CryptoDragon_Crypt(StringTrimLeft($aList[$A], 2), $sPass, StringLen(String($aList[$A]) - 1), $cryptLvl)) & "'), BinaryToString('" & StringToBinary($sPass) & "'), " & String(StringLen($aList[$A]) - 1) & ", " & String($cryptLvl) & ")")
556
					ConsoleWrite($splitChar & StringTrimLeft($aList[$A], 1) & $splitChar & ":&_CryptoDragon_Crypt(BinaryToString('" & StringToBinary(_CryptoDragon_Crypt(StringTrimLeft($aList[$A], 1), $sPass, StringLen(String($aList[$A]) - 1), $cryptLvl)) & "'), BinaryToString('" & StringToBinary($sPass) & "'), " & String(StringLen($aList[$A]) - 1) & ", " & String($cryptLvl) & ")" & @CRLF)
557
				ElseIf StringLeft($aList[$A], 2) = " &" Then
558
					$newAU3 = StringReplace($newAU3, $splitChar & StringTrimLeft($aList[$A], 2) & $splitChar, " & _CryptoDragon_Crypt(BinaryToString('" & StringToBinary(_CryptoDragon_Crypt(StringTrimLeft($aList[$A], 2), $sPass, StringLen(String($aList[$A]) - 2), $cryptLvl)) & "'), BinaryToString('" & StringToBinary($sPass) & "'))")
559
					ConsoleWrite($splitChar & StringTrimLeft($aList[$A], 2) & $splitChar & ": & _CryptoDragon_Crypt(BinaryToString('" & StringToBinary(_CryptoDragon_Crypt(StringTrimLeft($aList[$A], 2), $sPass, StringLen(String($aList[$A]) - 2), $cryptLvl)) & "'), BinaryToString('" & StringToBinary($sPass) & "'), " & String(StringLen($aList[$A]) - 2) & ", " & String($cryptLvl) & ")" & @CRLF)
560
				Else
561
					$newAU3 = StringReplace($newAU3, $splitChar & $aList[$A] & $splitChar, "_CryptoDragon_Crypt(BinaryToString('" & StringToBinary(_CryptoDragon_Crypt($aList[$A], $sPass, StringLen($aList[$A]), $cryptLvl)) & "'), BinaryToString('" & StringToBinary($sPass) & "'), " & String(StringLen($aList[$A])) & ", " & String($cryptLvl) & ")")
562
					ConsoleWrite($splitChar & $aList[$A] & $splitChar & ":_CryptoDragon_Crypt(BinaryToString('" & StringToBinary(_CryptoDragon_Crypt($aList[$A], $sPass, StringLen($aList[$A]), $cryptLvl)) & "'), BinaryToString('" & StringToBinary($sPass) & "'), " & String(StringLen($aList[$A])) & ", " & String($cryptLvl) & ")" & @CRLF)
563
				EndIf
564
			Else
565
				$newAU3 = StringReplace($newAU3, $splitChar & $aList[$A] & $splitChar, "_CryptoDragon_Crypt(BinaryToString('" & StringToBinary(_CryptoDragon_Crypt($aList[$A], $sPass, StringLen($aList[$A]), $cryptLvl)) & "'), BinaryToString('" & StringToBinary($sPass) & "'), " & StringLen($aList[$A]) & ", " & String($cryptLvl) & ")")
566
				ConsoleWrite($splitChar & $aList[$A] & $splitChar & ":_CryptoDragon_Crypt(BinaryToString('" & StringToBinary(_CryptoDragon_Crypt($aList[$A], $sPass, StringLen($aList[$A]), $cryptLvl)) & "'), BinaryToString('" & StringToBinary($sPass) & "'), " & String(StringLen($aList[$A])) & ", " & String($cryptLvl) & ")" & @CRLF)
567
			EndIf
568
		EndIf
569
	Next
570
	Return $newAU3
571
EndFunc   ;==>_ADD_STRINGS
572
Func _Encrypt_Strings($AU3, $file_Simple_Obfuscated)
573
	Local $sSTRINGS = _StringBetween($AU3, "'", "'")
574
	Local $newAU3 = _Add_Strings($sSTRINGS, $AU3, "'")
575
	Local $dSTRINGS = _StringBetween($newAU3, '"', '"')
576
	Local $epicAU3 = _Add_Strings($dSTRINGS, $newAU3, '"')
577
	Local $fileHandle = FileOpen($file_Simple_Obfuscated, 2)
578
	FileWrite($fileHandle, $epicAU3)
579
	FileClose($fileHandle)
580
EndFunc   ;==>_ENCRYPT_STRINGS
581
Func _Write_CryptoDragon_Obfuscated_File($AU3) ; Write CryptoDragon Obfuscated File
582
	Local $file_Simple_Obfuscated = StringTrimRight($file_Script_to_Obfuscate, 4) & " - CryptoDragon Obfuscated.au3" ; Create CryptoDragon Obfuscated Filename
583
	_Encrypt_Strings($AU3, $file_Simple_Obfuscated)
584
EndFunc ; ==> _Write_CryptoDragon_Obfuscated_File
585
; ===================================================================================================