Snippets

Mário Almeida Dump methods and classes from apk

Created by Mário Almeida last modified
APP=$1
FOLDER=$(basename $APP .apk)
PROCS=4 #Greatly speeds this script

echo "Decompiling $APP..."
apktool -f -r d $APP # -r reduces time almost by half by not unpacking the resources.

echo "Entering $FOLDER..."
cd $FOLDER

echo "Dumping classes..."
#Classes
find smali/ -name "*.smali" | cut -c 7- | awk -F '.' '{print $1}' | tr '/' '.' > ../classes.txt

echo "Dumping methods..."
#Methods (use tr '/' '.' if u prefer packages with dots)
find smali/ -name "*.smali" | xargs -I{} -n 1 -P $PROCS bash -c "cat '{}' | grep '\.method' | xargs -I[] echo '{} []'" | awk '{print substr($1, 7, length($1)-7-5)"."$NF}'  > ../methods.txt

cd ..

METHODS=$(cat methods.txt | wc -l)
CLASSES=$(cat classes.txt | wc -l)

echo "Number of classes: $CLASSES"
echo "Number of methods: $METHODS"

rm -rf $FOLDER

echo "Done!"

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.