批量從apk檔案中提取出so檔案,apk檔案提取so

來源:互聯網
上載者:User

批量從apk檔案中提取出so檔案,apk檔案提取so
應用情境在不解壓apk檔案夾的情況下批量的從apk檔案中提取出所有的so檔案。這樣你即不用使用apktool 這些工具令產生大量的中間檔案,或者將apk的尾碼變為.zip,然後在解壓,節省了磁碟空間。



功能說明提取出一系列的apk檔案然後提取出它們中的所有so檔案,按照apk的名字以及它們之前所在的檔案夾進行儲存。如所示:




代碼實現

#!/usr/bin/env python# coding=utf-8import zipfileimport ospath = "/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))







































聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.