apk重签名shell

  • 内容
  • 评论
  • 相关

改脚本实现了:输入apk,自动生成签名文件,自动重签名apk。

#!/bin/bash

# Set the path to your Java JDK and Android SDK
JAVA_HOME=/usr/lib/jvm/java-11-openjdk-11.0.18.0.10-1.el7_9.x86_64
ANDROID_HOME=/root/sdk

# Set the path to the APK file you want to sign
APK_FILE="$@"

# Generate a random keystore file
KEYSTORE_FILE=/root/sdk/jks/keystore_$(date +%s).jks

# Set the password for the new keystore
KEYSTORE_PASSWORD=123456

# Generate a random key alias
KEY_ALIAS=random_key_$(date +%s)

# Set the password for the new key
KEY_PASSWORD=123456

# Generate a new keystore and key
$JAVA_HOME/bin/keytool -genkeypair -v -keystore $KEYSTORE_FILE -alias $KEY_ALIAS -keyalg RSA -keysize 2048 -validity 10000 -storepass $KEYSTORE_PASSWORD -keypass $KEY_PASSWORD -dname "CN=Unknown, OU=Unknown, O=Unknown, L=Unknown, ST=Unknown, C=Unknown"

# Sign the APK file with the new keystore and key
$ANDROID_HOME/build-tools/30.0.3/apksigner sign --ks $KEYSTORE_FILE --ks-pass "pass:$KEYSTORE_PASSWORD" --ks-key-alias $KEY_ALIAS --key-pass "pass:$KEY_PASSWORD" $APK_FILE

# Delete the temporary keystore file
rm $KEYSTORE_FILE

改脚本实现了:输入apk,自动生成签名文件,自动重签名apk。

评论

0条评论

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注