Decompile the apk file in batches using apktool and decompile the apk

Source: Internet
Author: User

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 ~"





















Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.