Skip to content

Instantly share code, notes, and snippets.

@HunterXProgrammer
Last active August 25, 2023 19:03
Show Gist options
  • Save HunterXProgrammer/ffa2af244caa225e70e2cac7faea32fb to your computer and use it in GitHub Desktop.
Save HunterXProgrammer/ffa2af244caa225e70e2cac7faea32fb to your computer and use it in GitHub Desktop.
#!/data/data/com.termux/files/usr/bin/bash
if [ -z "$1" ]
then
echo "No input file specified"
exit 1
fi
echo -ne "\n Checking if Termux has storage permission..."
rm -r ~/storage &>/dev/null
if ! touch /storage/emulated/0/.tmp_check_termux &>/dev/null
then
echo -e "\nGrant Termux storage permission and run the script again\n"
termux-setup-storage
exit 1
fi
rm -rf /storage/emulated/0/.tmp_check_termux &>/dev/null
termux-setup-storage
echo "done"
if [ $(command -v git keytool python apksigner zipalign openssl | wc -l) -ne 6 ]
then
apt update
yes | pkg install git python aapt apksigner openjdk-17 openssl-tool
fi
if [ $? -ne 0 ]; then
echo "Error, exiting..."
exit 1
fi
apk_name=$(basename "$1" | sed -E 's/\.apk$//')
tmpdir="$(mktemp -d)"
output_dir="/storage/emulated/0/Download/debug_apk"
mkdir -p $tmpdir &>/dev/null
cd $tmpdir
git clone https://github.com/julKali/makeDebuggable
cd makeDebuggable
sed -i 's/if subprocess.run(\[apksignerLoc, "sign", "--ks", keystore, "--ks-key-alias", keyAlias, fnOut\]).returncode != 0:/if subprocess.run(\[apksignerLoc, "sign", "--ks", keystore, "--ks-key-alias", keyAlias, "--ks-pass", "pass:android", fnOut\]).returncode != 0:/g' makeDebuggable.py
git clone https://github.com/wfairclough/android_aosp_keys keys
openssl pkcs8 -inform DER -nocrypt -in "keys/testkey.pk8" | openssl pkcs12 -export -in "keys/testkey.x509.pem" -inkey /dev/stdin -name "androiddebugkey" -password pass:android -out "keys/testkey.p12"
keytool -importkeystore -deststorepass android -srckeystore "keys/testkey.p12" -srcstoretype PKCS12 -srcstorepass android -destkeystore "debug.keystore"
python makeDebuggable.py apk $1 output.apk debug.keystore androiddebugkey
mkdir -p "$output_dir"
mv -f output.apk "${output_dir}/${apk_name}.debug.apk"
rm -rf $tmpdir $>/dev/null
echo -e "Completed. Find the apk at:-\n\n \"${output_dir}/${apk_name}.debug.apk\"\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment