Android一鍵V2簽名,校驗
一般Android加固都自帶重簽名功能,但是有的加固只加了V1簽名,所以還是得自己手動簽名下,下面是我用python寫的簽名以及校驗指令碼
一鍵V2簽名
# -*- coding: utf-8 -*- #python2.7 import os import os.path #Android BuildTools路徑 buildToolDir='...\\build-tools\\27.0.3\\' #keyStore路徑 keyStorePath='your jks file path' #keystore密碼 keyStorePassword = 'your keystore password' #key別名 keyAlias = 'your key alias' #key密碼 keyPassword = 'your key password' zipalignPath=buildToolDir+'zipalign.exe'; apksignerPath=buildToolDir+'lib\\apksigner.jar'; if (not os.path.exists('signed')): os.mkdir('signed') if (not os.path.exists('aligned')): os.mkdir('aligned') workDir = os.path.dirname(__file__) signedDir = os.path.join(workDir, "signed") alignedDir = os.path.join(workDir, "aligned") apkDir = os.path.join(workDir, "apks") #獲取要簽名的apk檔案列表 apkFileList = os.listdir(apkDir) for fileName in apkFileList: apkFilePath=os.path.join(apkDir, fileName) alignedFilePath=os.path.join(alignedDir, fileName) signedFilePath=os.path.join(signedDir, fileName) # zipalign print("start align:" + fileName) aligncmd = '%s -f 4 "%s" "%s"' % (zipalignPath,apkFilePath,alignedFilePath) os.system(aligncmd) # v1+v2簽名 print("start sign:" + fileName) signcmd = '%s sign --ks "%s" --ks-key-alias %s--ks-pass pass:"%s"--key-pass pass:"%s"--out "%s" "%s"' %\ (apksignerPath,keyStorePath,keyAlias,keyStorePassword,keyPassword,signedFilePath,alignedFilePath) os.system(signcmd) print(fileName + " sign finish!\n") os.system("pause");
一鍵校驗對齊與簽名
# -*- coding: utf-8 -*- #python2.7 import os import sys import os.path #Android BuildTools路徑 buildToolDir='...\\build-tools\\27.0.3\\' zipalignPath=buildToolDir+'zipalign.exe'; apksignerPath=buildToolDir+'lib\\apksigner.jar'; if (len(sys.argv)>1): apkFilePath=sys.argv[1] print("start verify:" + apkFilePath) # zipalign 校驗 aligncmd = '%s -c -v 4 "%s"' % (zipalignPath,apkFilePath) os.system(aligncmd) # v1+v2簽名校驗 signcmd = 'java -jar %s verify -v --print-certs "%s"' %(apksignerPath,apkFilePath) os.system(signcmd) print("verify finish!") os.system("pause");