用python解壓分析jar包實(shí)例
寫這個(gè)玩意的背景:在u8多渠道打包里,需要分析jar包,并把里面的文件按目錄和類型分別放在root和assets文件夾里,之前師兄都是手動(dòng)解壓,一個(gè)一個(gè)文件夾找文件,效率比較低,剛好最近手上的android項(xiàng)目已經(jīng)做完了,就決定寫一個(gè)自動(dòng)化分析jar文件并復(fù)制粘貼到指定文件夾的腳本。
# -*- coding: utf-8 -*-
import os
import shutil
import zipfile
count = 1
def getSumDir():
sumfilelist = os.listdir(os.getcwd())
for dir in sumfilelist:
if ".idea" not in dir:
classify(dir)
def getlibDir():
sumfilelist = os.listdir(os.getcwd())
for dir in sumfilelist:
if "libs" in dir:
jieyajar(dir)
def jieyajar(dir):
files = os.listdir(dir)
for jars in files:
if "jar" in jars:
zfile = zipfile.ZipFile('libs/' + jars, 'r')
if not os.path.exists(os.getcwd() + '/jarlog/' + jars):
os.makedirs(os.getcwd() + '/jarlog/' + jars)
zfile.extractall(os.getcwd() + '/jarlog/' + jars)
if not os.path.exists(os.getcwd() + '/jars/'):
os.makedirs(os.getcwd() + '/jars/')
zfile.extractall(os.getcwd() + '/jars/')
zfile.close
for file in os.listdir(os.getcwd()):
if "jars" in file:
classify(file)
# def classify(path):
# if os.path.isfile(path):
# if ".class" not in path:
# if "assets" in os.path.dirname(path):
# if not os.path.exists(os.path.dirname(os.getcwd()) + '/assets/' + os.path.dirname(path)):
# os.makedirs(os.path.dirname(os.getcwd()) + '/assets/' + os.path.dirname(path))
# shutil.copy(path, os.path.dirname(os.getcwd()) + '/assets/' + os.path.dirname(path))
# else:
# if not os.path.exists(os.path.dirname(os.getcwd())+'/root/'+os.path.dirname(path)):
# os.makedirs(os.path.dirname(os.getcwd())+'/root/'+os.path.dirname(path))
# shutil.copy(path,os.path.dirname(os.getcwd())+'/root/'+os.path.dirname(path))
# else :
# list = os.listdir(path)
# for dir in list:
# classify(path+"/"+dir)
def classify(path):
global count
if os.path.isfile(path):
if ".class" not in path:
if not os.path.exists(os.getcwd() + '/root/' + os.path.dirname(path)):
os.makedirs(os.getcwd() + '/root/' + os.path.dirname(path))
shutil.copy(path, os.getcwd() + '/root/' + os.path.dirname(path))
else:
if 'assets' in path and count == 1:
count = count + 1
shutil.copytree(os.getcwd()+'/'+path, os.getcwd() + '/assets')
elif 'META-INF' not in path:
list = os.listdir(path)
for dir in list:
classify(path + "/" + dir)
# getSumDir()
getlibDir()
嗯,主要就是對文件夾和文件的操作。。
以上這篇用python解壓分析jar包實(shí)例就是小編分享給大家的全部內(nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。
- Python爬蟲逆向分析某云音樂加密參數(shù)的實(shí)例分析
- Python調(diào)用jar包方法實(shí)現(xiàn)過程解析
- Python使用jpype模塊調(diào)用jar包過程解析
- Python代碼一鍵轉(zhuǎn)Jar包及Java調(diào)用Python新姿勢
- python如何使用jt400.jar包代碼實(shí)例
- 利用python腳本如何簡化jar操作命令
- Python3 使用cookiejar管理cookie的方法
- python調(diào)用java的jar包方法
- Java實(shí)現(xiàn)的執(zhí)行python腳本工具類示例【使用jython.jar】
- 將Python代碼打包為jar軟件的簡單方法
- python 逆向爬蟲正確調(diào)用 JAR 加密邏輯
相關(guān)文章
YOLOv5車牌識(shí)別實(shí)戰(zhàn)教程(七)實(shí)時(shí)監(jiān)控與分析
這篇文章主要介紹了YOLOv5車牌識(shí)別實(shí)戰(zhàn)教程(七)實(shí)時(shí)監(jiān)控與分析,在這個(gè)教程中,我們將一步步教你如何使用YOLOv5進(jìn)行車牌識(shí)別,幫助你快速掌握YOLOv5車牌識(shí)別技能,需要的朋友可以參考下2023-04-04
python matplotlib實(shí)現(xiàn)雙Y軸的實(shí)例
今天小編就為大家分享一篇python matplotlib實(shí)現(xiàn)雙Y軸的實(shí)例,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧2019-02-02
對Pycharm創(chuàng)建py文件時(shí)自定義頭部模板的方法詳解
今天小編就為大家分享一篇對Pycharm創(chuàng)建py文件時(shí)自定義頭部模板的方法詳解,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧2019-02-02
python內(nèi)置模塊datetime.timedelta計(jì)算時(shí)間間隔示例代碼
Python的datetime模塊提供了處理日期和時(shí)間的功能,包括datetime.date、datetime.time、datetime.datetime、datetime.timedelta等類,timedelta用于表示時(shí)間間隔,支持日期和時(shí)間的加減運(yùn)算,文中給出了詳細(xì)的代碼示例,需要的朋友可以參考下2025-04-04
Python爬蟲實(shí)戰(zhàn)之虎牙視頻爬取附源碼
讀萬卷書不如行萬里路,學(xué)的扎不扎實(shí)要通過實(shí)戰(zhàn)才能看出來,本篇文章手把手帶你爬取虎牙短視頻數(shù)據(jù),大家可以在實(shí)戰(zhàn)過程中查缺補(bǔ)漏,加深學(xué)習(xí)2021-10-10
基于Python實(shí)現(xiàn)一個(gè)春節(jié)倒計(jì)時(shí)腳本
春節(jié)即將到來,本文將為大家介紹一個(gè)通過Python實(shí)現(xiàn)的春節(jié)倒計(jì)時(shí)腳本,文中的示例代碼簡潔易懂,感興趣的小伙伴可以自己動(dòng)手嘗試一下2022-01-01
selenium+headless chrome爬蟲的實(shí)現(xiàn)示例
這篇文章主要介紹了selenium+headless chrome爬蟲的實(shí)現(xiàn)示例,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2021-01-01

