如何检查在Android的root访问权限? [英] How to check root access in android?

查看:204
本文介绍了如何检查在Android的root访问权限?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建检查Android手机是否是植根与否的方法。这样做是如下

I created a method for checking whether the android phone is rooted or not. This is done as follows

public int checkrootcommand(String string) {
    // TODO Auto-generated method stub
    Process exec;
    try {

        exec = Runtime.getRuntime().exec(new String[]{"su","-c"});

        final OutputStreamWriter out = new OutputStreamWriter(exec.getOutputStream());
        out.write("exit");
        out.flush();

        Log.i(SUPER_USER_COMMAND, "su command executed successfully");
        return 0; // returns zero when the command is executed successfully
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }  
    return 1; //returns one when the command execution fails
}

但问题是该方法checkrootcommand()被执行第一它完美,但是当调用相同的方法再次超级用户会话仍在运行。有什么办法一旦执行??的方法来结束超级用户会话

But the problem is that the method checkrootcommand() is executed first it works perfectly, but when the same method called again the superuser session is still running. Is there any way to end the superuser session once the method is executed??

推荐答案

没有可靠的方法在哪里硬件保护已经克服了利用软件漏洞的设备上检测到扎根的条件

目前最好的,你可以检测到特定的工具集的presence或扫描对于不应该在那里的东西,或者是改变的文件 - 但是这需要一个什么样的给定的安装应该像知识,并假定您正在使用,使检查操作系统功能一直没有被修改,以隐藏更改。

At best you can detect the presence of particular toolsets or scan for things that aren't supposed to be there or changes in files that are - but that requires knowledge of what a given installation should look like, and assumes that the OS functionality you are using to make the checks hasn't been modified to hide the changes.

要可靠扫描,您需要确保受信任的code运行在一个较低的水平比不可信code;一个根深蒂固的设备是其中这种保证已经从根本上打破,或者最终用户是可信的比你多的开发者是。

To reliably scan, you need to be sure trusted code runs at a lower level than untrusted code; a rooted device is one where this assurance has been fundamentally broken, or where the end user is trusted more than you the developer are.

这篇关于如何检查在Android的root访问权限?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆