How does Android SuperUser app detect that an app requests root?

前端 未结 3 1806
隐瞒了意图╮
隐瞒了意图╮ 2021-02-01 23:15

I\'m writing an app that will use su to execute some commands in the linux kernel. I was wondering how SuperUser figures out that the application is asking for root

3条回答
  •  说谎
    说谎 (楼主)
    2021-02-01 23:19

    Actually it's quite simple. Vanilla Android doesn't even have su or superuser. When you root the device you run a shell as root. Then you install the su binary and superuser.apk. After installing you set the shell back to it's normal permissions. All these root-only apps can now call su to ask for root access.

    When su is run it calls superuser.apk with a message asking you whether you want to elevate privileges. The su binary and superuser.apk are protected via Android's normal sandboxing. Note that once you give an app root privileges it's free to do whatever it wants including overwriting su with it's own version.

提交回复
热议问题