Android kernel is Linux, so Android get root actually and Linux get root permissions is a thing. You want to get root permissions under Linux is the execution of Sudo or Su, then the system will prompt you to enter the root user's password, the password is correct to get root permissions.
Android itself does not want you to get root access, most of the phone factory when there is no SU this program. So if you want to gain root access to Android, the first step is to copy the compiled Su file to the/system/bin or/system/xbin/directory of your Android phone. Let's say you can put Su under the XBin, then you can enter SU on the Android phone's adb shell or the serial port. After the Linux su to enter the password can root, but the SU in the Android and the SU in Linux is not the same, the SU in Android is not by verifying the password, but to see what your original permissions. This means that if you are root, you can switch to another user via Su, such as Shell,wifi,audio or something. But if you are a user other than root, you can not switch back to root, you will be prompted to permission denied. Also said that using root to run Su is useful, but I do not have root at this time what to do? This involves a different problem.
Generally we enter ls-l under the console of Linux to list all the files ' permissions. For example:-rwxr-xr-x, people who have used Linux know that r means that the file is readable, W is writable, X is executable,-it means no such permission. The first rwx represents the permissions of the owner of the file, the second rwx represents the rights of the same group as the owner, and the third rwx represents the permissions of the other user on the file. But the following file is quite special:
RWS, its EXECUTE permission flag bit is a s,s represents when any user executes the file with the permission of the file owner, the Linux system, the current user executes the program, the program process's valid user ID (effective UID) is the current user, but A program with the S (set UID) permission, whose process's valid user ID is the owner of the program . In other words, a program with set UID permissions, after running, is equivalent to the owner running the program, and if the owner is root, that process also has root privileges. The simple point is that no matter who executes the file, he executes it as root. It also means that even if I am not root, it is possible to execute the program as root.
Similarly, we can put an owner is the root of the SU program permission flag location into-rwsr-xr-x, then no matter who executes it, is executed as root, Su can execute smoothly, get root permission. Therefore, the normal authorization of the SU, its owner must be root, otherwise it will not be properly authorized.
The problem is clear, you need to copy an owner-root su to the Android phone, and the SU's permission flag position to-rwsr-xr-x. If you can get this thing done, you'll be rooting for a cell phone.
Look at the following code:
Mount -o remount,rw/cat /sdcard/su >/system/xbin/suchown root.root/system/xbin/suchmod6755 /system/xbin/su #把su置成-rwsr-xr- Mount -o remount,ro/system #出于安全考虑, remount back to read only after the event
In the absence of root privileges, we can set the S permission through chmod, but we cannot use Chown to modify the owner of Su to root (prompting unable to chown su:operation not permitted). In other words, you can only execute the middle two lines of code if you have root privileges, so you can only set the SU owner to be root if you have cracked the root permission to have the normal use of SU. But these two lines of code are for you to get root permission, this is a logical closed loop, then how to break this logic closed loop it?
One way is to find a process that has its own root permission to start my two lines of code, then my two lines of code start is the root permission, it can be executed smoothly. But the process that already has the root authority is loaded on the phone from the factory, the code is dead, you can't control it to execute your own code AH.
We can use Zergrush to crack root privileges (see https://github.com/revolutionary/zergRush/blob/master/for specific code) ZERGRUSH.C), and then start the adbd with root privileges, the computer end with the ADB login directly after the root authority, and then set the SU permissions and owners, re-mount the system to write, and then copy Su to/system/xbin/ and install SUPERSU, restart your phone.
We can also install Supersu, crack root permissions, set the SU permissions and owner, restart the phone, execute Su, re-mount the system, copy su itself to/system/xbin. Re-mount the system and copy Su to xbin just to make it easier for the application to invoke Su.
Reference: http://www.zhihu.com/question/21074979
Android Power-up principle