Android view signature information

1.pk8 and x509.pem generate jks

https://blog.csdn.net/laipigui905/article/details/112347159

2. View jks sha256
  • keytool -list -v -keystore xxx.jks
  • enter key
    insert image description here
3. View apk sha256
  • unzip the apk
  • keytool -printcert -file xxx\META-INF\CERT.RSA
    insert image description here
4. View the signature of an apk through python
# -*- 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)

insert image description here

Guess you like

Origin blog.csdn.net/wangadping/article/details/129152350