Esempio n. 1
0
        public void ShouldDetectIfCanWriteToPrivate(string file)
        {
            using (var gel = new GlobalLock())
            {
                var jbd = new Cryoprison.iOS.JailbreakDetector(gel.Env, simulatorFriendly: false);

                gel.Env.System.IO.File.Open = (path, mode, access, share) =>
                {
                    if (path != file)
                    {
                        throw new System.IO.IOException();
                    }

                    var writables = new FileMode[] { FileMode.Append, FileMode.Create, FileMode.CreateNew, FileMode.OpenOrCreate, FileMode.Truncate };
                    if (!writables.Any(x => x == mode))
                    {
                        throw new System.IO.IOException();
                    }

                    if (access != FileAccess.Read)
                    {
                        throw new System.IO.IOException();
                    }

                    return(new MemoryStream());
                };

                Assert.True(jbd.IsJailbroken);
            }
        }
Esempio n. 2
0
        public void ShouldClaimThatTheDeviceIsJailbrokenByDefault()
        {
            using (var gel = new GlobalLock())
            {
                var jbd = new Cryoprison.iOS.JailbreakDetector(gel.Env, simulatorFriendly: false);

                Assert.True(jbd.IsJailbroken);
            }
        }
Esempio n. 3
0
        public void ShouldDetectIfCydiaUrlCanBeOpened(string scheme)
        {
            using (var gel = new GlobalLock())
            {
                var jbd = new Cryoprison.iOS.JailbreakDetector(gel.Env, simulatorFriendly: false);

                UIKit.UIApplication.SharedApplication.MockCanOpenUrl = (url) =>
                {
                    return(url.MockUrl.StartsWith(scheme));
                };

                Assert.True(jbd.IsJailbroken);
            }
        }
Esempio n. 4
0
        public void ShouldDetectIfCydiaStashDirectoryIsPresent(string directory)
        {
            using (var gel = new GlobalLock())
            {
                var jbd = new Cryoprison.iOS.JailbreakDetector(gel.Env, simulatorFriendly: false);

                gel.Env.System.IO.Directory.Exists = (path) =>
                {
                    return(path == directory);
                };

                Assert.True(jbd.IsJailbroken);
            }
        }
Esempio n. 5
0
        public void ShouldDetectIfSysLogIsPresent(string file)
        {
            using (var gel = new GlobalLock())
            {
                var jbd = new Cryoprison.iOS.JailbreakDetector(gel.Env, simulatorFriendly: false);

                gel.Env.System.IO.File.Exists = (path) =>
                {
                    return(path == file);
                };

                Assert.True(jbd.IsJailbroken);
            }
        }
Esempio n. 6
0
        public void ShouldDetectIfAptConfigDirectoryExistsAsFile(string file)
        {
            // Some tools seem to test for this, not sure whether it is needed.
            using (var gel = new GlobalLock())
            {
                var jbd = new Cryoprison.iOS.JailbreakDetector(gel.Env, simulatorFriendly: false);

                gel.Env.System.IO.File.Exists = (path) =>
                {
                    return(path == file);
                };

                Assert.True(jbd.IsJailbroken);
            }
        }
Esempio n. 7
0
        public void ShouldDetectIfImportantDirectoryHasBecomeASymLink(string directory)
        {
            using (var gel = new GlobalLock())
            {
                var jbd = new Cryoprison.iOS.JailbreakDetector(gel.Env, simulatorFriendly: false);

                gel.Env.System.IO.Directory.Exists = (path) =>
                {
                    return(directory == path);
                };

                Foundation.NSFileManager.DefaultManager.MockGetAttributes = GetAttributesReturnsSymLink;

                Assert.True(jbd.IsJailbroken);
            }
        }
Esempio n. 8
0
        public void ShouldNotClaimThatTheDeviceIsJailbrokenIfMobileProvisionIsEmbedded()
        {
            using (var gel = new GlobalLock())
            {
                Foundation.NSBundle.MainBundle.MockPathForResource = (a, b) =>
                {
                    if (a == "embedded" && b == "mobileprovision")
                    {
                        return("found");
                    }
                    return(null);
                };

                var jbd = new Cryoprison.iOS.JailbreakDetector(gel.Env, simulatorFriendly: false);

                Assert.False(jbd.IsJailbroken);
            }
        }