win 下批量查看 Apk 签名信息
目录结构:
# -*-coding=utf-8-*-
import os
import zipfile
import shutil
BASE_DIR = os.path.dirname(__file__)
apkPath = os.path.join(BASE_DIR, 'apk')
out = os.path.exists('out')
if out:
shutil.rmtree('out')
os.mkdir('out')
else:
os.mkdir('out')
outDir = os.path.join(BASE_DIR, 'out')
list = os.listdir(apkPath)
for file in list:
f = os.path.join(apkPath, file)
outFile = os.path.join(outDir, file)
if f.endswith(".apk"):
z=zipfile.ZipFile(f, 'r')
for fileName in z.namelist():
if fileName.endswith('.RSA'):
content = z.read(fileName)
certFileName = outFile + '.RSA'
certfile = open(certFileName, 'wb')
certfile.write(content)
certfile.close()
result = outFile + '.txt'
cmd = 'keytool -printcert -file "%s" > "%s"' % (certFileName, result)
os.system(cmd)