mbank-mobile-app-deadname-r.../mbankDeadnameRemover.sh

41 lines
1.6 KiB
Bash
Executable File

#!/bin/bash
if [[ $# -lt 2 ]]; then
echo "usage: $0 <mbank_apk> <your desired name(s)>"
exit 0
fi
apk=$(realpath $1)
mkdir mbank
cd mbank
[[ ! -f "apktool.jar" ]] && wget https://bitbucket.org/iBotPeaches/apktool/downloads/apktool_2.4.1.jar -O apktool.jar
[[ ! -f "signapk.jar" ]] && wget https://github.com/techexpertize/SignApk/raw/master/signapk.jar -O signapk.jar
[[ ! -f "zipalign.jar" ]] && wget https://git.sakamoto.pl/laudom/zipalign-java/uploads/8fcc06538b7392c623468e42c893f952/ZipAlign.jar -O zipalign.jar
java -jar apktool.jar d $apk -o base
strings_file_en=$(grep -Rl "Hello, %s" base/res/*)
strings_file_pl=$(grep -Rl "Witaj, %s" base/res/*)
sed -i "s/Hello, \%s/Hello, $2/" $strings_file_en
sed -i "s/Witaj, \%s/Witaj, $2/" $strings_file_pl
if [[ ! -f "crypto.crt" || ! -f "key.pk8" ]]; then
openssl genrsa -out crypto.key 1024
openssl req -new -key crypto.key -out crypto.csr -subj "/C=PL/ST=Warsaw/L=Warsaw/O=PaweĊ‚ Tanajno Rigcz Hawajska+ hacker collective"
openssl x509 -req -days 9999 -in crypto.csr -signkey crypto.key -out crypto.crt
cat crypto.key crypto.crt > certificate.pem
openssl pkcs8 -topk8 -outform DER -in certificate.pem -inform PEM -out key.pk8 -nocrypt
rm crypto.key crypto.csr certificate.pem
fi
java -jar apktool.jar --use-aapt2 b base -o out.apk
java -jar zipalign.jar out.apk out_aligned.apk # we don't know if this is strictly needed, but it might as well be
java -jar signapk.jar crypto.crt key.pk8 out_aligned.apk out_signed.apk
rm -R base
cp out_signed.apk ..
echo "IMPORTANT NOTE: please store crypto.crt and key.pk8 in a safe place - you'll need them to sign the app after any updates."
echo "OUTPUT FILE: out_signed.apk"