有时候为了安全性,我们可以实现机器自毁,比如,我要实现一个APP,运行之后能够使Android系统损害,无法重新开机,除非重新刷写系统。
第一步破解手机开启root权限。标志是在system/app文件夹下放入一个可以供调用的su命令。
adb push su /system/binadb push SuperUser.apk /system/appadb 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卡也自然被替换掉了,手机还可能被恢复为出厂设置,因此,走网络是比较靠谱的。
- 1楼xxm282828昨天 20:51
- 博主有superuser.apk 吗?