Decompile the apk file in batches using apktool and decompile the apk
Preface
This is a very simple script. Why do you want to write, because I am here to cheat the score.
Application scenarios
There are a bunch of APK files on the host, which are classified by category. Now we use apktool to decompile them and store them by category and apk name.
Implementation
To use this script, you need to install apktool. The annotations are very detailed and may be useful. Of course, you can also write a shell script for this implementation in python.
#! /Usr/bin/env python # coding = UTF-8 ''' @ author: chicho @ date: 2015-01-01 @ function: use apktool to decompile apk files @ rununing: python decompileAPK. py '''import OS # apk storage path apkPath = "/home/chicho/test/apps/" # Because APK storage is classified by category, therefore, the storage class dirlist = OS of each apk is obtained. listdir (apkPath) # The storage path outputPath = "/home/chicho/test/apktool_out/" after decompiling the apk with apktool (len (dirlist ): # Obtain the sub-category filelist = apkPath + dirlist [I] In the apk folder # obtain the path apklist = OS for each category. listdir (filelist) # obtain the apk list in each path category_output = outputPath + dirlist [I] # output path list if not OS. path. exists (category_output): # If the output path does not exist, create a path OS. makedirs (category_output) for APK in apklist: portion = OS. path. splitext (APK) # split the apk file according to their file name and suffix. apkoutPath = OS. path. join (category_output, portion [0]) # What is stored in portion is Apk file name APK = OS. path. join (apkPath + dirlist [I], APK) # if not OS. path. exists (apkoutPath): # OS. makedirs (apkoutPath) cmd = "apktool d {0} {1 }". format (APK, apkoutPath) # decompile the apk and store it in the storage OS according to the file name. system (cmd) print "all work done! Happy new year ~"