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); } }
public void ShouldClaimThatTheDeviceIsJailbrokenByDefault() { using (var gel = new GlobalLock()) { var jbd = new Cryoprison.iOS.JailbreakDetector(gel.Env, simulatorFriendly: false); Assert.True(jbd.IsJailbroken); } }
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); } }
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); } }
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); } }
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); } }
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); } }
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); } }