-
-
Save jordan-wright/a9d4265a84b7da0438664165f8d736c6 to your computer and use it in GitHub Desktop.
Extract Java Sources from APK
This file contains hidden or 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/sh | |
# check that 7z is installed | |
command -v 7z >/dev/null 2>&1 || { echo >&2 "This script requires 7z. Aborting."; exit 1; } | |
jdgui="/opt/jd-cli" | |
dex2jar="/opt/dex2jar-2.0/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 -od $1.src $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