forked from Gyoonus/deoptfuscator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
deoptfuscator.py
30 lines (25 loc) · 1.11 KB
/
deoptfuscator.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
#!/usr/bin/env python3
import sys
import os
sys.path.insert(0, 'deobfuscator')
import deobfuscator
import sys
if len(sys.argv) != 2:
print("Insufficient arguments")
sys.exit()
apk_name = sys.argv[1]
os.system("rm -rf .apk .std* .profile meta")
os.system("java -jar $TOOLS/apktool.jar d -r -s " + apk_name + " -o .apk")
dex_li = [a for a in os.listdir(".apk") if a.endswith(".dex") and a.startswith("classes")]
os.mkdir(".apk/const")
for dex in dex_li:
deobfuscator.main(".apk/"+dex)
os.system("$TOOLS/redex-all -c $TOOLS/default.config .apk/const/const.dex -o .apk/const")
print("$TOOLS/redex-all -c $TOOLS/default.config .apk/const/const.dex -o .apk/const")
os.system("mv .apk/const/classes.dex .apk/"+dex)
apk_name = apk_name.replace(".apk", "_deobfuscated.apk")
apk_name = os.path.basename(apk_name)
os.system("java -jar $TOOLS/apktool.jar b ./.apk -o " + apk_name)
os.system("zipalign -f -v 4 " + apk_name + " " + apk_name.replace(".apk", "_align.apk"))
os.system("apksigner sign --ks deoptfuscator.keystore --ks-pass pass:123456 " + apk_name.replace(".apk", "_align.apk"))
os.system("rm -rf " + apk_name)