private void CheckUsingServerManagedPolicy() { //("MainActivity.CheckUsingServerManagedPolicy"); byte[] salt = new byte[15] { 46, 65, 30, 128, 103, 57, 74, 64, 51, 88, 95, 45, 77, 117, 36 }; string packageName = this.PackageName; string @string = Settings.Secure.GetString(this.ContentResolver, "android_id"); AESObfuscator obfuscator = new AESObfuscator(salt, packageName, @string); ServerManagedPolicy policy = new ServerManagedPolicy(this, obfuscator); this._licenseChecker = new LicenseChecker(this, policy, "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAry4fecehDpCohQk4XhiIZX9ylIGUThWZxfN9qwvQyTh53hvnpQl/lCrjfflKoPz6gz5jJn6JI1PTnoBy/iXVx1+kbO99qBgJE2V8PS5pq+Usbeqqmqqzx4lEzhiYQ2um92v4qkldNYZFwbTODYPIMbSbaLm7eK9ZyemaRbg9ssAl4QYs0EVxzDK1DjuXilRk28WxiK3lNJTz4cT38bfs4q6Zvuk1vWUvnMqcxiugox6c/9j4zZS5C4+k+WY6mHjUMuwssjCY3G+aImWDSwnU3w9G41q8EoPvJ1049PIi7GJXErusTYZITmqfonyejmSFLPt8LHtux9AmJgFSrC3UhwIDAQAB"); this._licenseChecker.CheckAccess(this); }
private static AESObfuscator getObfuscator(Context context, byte[] salt) { if (_obfuscator == null) { string installationId = Installation.id(context); string deviceId = Settings.Secure.GetString(context.ContentResolver, Settings.Secure.AndroidId); string password = installationId + deviceId + context.PackageName; _obfuscator = new AESObfuscator(salt, password); } return(_obfuscator); }
public static string unobfuscate(Context context, byte[] salt, string obfuscated) { AESObfuscator obfuscator = getObfuscator(context, salt); try { return(obfuscator.unobfuscate(obfuscated)); } catch (Exception e) { Log.Warn(TAG, "Invalid obfuscated data or key"); } return(null); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); RequestWindowFeature(WindowFeatures.IndeterminateProgress); SetContentView(Resource.Layout.Main); // Try to use more data here. ANDROID_ID is a single point of attack. string deviceId = Settings.Secure.GetString(ContentResolver, Settings.Secure.AndroidId); // Construct the LicenseChecker with a policy. var obfuscator = new AESObfuscator(Salt, PackageName, deviceId); var policy = new ServerManagedPolicy(this, obfuscator); checker = new LicenseChecker(this, policy, Base64PublicKey); checkLicenseButton = FindViewById <Button>(Resource.Id.checkButton); checkLicenseButton.Click += delegate { DoCheck(); }; DoCheck(); }
private void CheckLVL() { var salt = new byte[] { 28, 65, 30, 128, 103, 87, 74, 64, 51, 88, 95, 45, 91, 121, 36 }; // create a app-unique identifer to prevent other apps from decrypting the responses var deviceInfoHelper = DependencyService.Resolve <IDeviceInfoHelper>(); deviceInfoHelper.AppPackageName = this.PackageName; deviceInfoHelper.DeviceId = Android.Provider.Settings.Secure.GetString(ContentResolver, Android.Provider.Settings.Secure.AndroidId); deviceInfoHelper.AppVersionName = this.ApplicationContext.PackageManager.GetPackageInfo(PackageName, 0).VersionName; // create the obfuscator that will read and write the saved responses, // passing the salt, the package name and the device identifier var obfuscator = new AESObfuscator(salt, deviceInfoHelper.AppPackageName, deviceInfoHelper.DeviceId); // create the policy, passing a Context and the obfuscator var policy = new ServerManagedPolicy(this, obfuscator); // create the checker var checker = new LicenseChecker(this, policy, ApiKey); // start the actual check, passing the callback checker.CheckAccess(this); }
public static string obfuscate(Context context, byte[] salt, string original) { AESObfuscator obfuscator = getObfuscator(context, salt); return(obfuscator.obfuscate(original)); }