批量从apk文件中提取出so文件
发表时间:2020-10-19
发布人:葵宇科技
浏览次数:191
应用处景
在不解压apk文件夹的情况下批量的大年夜apk文件中提掏出所有的so文件。如许你即不消应用apktool 这些对象令产生大年夜量的中心文件,或者将apk的后改变为.zip,然后在解压,节俭了磁盘空间。
功能解释
提掏出一系列的apk文件然后提掏出它们中的所有so文件,按照apk的名字以及它们之前地点的文件夹进行存储。如下图所示:
[img]http://img.blog.csdn.net/20150104030103718?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvY2hpY2hveGlhbg==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast
代码实现
#!/usr/bin/env python
# coding=utf-8
import zipfile
import os
path = "/home/chicho/test/test/"
so_path="/home/chicho/test/test/so/"
apklist=os.listdir(path)
for APK in apklist:
if APK.endswith(".zip"):
portion = os.path.splitext(APK)
apkname = portion[0]
abs_so_path=os.path.join(so_path,apkname) #/so/apkname/
abs_zipAPK_path=os.path.join(path,APK)
z = zipfile.ZipFile(abs_zipAPK_path,'r')
solists=[]
for filename in z.namelist():
if filename.endswith(".so"):
sofileName = os.path.basename(filename)
soSource = os.path.basename(os.path.dirname(filename))
'''
make a dir with the source(arm?mips)
'''
storePath=os.path.join(abs_so_path,soSource) # e.g. /.../so/apkname/mips/
if not os.path.exists(storePath):
os.makedirs(storePath)
'''
copy the xxx.so file to the object path
'''
newsofile=os.path.join(storePath,sofileName)
f = open(newsofile,'w')
f.write(z.read(filename))








