0

I am trying to give root access to my app on Jailbroken iPhone 9.3.3

I have followed the same steps as mentioned here - Gaining root permissions on iOS for NSFileManager (Jailbreak)

However the app does not gets root access. It looks like, the setuid(0) fails. I am using setuid(0) and setgid(0) in main function.

int main(int argc, char *argv[]) {
   if(!(setuid(0) == 0 && setgid(0) == 0)) {
     exit(EXIT_FAILURE);
   }

   return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
}

The app exits in the above condition.

Any help will be greatly appreciated.

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
Michael
  • 11
  • 3

1 Answers1

0

setgid(0) is not necessary

In iOS you can't run apps as root directly you have to run them through a shell script.

Todo that:

  1. Rename the app binary, for example if the binary named App rename it to _App
  2. Create a text file named App "the name of the original binary name"
  3. Inside the new created text file paste

#!/bin/bash
dir=$(dirname "$0")
exec "${dir}"/_App "$@"
Karim H
  • 1,543
  • 10
  • 24