-
-
Save mustafakibar/8f53e340ed72729763dd8365423bea5e to your computer and use it in GitHub Desktop.
Android APK Decompile Script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
APK=$1 | |
# Linux only right now. | |
if [ ! -d "$HOME/.android-decompile-tools" ]; then | |
mkdir "$HOME/.android-decompile-tools" | |
fi | |
# Install apktool | |
# https://ibotpeaches.github.io/Apktool/install/ | |
if [ ! -d "$HOME/.android-decompile-tools/apktool" ]; then | |
# make directory for apktool | |
mkdir "$HOME/.android-decompile-tools/apktool" | |
# Grab wrapper script | |
wget "https://raw.githubusercontent.com/iBotPeaches/Apktool/master/scripts/linux/apktool" -O "$HOME/.android-decompile-tools/apktool/apktool" | |
# Grab JAR | |
wget "https://bitbucket.org/iBotPeaches/apktool/downloads/apktool_2.2.0.jar" -O "$HOME/.android-decompile-tools/apktool/apktool.jar" | |
# Make both files executable as per instructions | |
chmod +x $HOME/.android-decompile-tools/apktool/* | |
fi | |
# Install dex2jar | |
# https://github.com/pxb1988/dex2jar | |
if [ ! -d "$HOME/.android-decompile-tools/dex2jar-2.0" ]; then | |
# Grab zip release | |
wget "https://github.com/pxb1988/dex2jar/releases/download/2.0/dex-tools-2.0.zip" -O "/tmp/dex-tools.zip" | |
# Unzip release | |
unzip "/tmp/dex-tools.zip" -d "$HOME/.android-decompile-tools" | |
# Clean up zip release | |
rm "/tmp/dex-tools.zip" | |
# Make all sh files executable | |
chmod +x $HOME/.android-decompile-tools/dex2jar-2.0/*.sh | |
fi | |
# Install JD-CMD | |
# https://github.com/kwart/jd-cmd | |
if [ ! -d "$HOME/.android-decompile-tools/jd-cmd" ]; then | |
# Make directory | |
mkdir "$HOME/.android-decompile-tools/jd-cmd" | |
# Get final release | |
wget "https://github.com/kwart/jd-cmd/releases/download/jd-cmd-0.9.1.Final/jd-cli-0.9.1.Final-dist.tar.gz" -O "/tmp/jd-cli.tar.gz" | |
# untar final release | |
tar xzf "/tmp/jd-cli.tar.gz" -C "$HOME/.android-decompile-tools/jd-cmd" | |
# rm final release | |
rm "/tmp/jd-cli.tar.gz" | |
fi | |
if [ -d "$(pwd)/android-decompiled-output" ]; then | |
echo "There is already decompiled output in this directory" | |
exit 1 | |
fi | |
# Make output directories | |
mkdir -p "$(pwd)/android-decompiled-output/dex2jar" | |
mkdir -p "$(pwd)/android-decompiled-output/jd-cli" | |
# Run decompilation tools | |
# Run apktool to grab resources | |
$HOME/.android-decompile-tools/apktool/apktool d $APK -o "$(pwd)/android-decompiled-output/apktool" | |
# Run dex2jar to disassemble smali | |
$HOME/.android-decompile-tools/dex2jar-2.0/d2j-dex2jar.sh -o "$(pwd)/android-decompiled-output/dex2jar/dex2jar-output.jar" $APK | |
# Run jd-cli to decompile disassembled smali | |
$HOME/.android-decompile-tools/jd-cmd/jd-cli -od "$(pwd)/android-decompiled-output/jd-cli" "$(pwd)/android-decompiled-output/dex2jar/dex2jar-output.jar" | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment