Beispiel #1
0
        protected override void OnCreate(Bundle bundle)
        {
            TabLayoutResource = Resource.Layout.Tabbar;
            ToolbarResource   = Resource.Layout.Toolbar;

            base.OnCreate(bundle);

            var env = new Cryoprison.Ex.Env();

            env.Reporter.OnJailbreakReported = (id) => {
                Console.WriteLine($"Jailbreak: {id ?? "<null>"}");
            };

            env.Reporter.OnExceptionReported = (message, exception) => {
                Console.WriteLine($"Jailbreak Error: {message}");
                Console.WriteLine(exception.ToString());
            };

            this.jailbreakDetector = new Cryoprison.Android.JailbreakDetector(env);

            SampleApp.App.IsJailBroken = () =>
            {
                return(this.jailbreakDetector.IsJailbroken);
            };

            SampleApp.App.JailBreaks = () =>
            {
                return(this.jailbreakDetector.Violations);
            };

            global::Xamarin.Forms.Forms.Init(this, bundle);
            LoadApplication(new App());
        }
Beispiel #2
0
        //
        // This method is invoked when the application has loaded and is ready to run. In this
        // method you should instantiate the window, load the UI into it and then make the window
        // visible.
        //
        // You have 17 seconds to return from this method, or iOS will terminate your application.
        //
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            var env = new Cryoprison.Ex.Env();

            env.Reporter.OnJailbreakReported = (id) => {
                Console.WriteLine($"Jailbreak: {id ?? "<null>"}");
            };

            env.Reporter.OnExceptionReported = (message, exception) => {
                Console.WriteLine($"Jailbreak Error: {message}");
                Console.WriteLine(exception.ToString());
            };

            this.jailbreakDetector = new Cryoprison.iOS.JailbreakDetector(env);

            SampleApp.App.IsJailBroken = () =>
            {
                return(this.jailbreakDetector.IsJailbroken);
            };

            SampleApp.App.JailBreaks = () =>
            {
                return(this.jailbreakDetector.Violations);
            };

            global::Xamarin.Forms.Forms.Init();
            LoadApplication(new App());

            return(base.FinishedLaunching(app, options));
        }
Beispiel #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="T:Cryoprison.Android.JailbreakDetector"/> class.
        /// By default, the jailbreak detector will be 'simulator friendly'
        /// when built in debug mode, and hostile towards the simulator in release
        /// builds.  This is intended to aid debugging, since the simulator will
        /// appear to be jailbroken due to installed debugging tools.
        /// </summary>
        /// <param name="simulatorFriendly">Simulator friendly.</param>
        public JailbreakDetector(Cryoprison.Ex.Env env, bool?simulatorFriendly = null)
            : base(env)
        {
            if (simulatorFriendly == null)
            {
#if DEBUG
                simulatorFriendly = true;
#else
                simulatorFriendly = false;
#endif
            }

            if (!simulatorFriendly.Value)
            {
                this.AddInspectors(PropsShouldNotBeSetUnlessDebugging.GetInspectors <ShouldNotHavePropValues>());
            }

            this.AddInspectors(ExecutablesShouldNotBeFound.GetInspectors <ShouldNotBeAbleToLocateFile>());
            this.AddInspectors(BuildTagsShouldNotBeFound.GetInspectors <ShouldNotHaveSpecificBuildTags>());
            this.AddInspectors(RootAppsShouldNotBeInstalled.GetInspectors <ShouldNotHavePackageInstalled>());
            this.AddInspectors(DangerousAppsShouldNotBeInstalled.GetInspectors <ShouldNotHavePackageInstalled>());
            this.AddInspectors(RootCloakingAppsShouldNotBeInstalled.GetInspectors <ShouldNotHavePackageInstalled>());
            this.AddInspectors(DangerousExecutablesShouldNotBeInstalled.GetInspectors <FileNotPresent>());
            this.AddInspectors(PathsShouldNotBeWritable.GetInspectors <FileNotDestructivelyWritable>());
            this.AddInspectors(PropsShouldNotBeSet.GetInspectors <ShouldNotHavePropValues>());
        }
Beispiel #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="T:Cryoprison.iOS.JailbreakDetector"/> class.
        /// By default, the jailbreak detector will be 'simulator friendly'
        /// when built in debug mode, and hostile towards the simulator in release
        /// builds.  This is intended to aid debugging, since the simulator will
        /// appear to be jailbroken due to installed debugging tools.
        /// </summary>
        /// <param name="simulatorFriendly">Simulator friendly.</param>
        public JailbreakDetector(Cryoprison.Ex.Env env, bool?simulatorFriendly = null)
            : base(env)
        {
            if (simulatorFriendly == null)
            {
#if DEBUG
                simulatorFriendly = true;
#else
                simulatorFriendly = false;
#endif
            }

            // TODO: There is some interesting obfuscated logic here
            //   that would be worth investigating further.  Might be some
            //   cool tricks there.
            //   https://github.com/masbog/isJB/blob/master/JailbreakDetection/JBDetect.m
            //
            // later:  add forking, info plist and exe modification detection
            //
            // maybe: obfuscate self to hide from sneaky jailbreaks.

            if (!simulatorFriendly.Value)
            {
                this.AddInspectors(new[] { new ShouldBeMobileProvisioned() });
            }

            this.AddInspectors(PathsShouldNotBeSymbolicLinks.GetInspectors <Cryoprison.iOS.PlatformSpecific.PathNotSymbolicLink>());

            this.AddInspectors(FilesShouldNotBePresent.GetInspectors <FileNotPresent>());

            this.AddInspectors(FilesShouldNotBeAccessible.GetInspectors <FileNotAccessible>());

            if (!simulatorFriendly.Value)
            {
                this.AddInspectors(DeveloperFilesShouldNotBePresent.GetInspectors <FileNotPresent>());

                this.AddInspectors(DeveloperFilesShouldNotBeAccessible.GetInspectors <FileNotAccessible>());
            }

            this.AddInspectors(DirectoriesShouldNotBePresent.GetInspectors <DirectoryNotPresent>());

            this.AddInspectors(FilesShouldNotBeDestructivelyWritable.GetInspectors <FileNotDestructivelyWritable>());

            this.AddInspectors(UrlsShouldNotBeOpenable.GetInspectors <Cryoprison.iOS.PlatformSpecific.UrlNotOpenable>());
        }
Beispiel #5
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            Cryoprison.Ex.Env env = new Cryoprison.Ex.Env();
            Cryoprison.Android.JailbreakDetector jbDetect = new Cryoprison.Android.JailbreakDetector(env, true);
            var isJailbroken = jbDetect.IsJailbroken;

            if (!isJailbroken)
            {
                TabLayoutResource = Resource.Layout.Tabbar;
                ToolbarResource   = Resource.Layout.Toolbar;
                base.OnCreate(savedInstanceState);
                Xamarin.Essentials.Platform.Init(this, savedInstanceState);
                global::Xamarin.Forms.Forms.Init(this, savedInstanceState);
                LoadApplication(new App());
            }
            else
            {
                var activity = (Activity)Android.App.Application.Context;
                activity.FinishAffinity();
            }
        }