Android get root permission method summary

Source: Internet
Author: User
Document directory
  • 1. Use superoneclick and other software for root cracking
  • 2. The application obtains the root permission code.
  • Iii. Supplement

Address: http://www.metsky.com/archives/532.html

 

 

This article introduces the Android system to obtain the TF/SD card root permission method, the application to obtain the root permission has a premise is that the device has been cracked (root, such as the use of superoneclick software, reference address: http://forum.xda-developers.com/showthread.php? T = 803682). Otherwise, executing the su command is ineffective. The demo program uses the CHMOD method to modify the access permission of a certain device (TF card partition, for example, to access the TF card by physical sector or to delete some important files, you must have the root permission on the Android system.

1. Use superoneclick and other software for root cracking

: Http://forum.xda-developers.com/showthread.php? T = 803682

Usage reference: http://hi.baidu.com/cy594/blog/item/190e8794021c150bd31b7041.html

The root cracking software uses the Android system vulnerability to escalate permissions. the root account logon is enabled, and the following su command is not executed by the Android system (execution failed ). If you know little about root results and potential risks, proceed with caution.

2. The application obtains the root permission code.

In the example, obtain the root user and modify the mmcblk0 partition permission to 777:

Package COM. android. myApp. utility; import Java. io. dataoutputstream; import android. app. activity; public class mytestpri extends activity {public void oncreate (bundle savedinstancestate) {super. oncreate (savedinstancestate); // * Create a textview and set its content. // * The text is retrieved by calling a native // * function. setcontentview (R. layout. main); string apkroot = "chmod 777/dev/block/mmcblk0 ";/ /SD card partition path, or mmcblk1 may be determined with the system version. Use getpackagecodepath (); rootcmd (apkroot);} public Boolean rootcmd (string cmd) as the program path) {Process = NULL; dataoutputstream OS = NULL; try {process = runtime.getruntime(.exe C ("Su"); OS = new dataoutputstream (process. getoutputstream (); OS. writebytes (CMD + "\ n"); OS. writebytes ("Exit \ n"); OS. flush (); process. waitfor ();} catch (exception e) {return false;} finally {T Ry {If (OS! = NULL) {OS. Close () ;}process. Destroy () ;}catch (exception e) {}} return true ;}}

When the above program runs for the first time, a dialog box similar to "XXX application wants to obtain root permissions" will pop up. In this case, you only need to confirm the permission. Next time you execute the command again, Android automatically authorizes the program to perform root Elevation of Privilege.

After the operation, you can see that the permission of the device has been changed to 777. Note: If you only want to read and write the SD card by sector, it is enough to change it to 606, or try a lower permission.

In addition, for the TF/SD card mount point issue, it seems that some versions will be mounted to mmcblk0, and some will be mounted to mmcblk1. You need to determine the details, if you have studied it in depth, leave a message to add it.

Iii. Supplement

The above method first requires superoneclick to perform root cracking, which is difficult for many non-developers and easy to ignore potential risks. Therefore, we can solve this problem through better methods, the following method is a good example:

Http://my.unix-center.net /~ Simon_fu /? P = 951 (the Android Application obtains the root permission)

This article improves the root permission by modifying the android startup Service (init. Rc). However, you must be a developer who knows how to modify and compile the android source code. This function has not been tested yet. This article seems to have only obtained the system permission, but the root permission is different from the system permission, for example, directly reading and writing the dev device class (for example, reading and writing the SD card sector above) only the system permission is required.

Tian Yuan has just been in touch with this but has not been tested yet. Try again later. You are welcome to enlighten me with experienced Android experts.

References:

Http://www.cnblogs.com/ycmoon/archive/2011/05/11/2042999.html (Android Application to obtain the root permission, this article mainly refer to the source)

Related Article

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.