Detecting rooted/jail broken devices

Hello, is there is a way to detect if my game is running on a rooted device for Android or a jail broken device for iOS?

I’m willing to buy a plugin that detects this if there is any since I’m not Android or iOS developer.

Thanks

1.Go to the assets store(in the menu: window-assets store) and search for something like “Jailbreak detect” or “Root detect”.

2.For rooted phones [this page][1] (url = android - Determine if running on a rooted device - Stack Overflow) will maybe helps you(it is not optimized for Unity so Im not sure). The first answer contains a script that might helps you, if it dont you can take a look at the other answers.

3.For iPhone you can check whether this locations exist:

/Applications/Cydia.app
/private/var/lib/cydia
/private/var/tmp/cydia.log
/System/Library/LaunchDaemons/com.saurik.Cydia.Startup.plist
/usr/libexec/sftp-server
/usr/bin/sshd
/usr/sbin/sshd
/Applications/FakeCarrier.app
/Applications/SBSettings.app
/Applications/WinterBoard.app

Cause Cydia is installed at most of the jailbroken devices, and the other locations are locations from popular apps from the cydia store(or whatever the name is).

A function for this will be:

bool check_jailbroken(){
		string[] paths = new string[10] {
			"/Applications/Cydia.app",
			"/private/var/lib/cydia",
			"/private/var/tmp/cydia.log",
			"/System/Library/LaunchDaemons/com.saurik.Cydia.Startup.plist",
			"/usr/libexec/sftp-server",
			"/usr/bin/sshd",
			"/usr/sbin/sshd",
			"/Applications/FakeCarrier.app",
			"/Applications/SBSettings.app",
			"/Applications/WinterBoard.app",};
		int i;
		bool jailbroken = false;
		for (i = 0; i < paths.Length; i++) {
			if (System.IO.File.Exists(paths*){*
  •  		jailbroken = true;*
    
  •  	}			*
    
  •  }*
    
  •  return jailbroken;*
    
  • }*
    You can call it like this:
    if(check_jailbroken()){
    //If the device is jailbroken the void will return true, so if it is jailbroken, it will execute this code
    Application.Quit;//Quits the application, just an example
    }
    It is not 100% sure that it detects rooted or jailbroken phones and I think that quit the application if the device is jailbroken or rooted is not a good deal, some devices are rooted before you buy them or if you buy an iPhone from anyone it also could be jailbroken without the user knows it. I think the best you can do is encode and decode all your variables so it is more difficult to hack.
    I hope this answer helped you. Success with your app!
    [1]: android - Determine if running on a rooted device - Stack Overflow

You can use Application.sandboxType == SandboxBroken // Application is running in broken sandbox.

public static bool IsJailBroken()
{
try
{
var paths = new
{
“/Applications/Cydia.app”,
“/private/var/lib/cydia”,
“/private/var/tmp/cydia.log”,
“/System/Library/LaunchDaemons/com.saurik.Cydia.Startup.plist”,
“/usr/libexec/sftp-server”,
“/usr/bin/sshd”,
“/usr/sbin/sshd”,
“/Applications/FakeCarrier.app”,
“/Applications/SBSettings.app”,
“/Applications/WinterBoard.app”,
“/Library/MobileSubstrate/MobileSubstrate.dylib”,
“/etc/apt”,
“/bin/hash”,
“/private/var/lib/apt/”
};

                return paths.Any(System.IO.File.Exists);
            }
            catch (Exception e)
            {
                LogManager.Error(LogTags.CaravanNativeTools, "Can not detect system files. Considering not jailed: {0}", e.Message);                
            }

            return false;
        }

You can use asset store package: Jailbreak Checker | Integration | Unity Asset Store