Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Extract Java Sources from APK
#!/bin/sh
# check that 7z is installed
command -v 7z >/dev/null 2>&1 || { echo >&2 "This script requires 7z. Aborting."; exit 1; }
jdgui="/path/to/jd-gui"
startmenu="/path/to/DroidBox_4.1.1/startemu.sh"
dex2jar="/path/to/dex2jar-0.0.9.15/d2j-dex2jar.sh"
if [ $# -eq 0 ]
then
echo "Usage: extract.sh <test.apk>"
exit 1
fi
# extracting the apk
echo "apk file: $1"
DIRECTORY=$(dirname ${1})
FILE=$(basename ${1})
echo "Creating directory $FILE.files"
# echo "mkdir $1.files"
mkdir $1.files
echo "Extracting apk to $1.files/"
# echo "7z x $1 -o$1.files/"
7z x $1 -o$1.files/
echo "Finding .dex file in $1.files/"
# echo "$dexfile={find ${1}.files/ -name '*.dex'}"
dexfile=`find ${1}.files/ -name '*.dex'`
echo "Generating $FILE.jar in $1.files/"
# echo "$dex2jar $dexfile -o $1.files/$FILE.jar"
$dex2jar $dexfile -o $1.files/$FILE.jar
echo "Opening jd-gui with .jar file"
# echo "$jdgui $1.files/$FILE.jar"
$jdgui $1.files/$FILE.jar 2> /dev/null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.