Hi 🙂 , here I will explain how to write a simple python script to automate the process of decompiling Android APK files using apktool .jar.
- First, you need to have apktool.jar installed at location “/usr/local/bin/”.
- Then, put all the apk files in a directory: “/home/Documents/Project/APKS”.
- Now, you can simply traverse inside this directory using os.walk (path_to_dir) and decompile each apk using the commands available with apktool.jar
- Run the python script with this command
python decompileApk.py '/home/kulani/Documents/Project/APKS'
decompileApk.py
import os import sys import subprocess walk_dir = sys.argv[1] #-------------------------------------decompile---------------------------- i = 0 apktool = "/usr/local/bin/apktool.jar" for root, subdirs, files in os.walk(walk_dir): list_file_path = os.path.join(root, 'my-directory-list.txt') with open(list_file_path, 'wb') as list_file: for file in files: if file.endswith(".apk"): i=i+1 print str(i)+"-"+file os.system("java -jar " + apktool + " d " + root+"/"+file)
Cheers ! 🙂
ı try to use code above to decompile by apps but it doesnt work. I use the saem code.
can u tell something about this:
apktool = “/usr/local/bin/apktool.jar”
does it has to be in usr/local/bin/apktool.jar.
instead of this I put
c:\\apktool.
when I try to run python script it has an error
LikeLike
walk_dir= sys.argv[3]
IndexError: list index out of range
this is the error that I have.
LikeLike
Why did you put 3 for sys.argv[]?
In my code I use 1 for sys.argv[], to get the apk location ‘/home/kulani/Documents/Project/APKS’ from the command line
LikeLike
Great post all decomplie
LikeLike
where can we see the output?
LikeLike