-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathstring-decode.py
More file actions
43 lines (31 loc) · 991 Bytes
/
string-decode.py
File metadata and controls
43 lines (31 loc) · 991 Bytes
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
#!/usr/bin/env python
'''
Standalone Python program to de-obfuscate Android/Ztorg strings
Example:
$ python string-decode.py -i '50, 64, 63, 42, 70, 41'
[$1]
'''
import argparse
def get_arguments():
parser = argparse.ArgumentParser(description='Ztorg string de-obfuscation')
parser.add_argument('-i', '--input', help='bytes to decode - provide something like 1,2,3', action='store')
args = parser.parse_args()
return args
def decodeBytes(buf):
'''Decodes the buffer and returns the decoded result
Similar to La/b/c;->a([B)Ljava/lang/String;
'''
key0 = buf[0]
key1 = buf[len(buf)-1]
# copy buffer
result = buf[1:len(buf)-1]
# decode
for i in range(0, len(result)):
result[i] = result[i] ^ key1
result[i] = result[i] ^ key0
return result
if __name__ == "__main__":
args = get_arguments()
array = [ int(i) for i in args.input.split(',') ]
result = decodeBytes(array)
print ''.join(map(chr,result))