获得Android App的"root"权限

ik0*_*024 7 android root android-kernel

我想知道如何从Android应用程序获得root权限?Android市场上有没有应用程序?

我尝试了下面的代码行列出文件但没有发生任何事情

Process process = Runtime.getRuntime().exec(new String[] { "su", "-", "root"});
Run Code Online (Sandbox Code Playgroud)

我试图在我的清单文件中给出TEST_FACTORY权限,但我收到错误"允许系统应用程序"

如何制作我的应用系统应用?

我想要帮助开始使用这些东西(如果可能的话,让应用程序获得root权限)对此非常感谢.提前致谢 :)

Nir*_*ann 6

这里有一个很好的答案 - ANDROID: How to get root access in an Android application?

“据我所知,您只能使用 root 权限运行命令行命令。您可以使用我制作的通用类,它将 root 访问权限包装在您的代码中:http ://muzikant-android.blogspot.com/2011/ 02/how-to-get-root-access-and-execute.html "


Joh*_* H. 5

首先:请注意,您只能使用 su 执行 shell 命令(= 您只能以 root 身份使用 shell 命令,而不能使用 java 代码)。

第二:不确定这是否适用于所有 su 应用程序,但这是su我手机上的帮助消息:

Usage: su [options] [--] [-] [LOGIN] [--] [args...]

Options:  
  --daemon                      start the su daemon agent  
  -c, --command COMMAND         pass COMMAND to the invoked shell  
  -h, --help                    display this help message and exit  
  -, -l, --login                pretend the shell to be a login shell  
  -m, -p,  
  --preserve-environment        do not change environment variables  
  -s, --shell SHELL             use SHELL instead of the default /system/bin/sh  
  -u                            display the multiuser mode and exit  
  -v, --version                 display version number and exit  
  -V                            display version code and exit,  
                                this is used almost exclusively by Superuser.apk  
Run Code Online (Sandbox Code Playgroud)

这意味着:您必须运行su -c something (或su -c something - root,但root无论如何都是默认值)。本质上,这与大多数 Linux 系统上的 su 相同,除了守护进程之外,因为在常规 Linux 系统上没有守护进程处理 su 调用。

如果其他 su 命令的行为不同(这是可能的),则更安全的做法是打开 shell 的流,执行su,评估它的返回代码,然后继续执行其他命令,最后执行exit