且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在没有 root 访问权限的情况下获取已安装应用的 APK?

更新时间:2022-11-03 12:58:33

无需root权限即可访问/data/app;该目录的权限是 rwxrwx--x.目录的执行权限意味着您可以访问它,但是缺少读取权限意味着您无法获得其内容列表——因此为了访问它,您必须知道您将要访问的文件的名称.Android 的包管理器会告诉您存储的给定包的 apk 的名称.

Accessing /data/app is possible without root permission; the permissions on that directory are rwxrwx--x. Execute permission on a directory means you can access it, however lack of read permission means you cannot obtain a listing of its contents -- so in order to access it you must know the name of the file that you will be accessing. Android's package manager will tell you the name of the stored apk for a given package.

要从命令行执行此操作,请使用 adb shell pm list packages 获取已安装包的列表并找到所需的包.

To do this from the command line, use adb shell pm list packages to get the list of installed packages and find the desired package.

通过包名,我们可以使用adb shell pm path your-package-name获取APK的实际文件名和位置.

With the package name, we can get the actual file name and location of the APK using adb shell pm path your-package-name.

并且知道完整目录,我们最终可以使用 adb pull full/directory/of/the.apk

And knowing the full directory, we can finally pull the adb using adb pull full/directory/of/the.apk

感谢@tarn 指出在 Lollipop 下,apk 路径将是 /data/app/your-package-name-1/base.apk

Credit to @tarn for pointing out that under Lollipop, the apk path will be /data/app/your-package-name-1/base.apk