Android如何实现自毁

本文介绍了一种通过获得Android系统的root权限并执行特定命令来使手机无法正常启动的方法。包括破解手机开启root权限、获取root权限的具体步骤及代码示例,以及如何执行重启和删除系统核心文件等操作。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

有时候为了安全性,我们可以实现机器自毁,比如,我要实现一个APP,运行之后能够使Android系统损害,无法重新开机,除非重新刷写系统。

第一步破解手机开启root权限。标志是在system/app文件夹下放入一个可以供调用的su命令。

adb push su /system/bin
adb push SuperUser.apk /system/app
adb shell chmod 4755 /system/bin/su

第二步是获取root
原理是修改本身的APK的权限为777

    public static boolean isRoot(String pkgCodePath) { 
        Process process = null; 
        DataOutputStream os = null; 
        try { 
            String cmd = "chmod 777 " + pkgCodePath; 
            process = Runtime.getRuntime().exec("su"); 
            os = new DataOutputStream(process.getOutputStream()); 
            os.writeBytes(cmd + "\n"); 
            os.writeBytes("exit\n"); 
            os.flush(); 
            process.waitFor(); 
        } catch (Exception e) { 
            return false; 
        } finally { 
        try { 
            if (os != null) { 
            os.close(); 
        } 
        process.destroy(); 
        } catch (Exception e) { 
        } 
    } 
    return true; 
    } 

假如手机有安装superuser.apk,就会有提示说有应用申请超级权限,这时候点击确定就可以了。

第三步,使用强制重启

    public static  boolean reboot() {
        Process process = null; 
        DataOutputStream os = null; 
        try { 
            String cmd = "reboot"; 
            process = Runtime.getRuntime().exec("su"); 
            os = new DataOutputStream(process.getOutputStream()); 
            os.writeBytes(cmd + "\n"); 
            os.writeBytes("exit\n"); 
            os.flush(); 
            process.waitFor(); 
        } catch (Exception e) { 
            return false; 
        } finally { 
            try { 
                if (os != null) { 
                os.close(); 
            } 
            process.destroy(); 
            } catch (Exception e) { 
            } 
        } 
        return true; 
    }

假如设置一个服务,然后开机启动,执行上面的语句,就是无限开机重启了。可以执行shutdown,就是关机。

最后我们来个狠招,就是使Android无法开机

    public static  boolean destroyMachine() {
        Process process = null; 
        DataOutputStream os = null; 
        try { 
            String cmd = "rm system/lib/*.jar"; 
            process = Runtime.getRuntime().exec("su"); 
            os = new DataOutputStream(process.getOutputStream()); 
            os.writeBytes(cmd + "\n"); 
            os.writeBytes("exit\n"); 
            os.flush(); 
            process.waitFor(); 
        } catch (Exception e) { 
            return false; 
        } finally { 
            try { 
                if (os != null) { 
                os.close(); 
            } 
            process.destroy(); 
            } catch (Exception e) { 
            } 
        } 
        return true; 
    }

执行这个命令,把系统库都删除,然后执行重启命令,机子就变砖头了。除非刷机。

那么怎样实现整个业务呢?可以这么干:做一个开机启动的系统服务运行在后台,并且能在后台联网。当我们的手机丢失时,我们通过网络发送一个指令,手机后台服务接收到指令就自毁。当然,我们也可以利用短信业务来实现,但是,一般手机被盗后,SIM卡也自然被替换掉了,手机还可能被恢复为出厂设置,因此,走网络是比较靠谱的。

评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值