forked from idiom/IRScripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
alienspy-decrypt-v2.py
72 lines (52 loc) · 1.94 KB
/
alienspy-decrypt-v2.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
__description__ = 'AlienSpy Decoder v2'
__author__ = '@seanmw'
__version__ = '0.0.1'
__date__ = '2015/07/27'
import hashlib
from StringIO import StringIO
import zipfile
import argparse
from Crypto.Cipher import ARC4
import os
def getpassandconfig(jfname):
jar = zipfile.ZipFile(open(jfname, 'rb'))
pw = StringIO(jar.read('a.txt')).read()
config = StringIO(jar.read('b.txt')).read()
ratdata = (pw, config)
return ratdata
def decrypt_payload(ratdata):
static_key = 'plowkmsssssPosq34r'
rcobj = ARC4.new('{0}{1}{0}{1}{2}'.format(static_key, ratdata[0],'a'))
data = rcobj.decrypt(ratdata[1])
return data
def extract_props(data):
jtmp = StringIO()
jtmp.write(data)
jar = zipfile.ZipFile(jtmp)
files = jar.namelist()
# It looks like the jar file may be customized with the configured 'nickname'
# loop through the files until we find the path to the configuration file
for jfile in files:
if 'config.json' in jfile:
return StringIO(jar.read(jfile)).read()
def main():
parser = argparse.ArgumentParser(description="Decrypt adwind jar.")
parser.add_argument("jarfile", help="Adwind Jar file")
parser.add_argument('-p', '--props', dest='props', action='store_true', help="Extract properties config.xml file.")
parser.add_argument('-e', '--extract', dest='extract', action='store_true', help="Extract enctypted jar to out.jar.")
args = parser.parse_args()
rdata = getpassandconfig(args.jarfile)
if not os.path.isfile(args.jarfile):
raise Exception('File does not exist')
if args.props:
print 'Extracting Properties...'
propdata = extract_props(decrypt_payload(rdata))
out = open('config.json', 'wb')
out.write(propdata)
out.close()
if args.extract:
outfile = open('out.jar', 'wb')
outfile.write(decrypt_payload(rdata))
outfile.close()
if __name__ == '__main__':
main()