-
Notifications
You must be signed in to change notification settings - Fork 0
/
ACN_HASH.au3
463 lines (404 loc) · 22.7 KB
/
ACN_HASH.au3
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
#include-once
Global $_SHA1Opcode = '0xC86800005356576A006A006A008D459850E829000000FF7514FF750CFF75088D459850E88A0000006A006A008D459850FF7510E8490000005F5E5BC9C210005589E5538B5D08836314008363180083635C00C70301234567C7430489ABCDEFC74308FEDCBA98C7430C76543210C74310F0E1D2C383636000836364005B5DC210005589E55657FF750CE8850200008B7D088B750C6A0559A58A47FF8647FC8847FF8A47FE8647FD8847FEE2EB5F5E5DC210005589E55356578B5D08837D10007502EB59837B60007506837B640074076A018F4364EB468B4D108B7D0CEB3449518A078B735C8844331CFF435C83431408837B1400750EFF4318837B180075056A018F4364837B5C40750653E813000000475985C97406837B640074C25F5E5B5DC21000C84801005356578B5D086A10598D51FF89D7C1E7020FB6443B1CC1E018898495BCFEFFFF0FB6443B1DC1E010098495BCFEFFFF0FB6443B1EC1E008098495BCFEFFFF0FB6443B1F098495BCFEFFFFE2BD6A105A83FA5073288B8495B0FEFFFF3384959CFEFFFF33849584FEFFFF3384957CFEFFFFD1C0898495BCFEFFFF42EBD38B4D088B318B59048B51088B790C8B41108985B8FEFFFF8365FC00837DFC147D3C89D131F921D931F989F0C1C00501C80385B8FEFFFF8B4DFC03848DBCFEFFFF059979825A5089BDB8FEFFFF89D789D8C1C01E89C289F35EFF45FCEBBE6A148F45FC837DFC287D3A89D931D131F989F0C1C00501C80385B8FEFFFF8B4DFC03848DBCFEFFFF05A1EBD96E5089BDB8FEFFFF89D789D8C1C01E89C289F35EFF45FCEBC06A288F45FC837DFC3C7D4689D821F85089D021F889D921D109C15809C189F0C1C00501C80385B8FEFFFF8B4DFC03848DBCFEFFFF05DCBC1B8F5089BDB8FEFFFF89D789D8C1C01E89C289F35EFF45FCEBB46A3C8F45FC837DFC507D3A89D931D131F989F0C1C00501C80385B8FEFFFF8B4DFC03848DBCFEFFFF05D6C162CA5089BDB8FEFFFF89D789D8C1C01E89C289F35EFF45FCEBC08B4D088B0101F089018B410401D88941048B410801D08941088B410C01F889410C8B41100385B8FEFFFF89411083615C005F5E5BC9C204005589E55356578B5D08837B6400740431C0EB14837B6000750B53E80F0000006A018F436031C0405F5E5B5DC204005589E553578B5D088B7B5C83FF37762EC6443B1C8047EB06C6443B1C004783FF4072F5897B5C53E8B6FDFFFF8B7B5CEB06C6443B1C004783FF3872F5EB13C6443B1C8047EB06C6443B1C004783FF3872F5897B5C8B4318C1E81825FF0000008843548B4318C1E81025FF0000008843558B4318C1E80825FF0000008843568B431825FF0000008843578B4314C1E81825FF0000008843588B4314C1E81025FF0000008843598B4314C1E80825FF00000088435A8B431425FF00000088435B53E81EFDFFFF5F5B5DC20400'
Global $_MD5Opcode = '0xC85800005356576A006A006A008D45A850E8280000006A00FF750CFF75088D45A850E8440000006A006A008D45A850FF7510E8710700005F5E5BC9C210005589E58B4D0831C0894114894110C70101234567C7410489ABCDEFC74108FEDCBA98C7410C765432105DC21000C80C0000538B5D088B4310C1E80383E03F8945F88B4510C1E0030143103943107303FF43148B4510C1E81D0143146A40582B45F88945F4394510724550FF750C8B45F88D44031850E8A00700008D43185053E84E0000008B45F48945FC8B45FC83C03F39451076138B450C0345FC5053E8300000008345FC40EBE28365F800EB048365FC008B45102B45FC508B450C0345FC508B45F88D44031850E84D0700005BC9C21000C84000005356576A40FF750C8D45C050E8330700008B45088B088B50048B70088B780C89D021F089D3F7D321FB09D801C1034DC081C178A46AD7C1C10701D189C821D089CBF7D321F309D801C7037DC481C756B7C7E8C1C70C01CF89F821C889FBF7D321D309D801C60375C881C6DB702024C1C61101FE89F021F889F3F7D321CB09D801C20355CC81C2EECEBDC1C1C21601F289D021F089D3F7D321FB09D801C1034DD081C1AF0F7CF5C1C10701D189C821D089CBF7D321F309D801C7037DD481C72AC68747C1C70C01CF89F821C889FBF7D321D309D801C60375D881C6134630A8C1C61101FE89F021F889F3F7D321CB09D801C20355DC81C2019546FDC1C21601F289D021F089D3F7D321FB09D801C1034DE081C1D8988069C1C10701D189C821D089CBF7D321F309D801C7037DE481C7AFF7448BC1C70C01CF89F821C889FBF7D321D309D801C60375E881C6B15BFFFFC1C61101FE89F021F889F3F7D321CB09D801C20355EC81C2BED75C89C1C21601F289D021F089D3F7D321FB09D801C1034DF081C12211906BC1C10701D189C821D089CBF7D321F309D801C7037DF481C7937198FDC1C70C01CF89F821C889FBF7D321D309D801C60375F881C68E4379A6C1C61101FE89F021F889F3F7D321CB09D801C20355FC81C22108B449C1C21601F289D021F889FBF7D321F309D801C1034DC481C162251EF6C1C10501D189C821F089F3F7D321D309D801C7037DD881C740B340C0C1C70901CF89F821D089D3F7D321CB09D801C60375EC81C6515A5E26C1C60E01FE89F021C889CBF7D321FB09D801C20355C081C2AAC7B6E9C1C21401F289D021F889FBF7D321F309D801C1034DD481C15D102FD6C1C10501D189C821F089F3F7D321D309D801C7037DE881C753144402C1C70901CF89F821D089D3F7D321CB09D801C60375FC81C681E6A1D8C1C60E01FE89F021C889CBF7D321FB09D801C20355D081C2C8FBD3E7C1C21401F289D021F889FBF7D321F309D801C1034DE481C1E6CDE121C1C10501D189C821F089F3F7D321D309D801C7037D'
$_MD5Opcode &= 'F881C7D60737C3C1C70901CF89F821D089D3F7D321CB09D801C60375CC81C6870DD5F4C1C60E01FE89F021C889CBF7D321FB09D801C20355E081C2ED145A45C1C21401F289D021F889FBF7D321F309D801C1034DF481C105E9E3A9C1C10501D189C821F089F3F7D321D309D801C7037DC881C7F8A3EFFCC1C70901CF89F821D089D3F7D321CB09D801C60375DC81C6D9026F67C1C60E01FE89F021C889CBF7D321FB09D801C20355F081C28A4C2A8DC1C21401F289D031F031F801C1034DD481C14239FAFFC1C10401D189C831D031F001C7037DE081C781F67187C1C70B01CF89F831C831D001C60375EC81C622619D6DC1C61001FE89F031F831C801C20355F881C20C38E5FDC1C21701F289D031F031F801C1034DC481C144EABEA4C1C10401D189C831D031F001C7037DD081C7A9CFDE4BC1C70B01CF89F831C831D001C60375DC81C6604BBBF6C1C61001FE89F031F831C801C20355E881C270BCBFBEC1C21701F289D031F031F801C1034DF481C1C67E9B28C1C10401D189C831D031F001C7037DC081C7FA27A1EAC1C70B01CF89F831C831D001C60375CC81C68530EFD4C1C61001FE89F031F831C801C20355D881C2051D8804C1C21701F289D031F031F801C1034DE481C139D0D4D9C1C10401D189C831D031F001C7037DF081C7E599DBE6C1C70B01CF89F831C831D001C60375FC81C6F87CA21FC1C61001FE89F031F831C801C20355C881C26556ACC4C1C21701F289F8F7D009D031F001C1034DC081C1442229F4C1C10601D189F0F7D009C831D001C7037DDC81C797FF2A43C1C70A01CF89D0F7D009F831C801C60375F881C6A72394ABC1C60F01FE89C8F7D009F031F801C20355D481C239A093FCC1C21501F289F8F7D009D031F001C1034DF081C1C3595B65C1C10601D189F0F7D009C831D001C7037DCC81C792CC0C8FC1C70A01CF89D0F7D009F831C801C60375E881C67DF4EFFFC1C60F01FE89C8F7D009F031F801C20355C481C2D15D8485C1C21501F289F8F7D009D031F001C1034DE081C14F7EA86FC1C10601D189F0F7D009C831D001C7037DFC81C7E0E62CFEC1C70A01CF89D0F7D009F831C801C60375D881C6144301A3C1C60F01FE89C8F7D009F031F801C20355F481C2A111084EC1C21501F289F8F7D009D031F001C1034DD081C1827E53F7C1C10601D189F0F7D009C831D001C7037DEC81C735F23ABDC1C70A01CF89D0F7D009F831C801C60375C881C6BBD2D72AC1C60F01FE89C8F7D009F031F801C20355E481C291D386EBC1C21501F28B4508010801500401700801780C5F5E5BC9C20800C814000053E840000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008F45EC8B5D0C6A088D4310508D'
$_MD5Opcode &= '45F850E8510000008B4310C1E80383E03F8945F483F838730B6A38582B45F48945F0EB096A78582B45F48945F0FF75F0FF75ECFF750CE831F8FFFF6A088D45F850FF750CE823F8FFFF6A1053FF7508E8050000005BC9C210005589E55156578B7D088B750C8B4D10FCF3A45F5E595DC20C00'
Global $_MD5CodeBuffer='',$_SHA1CodeBuffer='',$CodeBuffer
If @AutoItX64 Then
MsgBox(32,"ACN_HASH","此加密函数不能用于64位AutoIt版本,请编译为32位版本.",5)
Exit
EndIf
;======================================================
;
; 函数名称: _Base64Decode
; 详细信息: Base64解码
; 返回值 :
; 作者: Ward(Taiwan)
;
;======================================================
Func _Base64Decode($Data)
Local $Opcode = "0xC81000005356578365F800E8500000003EFFFFFF3F3435363738393A3B3C3DFFFFFF00FFFFFF000102030405060708090A0B0C0D0E0F10111213141516171819FFFFFFFFFFFF1A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132338F45F08B7D0C8B5D0831D2E9910000008365FC00837DFC047D548A034384C0750383EA033C3D75094A803B3D75014AB00084C0751A837DFC047D0D8B75FCC64435F400FF45FCEBED6A018F45F8EB1F3C2B72193C7A77150FB6F083EE2B0375F08A068B75FC884435F4FF45FCEBA68D75F4668B06C0E002C0EC0408E08807668B4601C0E004C0EC0208E08847018A4602C0E00624C00A46038847028D7F038D5203837DF8000F8465FFFFFF89D05F5E5BC9C21000"
Local $CodeBuffer = DllStructCreate("byte[" & BinaryLen($Opcode) & "]")
DllStructSetData($CodeBuffer, 1, $Opcode)
Local $Ouput = DllStructCreate("byte[" & BinaryLen($Data) & "]")
Local $Ret = DllCall("user32.dll", "int", "CallWindowProc", "ptr", DllStructGetPtr($CodeBuffer), _
"str", $Data, _
"ptr", DllStructGetPtr($Ouput), _
"int", 0, _
"int", 0)
Return BinaryMid(DllStructGetData($Ouput, 1), 1, $Ret[0])
EndFunc
;======================================================
;
; 函数名称: _Base64Encode
; 详细信息: Base64编码
; 返回值 :
; 作者: Ward(Taiwan)
;
;======================================================
Func _Base64Encode($Data, $LineBreak = 76)
Local $Opcode = "0x5589E5FF7514535657E8410000004142434445464748494A4B4C4D4E4F505152535455565758595A6162636465666768696A6B6C6D6E6F707172737475767778797A303132333435363738392B2F005A8B5D088B7D108B4D0CE98F0000000FB633C1EE0201D68A06880731C083F901760C0FB6430125F0000000C1E8040FB63383E603C1E60409C601D68A0688470183F90176210FB6430225C0000000C1E8060FB6730183E60FC1E60209C601D68A06884702EB04C647023D83F90276100FB6730283E63F01D68A06884703EB04C647033D8D5B038D7F0483E903836DFC04750C8B45148945FC66B80D0A66AB85C90F8F69FFFFFFC607005F5E5BC9C21000"
Local $CodeBuffer = DllStructCreate("byte[" & BinaryLen($Opcode) & "]")
DllStructSetData($CodeBuffer, 1, $Opcode)
$Data = Binary($Data)
Local $Input = DllStructCreate("byte[" & BinaryLen($Data) & "]")
DllStructSetData($Input, 1, $Data)
$LineBreak = Floor($LineBreak / 4) * 4
Local $OputputSize = Ceiling(BinaryLen($Data) * 4 / 3)
$OputputSize = $OputputSize + Ceiling($OputputSize / $LineBreak) * 2 + 4
Local $Ouput = DllStructCreate("char[" & $OputputSize & "]")
DllCall("user32.dll", "none", "CallWindowProc", "ptr", DllStructGetPtr($CodeBuffer), _
"ptr", DllStructGetPtr($Input), _
"int", BinaryLen($Data), _
"ptr", DllStructGetPtr($Ouput), _
"uint", $LineBreak)
Return DllStructGetData($Ouput, 1)
EndFunc
;======================================================
;
; 函数名称: _CRC32
; 详细信息: CRC32编码
; 返回值 :
; 作者: Ward(Taiwan)
;
;======================================================
Func _CRC32($Data, $CRC32 = -1)
If @AutoItX64 Then
Local $Opcode = '0x554889E54881EC2004000048894D10488955184489452044894D28C745F800000000EB468B45F88945ECC745FC08000000EB1E8B45EC83E00184C0740D8B45ECD1E83345288945ECEB03D16DEC836DFC01837DFC007FDC8B45F848988B55EC899485E0FBFFFF8345F801817DF8FF0000007EB1488B4510488945F0C745F800000000EB318B452089C2C1EA088B45F84898480345F00FB6000FB6C033452025FF00000089C08B8485E0FBFFFF31D08945208345F8018B45F84898483B451872C48B4520F7D0C9C3'
Else
Local $Opcode = '0xC8000400538B5514B9000100008D41FF516A0859D1E8730231D0E2F85989848DFCFBFFFFE2E78B5D088B4D0C8B451085DB7416E3148A1330C20FB6D2C1E80833849500FCFFFF43E2ECF7D05BC9C21000'
EndIf
Local $CodeBuffer = DllStructCreate("byte[" & BinaryLen($Opcode) & "]")
DllStructSetData($CodeBuffer, 1, $Opcode)
Local $Input = DllStructCreate("byte[" & BinaryLen($Data) & "]")
DllStructSetData($Input, 1, $Data)
Local $Ret = DllCall("user32.dll", "uint", "CallWindowProc", "ptr", DllStructGetPtr($CodeBuffer), _
"ptr", DllStructGetPtr($Input), _
"int", BinaryLen($Data), _
"uint", $CRC32, _
"int", 0)
$Input = 0
$CodeBuffer = 0
Return $Ret[0]
EndFunc
;======================================================
;
; 函数名称: _MD5Init
; 详细信息: _MD5初始化
; 返回值 :
; 作者: Ward(Taiwan)
;
;======================================================
Func _MD5Init()
If Not IsDeclared("_MD5CodeBuffer") Or Not IsDllStruct($_MD5CodeBuffer) Then
Global $_MD5CodeBuffer = DllStructCreate("byte[" & BinaryLen($_MD5Opcode) & "]")
DllStructSetData($_MD5CodeBuffer, 1, $_MD5Opcode)
EndIf
;Local $OpcodeStart = (StringInStr($_MD5Opcode, "5589E58B4D08") - 1) / 2 - 1
Local $OpcodeStart = 62
Local $MD5CTX = DllStructCreate("dword[22]")
DllCall("user32.dll", "none", "CallWindowProc", "ptr", DllStructGetPtr($_MD5CodeBuffer) + $OpcodeStart, _
"ptr", DllStructGetPtr($MD5CTX), _
"int", 0, _
"int", 0, _
"int", 0)
$CodeBuffer = 0
Return $MD5CTX
EndFunc
;======================================================
;
; 函数名称: _MD5Input
; 详细信息: MD5输入
; 返回值 :
; 作者: Ward(Taiwan)
;
;======================================================
Func _MD5Input(ByRef $MD5CTX, $Data)
If Not IsDeclared("_MD5CodeBuffer") Or Not IsDllStruct($_MD5CodeBuffer) Then Return
;Local $OpcodeStart = (StringInStr($_MD5Opcode, "C80C0000538B5D08") - 1) / 2 - 1
Local $OpcodeStart = 107
Local $Input = DllStructCreate("byte[" & BinaryLen($Data) & "]")
DllStructSetData($Input, 1, $Data)
DllCall("user32.dll", "none", "CallWindowProc", "ptr", DllStructGetPtr($_MD5CodeBuffer) + $OpcodeStart, _
"ptr", DllStructGetPtr($MD5CTX), _
"ptr", DllStructGetPtr($Input), _
"int", BinaryLen($Data), _
"int", 0)
$Input = 0
EndFunc
;======================================================
;
; 函数名称: _MD5Result
; 详细信息: _MD5结果
; 返回值 :
; 作者: Ward(Taiwan)
;
;======================================================
Func _MD5Result(ByRef $MD5CTX)
If Not IsDeclared("_MD5CodeBuffer") Or Not IsDllStruct($_MD5CodeBuffer) Then Return Binary(0)
;Local $OpcodeStart = (StringInStr($_MD5Opcode, "C814000053") - 1) / 2 - 1
Local $OpcodeStart = 1960
Local $Digest = DllStructCreate("byte[16]")
DllCall("user32.dll", "none", "CallWindowProc", "ptr", DllStructGetPtr($_MD5CodeBuffer) + $OpcodeStart, _
"ptr", DllStructGetPtr($Digest), _
"ptr", DllStructGetPtr($MD5CTX), _
"int", 0, _
"int", 0)
Local $Ret = DllStructGetData($Digest, 1)
$CodeBuffer = 0
$Digest = 0
$MD5CTX = 0
$_MD5CodeBuffer = 0
Return $Ret
EndFunc
;======================================================
;
; 函数名称: _MD5
; 详细信息: MD5编码
; 返回值 :
; 作者: Ward(Taiwan)
;
;======================================================
Func _MD5($Data)
Local $CodeBuffer = DllStructCreate("byte[" & BinaryLen($_MD5Opcode) & "]")
DllStructSetData($CodeBuffer, 1, $_MD5Opcode)
Local $Input = DllStructCreate("byte[" & BinaryLen($Data) & "]")
DllStructSetData($Input, 1, $Data)
Local $Digest = DllStructCreate("byte[16]")
DllCall("user32.dll", "none", "CallWindowProc", "ptr", DllStructGetPtr($CodeBuffer), _
"ptr", DllStructGetPtr($Input), _
"int", BinaryLen($Data), _
"ptr", DllStructGetPtr($Digest), _
"int", 0)
Local $Ret = DllStructGetData($Digest, 1)
$Input = 0
$Digest = 0
$CodeBuffer = 0
Return $Ret
EndFunc
;======================================================
;
; 函数名称: _RC4
; 详细信息: RC4编码
; 返回值 :
; 作者: Ward(Taiwan)
;
;======================================================
Func _RC4($Data, $Key)
Local $Opcode = "0xC81001006A006A005356578B551031C989C84989D7F2AE484829C88945F085C00F84DC000000B90001000088C82C0188840DEFFEFFFFE2F38365F4008365FC00817DFC000100007D478B45FC31D2F775F0920345100FB6008B4DFC0FB68C0DF0FEFFFF01C80345F425FF0000008945F48B75FC8A8435F0FEFFFF8B7DF486843DF0FEFFFF888435F0FEFFFFFF45FCEBB08D9DF0FEFFFF31FF89FA39550C76638B85ECFEFFFF4025FF0000008985ECFEFFFF89D80385ECFEFFFF0FB6000385E8FEFFFF25FF0000008985E8FEFFFF89DE03B5ECFEFFFF8A0689DF03BDE8FEFFFF860788060FB60E0FB60701C181E1FF0000008A840DF0FEFFFF8B750801D6300642EB985F5E5BC9C21000"
Local $CodeBuffer = DllStructCreate("byte[" & BinaryLen($Opcode) & "]")
DllStructSetData($CodeBuffer, 1, $Opcode)
If Not IsBinary($Data) Then $Data=StringToBinary($Data,1)
Local $Buffer = DllStructCreate("byte[" & BinaryLen($Data) & "]")
DllStructSetData($Buffer, 1, $Data)
DllCall("user32.dll", "none", "CallWindowProc", "ptr", DllStructGetPtr($CodeBuffer), _
"ptr", DllStructGetPtr($Buffer), _
"int", BinaryLen($Data), _
"str", $Key, _
"int", 0)
Local $Ret = DllStructGetData($Buffer, 1)
$Buffer = 0
$CodeBuffer = 0
Return $Ret
EndFunc
;======================================================
;
; 函数名称: _SHA1Init
; 详细信息: SHA1初始化
; 返回值 :
; 作者: Ward(Taiwan)
;
;======================================================
Func _SHA1Init()
If Not IsDeclared("_SHA1CodeBuffer") Or Not IsDllStruct($_SHA1CodeBuffer) Then
Global $_SHA1CodeBuffer = DllStructCreate("byte[" & BinaryLen($_SHA1Opcode) & "]")
DllStructSetData($_SHA1CodeBuffer, 1, $_SHA1Opcode)
EndIf
Local $OpcodeStart = (StringInStr($_SHA1Opcode, "5589E5538B5D08") - 1) / 2 - 1
;Local $OpcodeStart = 62
Local $SHA1CTX = DllStructCreate("dword[26]")
DllCall("user32.dll", "none", "CallWindowProc", "ptr", DllStructGetPtr($_SHA1CodeBuffer) + $OpcodeStart, _
"ptr", DllStructGetPtr($SHA1CTX), _
"int", 0, _
"int", 0, _
"int", 0)
$CodeBuffer = 0
Return $SHA1CTX
EndFunc
;======================================================
;
; 函数名称: _SHA1Input
; 详细信息: SHA1输入
; 返回值 :
; 作者: Ward(Taiwan)
;
;======================================================
Func _SHA1Input(ByRef $SHA1CTX, $Data)
If Not IsDeclared("_SHA1CodeBuffer") Or Not IsDllStruct($_SHA1CodeBuffer) Then Return
Local $OpcodeStart = (StringInStr($_SHA1Opcode, "5589E55356578B5D08837D1000") - 1) / 2 - 1
;Local $OpcodeStart = 107
Local $Input = DllStructCreate("byte[" & BinaryLen($Data) & "]")
DllStructSetData($Input, 1, $Data)
DllCall("user32.dll", "none", "CallWindowProc", "ptr", DllStructGetPtr($_SHA1CodeBuffer) + $OpcodeStart, _
"ptr", DllStructGetPtr($SHA1CTX), _
"ptr", DllStructGetPtr($Input), _
"int", BinaryLen($Data), _
"int", 0)
$Input = 0
EndFunc
;======================================================
;
; 函数名称: _SHA1Result
; 详细信息: SHA1结果
; 返回值 :
; 作者: Ward(Taiwan)
;
;======================================================
Func _SHA1Result(ByRef $SHA1CTX)
If Not IsDeclared("_SHA1CodeBuffer") Or Not IsDllStruct($_SHA1CodeBuffer) Then Return Binary(0)
Local $OpcodeStart = (StringInStr($_SHA1Opcode, "5589E55657FF750C") - 1) / 2 - 1
;Local $OpcodeStart = 1960
Local $Digest = DllStructCreate("byte[20]")
DllCall("user32.dll", "none", "CallWindowProc", "ptr", DllStructGetPtr($_SHA1CodeBuffer) + $OpcodeStart, _
"ptr", DllStructGetPtr($Digest), _
"ptr", DllStructGetPtr($SHA1CTX), _
"int", 0, _
"int", 0)
Local $Ret = DllStructGetData($Digest, 1)
$CodeBuffer = 0
$Digest = 0
$SHA1CTX = 0
$_SHA1CodeBuffer = 0
Return $Ret
EndFunc
;======================================================
;
; 函数名称: _SHA1
; 详细信息: SHA1编码
; 返回值 :
; 作者: Ward(Taiwan)
;
;======================================================
Func _SHA1($Data)
Local $CodeBuffer = DllStructCreate("byte[" & BinaryLen($_SHA1Opcode) & "]")
DllStructSetData($CodeBuffer, 1, $_SHA1Opcode)
Local $Input = DllStructCreate("byte[" & BinaryLen($Data) & "]")
DllStructSetData($Input, 1, $Data)
Local $Digest = DllStructCreate("byte[20]")
DllCall("user32.dll", "none", "CallWindowProc", "ptr", DllStructGetPtr($CodeBuffer), _
"ptr", DllStructGetPtr($Input), _
"int", BinaryLen($Data), _
"ptr", DllStructGetPtr($Digest), _
"int", 0)
Local $Ret = DllStructGetData($Digest, 1)
$Input = 0
$Digest = 0
$CodeBuffer = 0
Return $Ret
EndFunc
;======================================================
;
; 函数名称: _XXTEA_Encrypt
; 详细信息: _XXTEA编码
; 返回值 :
; 作者: Ward(Taiwan)
;
;======================================================
Func _XXTEA_Encrypt($Data, $Key)
$Data = Binary($Data)
Local $DataLen = BinaryLen($Data)
If $DataLen = 0 Then
Return ""
ElseIf $DataLen < 8 Then
$DataLen = 8
EndIf
Local $Opcode = '0x83EC14B83400000099538B5C2420558B6C242056578B7C9DFCF7FB89C683C606C74424180000000085F68D76FF0F8EEA000000896C24288D4BFF8D549D00894C2410895424148974242081442418B979379E8B4C2418C1E90281E103000000894C241C31F6397424107E568B5424288BCF8B6CB204C1E9058D14AD0000000033CA8BD58BC7C1EA03C1E00433D003CA8B5424188BDE81E303000000335C241C8B4424308B1C9833D533DF03D333CA8B542428010CB28B0CB2463974241089CF7FAA8B5424288BCF8B2AC1E9058D14AD0000000033CA8BD58BC7C1EA03C1E00433D003CA8B5424188BDE81E303000000335C241C8B4424308B1C9833D533DF03D3FF4C242033CA8B542414014AFC8B4AFC8B54242089CF420F8F2DFFFFFF5F31C05E5D5B83C414C21000'
Local $CodeBuffer = DllStructCreate("byte[" & BinaryLen($Opcode) & "]")
DllStructSetData($CodeBuffer, 1, $Opcode)
Local $V = DllStructCreate("byte[" & Ceiling($DataLen / 4) * 4 & "]")
DllStructSetData($V, 1, $Data)
Local $K = DllStructCreate("byte[16]")
DllStructSetData($K, 1, $Key)
DllCall("user32.dll", "none", "CallWindowProc", "ptr", DllStructGetPtr($CodeBuffer), _
"ptr", DllStructGetPtr($V), _
"int", Ceiling($DataLen / 4), _
"ptr", DllStructGetPtr($K), _
"int", 0)
Local $Ret = DllStructGetData($V, 1)
$CodeBuffer = 0
$V = 0
$K = 0
Return $Ret
EndFunc
;======================================================
;
; 函数名称: _XXTEA_Decrypt
; 详细信息: _XXTEA解码
; 返回值 :
; 作者: Ward(Taiwan)
;
;======================================================
Func _XXTEA_Decrypt($Data, $Key)
$Data = Binary($Data)
Local $DataLen = BinaryLen($Data)
If $DataLen = 0 Then Return ""
Local $Opcode = '0x83EC10B83400000099538B5C241C55568B742420578B3EF7FB69D0B979379E81C256DA4CB5895424180F84DD000000897424248D4BFF8D149E894C2410895424148B4C2418C1E90281E103000000894C241C8B742410837C2410007E528B5424248B6CB2FC8BCD8BD7C1E905C1E20233CA8BD78BC5C1EA03C1E00433D003CA8B5424188BDE81E3030000008B44242C33D7335C241C8B1C9833DD03D333CA8B542424290CB28B0CB24E89CF85F67FAE8B5424148B6AFC8BCD8BD7C1E905C1E20233CA8BD78BC5C1EA03C1E00433D003CA8B5424188BDE81E3030000008B44242C33D7335C241C8B1C9833DD03D333CA8B542424290A8B0A89CF814424184786C861837C2418000F8535FFFFFF5F31C05E5D5B83C410C21000'
Local $CodeBuffer = DllStructCreate("byte[" & BinaryLen($Opcode) & "]")
DllStructSetData($CodeBuffer, 1, $Opcode)
Local $V = DllStructCreate("byte[" & Ceiling($DataLen / 4) * 4 & "]")
DllStructSetData($V, 1, $Data)
Local $K = DllStructCreate("byte[16]")
DllStructSetData($K, 1, $Key)
DllCall("user32.dll", "none", "CallWindowProc", "ptr", DllStructGetPtr($CodeBuffer), _
"ptr", DllStructGetPtr($V), _
"int", Ceiling($DataLen / 4), _
"ptr", DllStructGetPtr($K), _
"int", 0)
Local $Ret = DllStructGetData($V, 1)
$CodeBuffer = 0
$V = 0
$K = 0
Return $Ret
EndFunc
;======================================================
;
; 函数名称: _XXTEA_Encrypt_Pad
; 详细信息: _XXTEA编码算法
; 返回值 :
; 作者: Ward(Taiwan)
;
;======================================================
Func _XXTEA_Encrypt_Pad($Data, $Key)
$Data = Binary($Data)
Local $DataLen = BinaryLen($Data), $DataPad
Switch(Mod($DataLen, 4))
Case 0
$DataPad = Binary("0x80000000")
Case 1
$DataPad = Binary("0x800000")
Case 2
$DataPad = Binary("0x8000")
Case 3
$DataPad = Binary("0x80")
EndSwitch
Return _XXTEA_Encrypt($Data & $DataPad, $Key)
EndFunc
;======================================================
;
; 函数名称: _XXTEA_Decrypt_Pad
; 详细信息: _XXTEA解码算法
; 返回值 :
; 作者: Ward(Taiwan)
;
;======================================================
Func _XXTEA_Decrypt_Pad($Data, $Key)
$Data = _XXTEA_Decrypt($Data, $Key)
Local $DataLen = BinaryLen($Data), $i
For $i = $DataLen To $DataLen - 8 Step -1
If BinaryMid($Data, $i, 1) = Binary("0x80") Then
$Data = BinaryMid($Data, 1, $i - 1)
ExitLoop
EndIf
Next
Return $Data
EndFunc