Created
January 16, 2024 01:32
-
-
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
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
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