android的一款整合jad,apktool,dex2jar的脚本
#! /usr/bin/env python #coding=utf-8 import os import subprocess import time import shutil,sys import zipfile apksrc="C:\\test\\test.apk" apkdest="" copyzip="" dex2dir="" jadsrc="" projectcodepath="" apktoolpath=r"F:\\bishe\android\apktool\apktool.bat" dex2jarpath=r"F:\\bishe\android\dex2jar-0.0.9.8\dex2jar-0.0.9.8\dex2jar.bat" jadexepath=r"F:\\bishe\android\jad158g\jad.exe" def apktools(src,dest): cmd_list=apktoolpath+r" d -f "+src+" "+dest print cmd_list process = subprocess.Popen(cmd_list) while 1: ret1 = subprocess.Popen.poll(process) if ret1 == 0: print process.pid,'end' break elif ret1 is None: time.sleep(1) else: print sub2.pid,'term' break print "apk tools end" def jad(src,dest): codesrc=dest+"src\\" if((os.path.exists(codesrc))==False): os.makedirs(codesrc) cmd_list=jadexepath+" -o -r -d "+codesrc+" -s java "+src+"**\\*.class" print cmd_list process = subprocess.Popen(cmd_list) while 1: ret1 = subprocess.Popen.poll(process) if ret1 == 0: print process.pid,'end' break elif ret1 is None: time.sleep(1) else: print sub2.pid,'term' break print "apk jad code successfully" def dex2jar(src,dest): cmd_list=dex2jarpath+" "+src+"classes.dex" print cmd_list process = subprocess.Popen(cmd_list) while 1: ret1 = subprocess.Popen.poll(process) if ret1 == 0: print process.pid,'end' break elif ret1 is None: time.sleep(1) else: print sub2.pid,'term' break print "apk dex2jar.bat successfully" def unzip(src,dest): print src f = zipfile.ZipFile(src) f.extractall(dest) f.close() print "apk unzip successfully" def GenerateProCode(dest): print jadsrc+"src" print dest shutil.copytree(jadsrc+"src\\",dest) shutil.copytree(apkdest,dest) def adbinstall(src): cmd_list="adb install "+src print cmd_list process = subprocess.Popen(cmd_list) while 1: ret1 = subprocess.Popen.poll(process) if ret1 == 0: print process.pid,'end' break elif ret1 is None: time.sleep(1) else: print sub2.pid,'term' break print "apk install successfully" def init(src,dest): global apkdest global dex2dir global copyzip global jadsrc global projectcodepath copyzip=os.path.dirname(src)+"\\"+"dex2jar.zip" if dest=="": apkdest=os.path.dirname(src)+"\\ProjectCode\\" shutil.copy2(src,copyzip) dex2dir=os.path.dirname(src)+"\\dex\\" jadsrc=os.path.dirname(src)+"\\jad\\" init(apksrc,apkdest) apktools(apksrc,apkdest) unzip(copyzip,dex2dir) dex2jar(dex2dir,apkdest) unzip(dex2dir+"classes_dex2jar.jar",jadsrc) jad(jadsrc,apkdest) adbinstall(apksrc)
代码如上,就是对一个apk文件自动解压缩,生成最终代码在projectcode中,包括了解压缩后的AndroidManifest.xml,反编译的java文件,资源文件等等
相关推荐
ProgrammerFan00 2020-01-23
大家好 2011-02-28
baqiuxiao 2011-08-13
attackeg 2014-09-04
attackeg 2011-12-25
yinbaoshiguang 2019-07-01
yinsui 2018-01-11
RungBy 2016-05-18
linghujava 2015-09-08
heavyle 2014-09-04
yubang 2013-08-14
heavyle 2013-05-09
tndroid 2012-12-01
zyygive 2012-08-05
HouSisong 2012-05-22
快乐生活 2012-04-16