Add simple GUI for device ID and security intrusion
The AppSealing library within your App is automatically activated when right after App has launched. If AppSealing library has detected any abnormal environment (such as jailbroken-device, executable has decrypted or debugger has attached) it will close the app after 20 seconds irrespectively of user action, so the app should notify the detection result to user and show some proper message box for user can recognize there’s some invalid environment in his/her device.
Add Security Detection GUI
Section titled “Add Security Detection GUI”To add security threat detection in your Xamarin iOS project, add the following code to your ViewController:
using System;using UIKit;using Foundation;
public override void ViewDidAppear(bool animated){ base.ViewDidAppear(animated);
// Check for security threats var tamper = AppSealingInterface.IsAbnormalEnvironmentDetected(); if (tamper > 0) { var msg = "Abnormal Environment Detected!";
if ((tamper & DetectedFlags.DETECTED_JAILBROKEN) > 0) msg += "\n - Jailbroken"; if ((tamper & DetectedFlags.DETECTED_DRM_DECRYPTED) > 0) msg += "\n - Executable is not encrypted"; if ((tamper & DetectedFlags.DETECTED_DEBUG_ATTACHED) > 0) msg += "\n - App is debugged"; if ((tamper & (DetectedFlags.DETECTED_HASH_INFO_CORRUPTED | DetectedFlags.DETECTED_HASH_MODIFIED)) > 0) msg += "\n - App integrity corrupted"; if ((tamper & (DetectedFlags.DETECTED_CODESIGN_CORRUPTED | DetectedFlags.DETECTED_EXECUTABLE_CORRUPTED)) > 0) msg += "\n - App executable has corrupted"; if ((tamper & DetectedFlags.DETECTED_CERTIFICATE_CHANGED) > 0) msg += "\n - App has re-signed";
var alertController = UIAlertController.Create("AppSealing", msg, UIAlertControllerStyle.Alert); var confirmAction = UIAlertAction.Create("Confirm", UIAlertActionStyle.Default, (action) => {#if !DEBUG Environment.Exit(0);#endif });
alertController.AddAction(confirmAction); PresentViewController(alertController, true, null); }}
Add Device ID Display
Section titled “Add Device ID Display”To display the AppSealing device unique identifier:
public override void ViewDidAppear(bool animated){ base.ViewDidAppear(animated);
var deviceID = AppSealingInterface.GetAppSealingDeviceID(); var alertController = UIAlertController.Create("AppSealing DeviceID", deviceID, UIAlertControllerStyle.Alert); var confirmAction = UIAlertAction.Create("Confirm", UIAlertActionStyle.Default, null);
alertController.AddAction(confirmAction); PresentViewController(alertController, true, null);}
Your app will show appropriate alert dialogs when security threats are detected or when displaying the device ID.