android查看签名信息

该文章详细介绍了如何通过Java的keytool工具以及Python脚本,从pk8和x509.pem文件生成jks存储,查看jks的SHA256摘要,以及从APK中提取并查看其SHA256签名信息。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1.pk8和x509.pem生成jks

https://blog.youkuaiyun.com/laipigui905/article/details/112347159

2.查看jks sha256
  • keytool -list -v -keystore xxx.jks
  • 输入密钥
    在这里插入图片描述
3.查看apk sha256
  • 解压apk
  • keytool -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)

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值