1.pk8 및 x509.pem은 jks를 생성합니다.
https://blog.csdn.net/laipigui905/article/details/112347159
2. jks sha256 보기
- keytool -목록 -v -keystore xxx.jks
- 키 입력
3. APK sha256 보기
- APK의 압축을 풉니다
- 키 도구 -printcert -file xxx\META-INF\CERT.RSA
4. Python을 통해 apk의 서명 보기
# -*- coding: utf-8 -*-
#coding:utf-8
from cProfile import run
import os
from subprocess import call
import sys
import zipfile
# 解压出来的路径
def getExtractPath(apkPath):
return apkPath + "_files/"
# 解压apk
def un_zip(apk_path, extract_path):
print("unzip:", apk_path)
zip_file = zipfile.ZipFile(apk_path)
if os.path.isdir(extract_path):
pass
else:
os.mkdir(extract_path)
for names in zip_file.namelist():
zip_file.extract(names, extract_path)
zip_file.close()
# 获取签名信息
def getSignatureSha256(extractPath):
certRSAPath = extractPath + "/META-INF/CERT.RSA"
outputPath = extractPath + "/sign.txt"
cmd = "keytool -printcert -file " + certRSAPath + " > " + outputPath
call("keytool -printcert -file " + certRSAPath)
return os.system(cmd)
# 读取sha256
def readSignatureSha256(extractPath):
outputPath = extractPath + "/sign.txt"
for line in open(outputPath):
if(line.__contains__("SHA256")):
return line.strip()
argv = sys.argv[1:]
print(argv)
apkPath = argv[0]
extractPath = getExtractPath(apkPath)
un_zip(apkPath , extractPath)
getSignatureSha256(extractPath)
sha256 = readSignatureSha256(extractPath)
print(sha256)