Skip to content

Instantly share code, notes, and snippets.

@flo-genymobile
Created December 6, 2015 19:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save flo-genymobile/e1b10b032c650bebf8ae to your computer and use it in GitHub Desktop.
Save flo-genymobile/e1b10b032c650bebf8ae to your computer and use it in GitHub Desktop.
Shell script to dump current running apk to local directory
#!/bin/sh
# Simle shell script to dump the current running apk
# This require root adb access to the device
# Useful commands
# adb shell dumpsys activity recents
# adb shell dumpsys activity activities
# adb shell pm list package -f
dumpCurrentRunningApk() {
RUNNINGPACKAGE=$(adb shell dumpsys activity activities|grep realActivity -m 1|awk -F= '{print $2}'|awk -F/ '{print $1}')
echo 'current running package is' $RUNNINGPACKAGE
APKPATH=$(adb shell pm list package -f|grep $RUNNINGPACKAGE|awk -F: '{print $2}'|awk -F= '{print $1}')
echo 'apk path is' $APKPATH
adb pull $APKPATH .
}
echo 'Pull current running apk to local directory'
dumpCurrentRunningApk
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment