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 ! 🙂