Skip to content

Instantly share code, notes, and snippets.

@mattak
Created April 8, 2013 14:42
Show Gist options
  • Save mattak/5337300 to your computer and use it in GitHub Desktop.
Save mattak/5337300 to your computer and use it in GitHub Desktop.
dump android apk file. it requires "dex2jar", "apktool", "jad".
#!/bin/sh
if [ $# -lt 1 ]; then
echo "usage: [apk file]"
exit 0
fi
APKFILE=$1
APKTOOL=apktool
D2J=d2j-dex2jar.sh
JAD=jad
OUTPUTDIR=`echo $APKFILE | sed 's/\.apk//g'`
TMPDIR=tmp
#
# 1. apk -> AndroidManifest.xml smali res
#
echo $APKTOOL d $APKFILE $OUTPUTDIR
$APKTOOL d $APKFILE $OUTPUTDIR
#
# 2. apk -> zip
#
unzip $APKFILE -d $TMPDIR
#
# 3. classes.jar -> classes/
#
mkdir $TMPDIR/classes
$D2J $TMPDIR/classes.dex --output $TMPDIR/classes/classes.jar
cd $TMPDIR/classes
jar xvf classes.jar
#
# 4. classes/ -> src/
#
$JAD -s java -d ../src -r ./**/*.class
cd -
mv $TMPDIR/src $OUTPUTDIR/
#
# 5. remove tmp dir
#
rm -rf $TMPDIR
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment