Skip to content

Instantly share code, notes, and snippets.

@kynex7510
Created June 25, 2022 08:09
Show Gist options
  • Save kynex7510/3c699931c15c60c25fe1423e1ec5afe2 to your computer and use it in GitHub Desktop.
Save kynex7510/3c699931c15c60c25fe1423e1ec5afe2 to your computer and use it in GitHub Desktop.
Find android app paths
import subprocess
def get_encoded_paths():
cmd = ['adb', 'shell', 'su', '-c', '"ls /data/app"']
pipe = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
stdout, _ = pipe.communicate()
encoded_paths = stdout.decode().split('\n')
return encoded_paths
def get_pkg_path(path: str):
cmd = ['adb', 'shell', 'su', '-c', f'"ls /data/app/{path}"']
pipe = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
stdout, _ = pipe.communicate()
pkg_path = stdout.decode().split('\n')[0]
return pkg_path
def get_pkg_name(pkg_path: str):
return pkg_path.split('-')[0]
encoded_paths = get_encoded_paths()
for encoded_path in encoded_paths:
pkg_path = get_pkg_path(encoded_path)
pkg_name = get_pkg_name(pkg_path)
print(f'{pkg_name} -> /data/app/{encoded_path}/{pkg_path}')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment