How Android achieves self-destruct

Source: Internet
Author: User

Sometimes for security, we can implement machine self-destruct, for example, I want to implement an app, after running can make Android system damage, unable to reboot, unless the system is re-written.

The first step is to hack the phone to enable root access. The flags are placed in the System/app folder into a single SU command that can be called.

push su /systempush SuperUser.apk /systemchmod4755 /system/bin/su

The second step is to get root
The principle is to modify the permissions of the APK itself to 777

public static Boolean isRoot (String pkgcodepath) {ProcessProcess=NULL; DataOutputStream OS =NULL;Try{String cmd ="chmod 777"+ Pkgcodepath;Process= Runtime.getruntime (). EXEC ("Su"); OS =NewDataOutputStream (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; }

If the mobile phone has installed superuser.apk, there will be a hint that there is an application to apply for super permissions, then click OK.

Step three, using a forced restart

public static Boolean reboot () {ProcessProcess=NULL; DataOutputStream OS =NULL;Try{String cmd ="reboot";Process= Runtime.getruntime (). EXEC ("Su"); OS =NewDataOutputStream (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; }

If you set up a service, then boot up, execute the above statement, is the infinite power-on restart. Can execute shutdown, is shutdown.

Finally, we have a tough trick, is to make Android unable to boot

public static Boolean Destroymachine () {ProcessProcess=NULL; DataOutputStream OS =NULL;Try{String cmd ="rm System/lib/*.jar";Process= Runtime.getruntime (). EXEC ("Su"); OS =NewDataOutputStream (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; }

Execute this command, delete the system library, and then execute the restart command, the machine becomes a brick. Unless the machine is brushed.

So how to achieve the entire business? Can do this: do a boot-start system service running in the background, and can be connected in the background. When our phone is lost, we send a command through the network, the phone backend service received instructions to self-destruct. Of course, we can also use the SMS business to achieve, but, the general mobile phone is stolen, SIM card is also naturally replaced, the phone may also be restored to the factory settings, so the network is more reliable.

How Android achieves self-destruct

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.