Skip to content

Instantly share code, notes, and snippets.

@vgmoose
Created January 16, 2024 01:32
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 vgmoose/9beb860880460aaeadeb501af5bdffa7 to your computer and use it in GitHub Desktop.
Save vgmoose/9beb860880460aaeadeb501af5bdffa7 to your computer and use it in GitHub Desktop.
Python script to pull all APKs from non-rooted android device, using adb shell commands
import os
list_pkgs_cmd = "adb shell pm list packages"
list_pkgs = os.popen(list_pkgs_cmd).read().splitlines()
list_pkgs = [pkg.split(":")[1] for pkg in list_pkgs]
for pkg in list_pkgs:
path_cmd = "adb shell pm path {}".format(pkg)
path = os.popen(path_cmd).read().splitlines()[0].split(":")[1]
pull_cmd = "adb pull {} {}".format(path, pkg + ".apk")
os.system(pull_cmd)
print("Pulled {} to {}".format(pkg, pkg + ".apk"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment