forked from kevthehermit/Scripts
-
Notifications
You must be signed in to change notification settings - Fork 3
/
adWindDecoder.py
76 lines (59 loc) · 1.74 KB
/
adWindDecoder.py
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
#!/usr/bin/env python
'''
Adwind Class Decoder
'''
__description__ = 'Adwind Class Decoder'
__author__ = 'Kevin Breen http://techanarchy.net'
__version__ = '0.1'
__date__ = '2014/01'
import sys
import string
import os
from optparse import OptionParser
import zlib
try:
from Crypto.Cipher import ARC4
from Crypto.Cipher import DES
except ImportError:
print "Cannot import PyCrypto, Is it installed?"
def main():
parser = OptionParser(usage='usage: %prog [options] pass inFile outFile\n' + __description__, version='%prog ' + __version__)
parser.add_option("-d", "--DES", action='store_true', default=False, help="ENC Mode = DES")
parser.add_option("-r", "--RC4", action='store_true', default=False, help="ENC Mode = RC4")
(options, args) = parser.parse_args()
if len(args) != 3:
parser.print_help()
sys.exit()
password = args[0]
infile = args[1]
outfile = args[2]
with open(outfile, 'w') as out:
data = open(infile, 'rb').read()
if options.DES == True:
result = DecryptDES(password[:8], data)
elif options.RC4 == True:
result = DecryptRC4(password, data)
else:
print "No Cypher selected"
sys.exit()
if infile.endswith(".adwind"):
result = decompress(result)
out.write(result)
else:
result = filter(lambda x: x in string.printable, result)
out.write(result)
#### DES Cipher ####
def DecryptDES(enckey, data):
cipher = DES.new(enckey, DES.MODE_ECB) # set the ciper
return cipher.decrypt(data) # decrpyt the data
####RC4 Cipher ####
def DecryptRC4(enckey, data):
cipher = ARC4.new(enckey) # set the ciper
return cipher.decrypt(data) # decrpyt the data
#### ZLIB ####
def decompress(data):
ba = bytearray(data)
this = zlib.decompress(bytes(data), 15+32)
return this
if __name__ == "__main__":
main()