From 0bbac12ce863299ef05aa23c057d4d151fa8ca4d Mon Sep 17 00:00:00 2001 From: Andrea Cioccarelli Date: Thu, 14 Mar 2019 23:02:04 +0100 Subject: [PATCH] Added regexp matching, internal storing mechanism update, refactoring, switched to md5 hash algorithm, UI test changes, better support for Lucky Patcher --- README.md | 4 +- app/build.gradle | 4 +- .../DetectionActivity.java | 30 +++- .../{activity_secondary.xml => activity.xml} | 0 library/build.gradle | 6 +- .../billingprotector/BillingProtector.kt | 25 ++-- .../billingprotector/assets/definitions.kt | 140 ++++++++++++++++++ .../billingprotector/crypt/HashGeneratior.kt | 23 +++ .../billingprotector/data/AppDefinition.kt | 12 ++ .../billingprotector/data/DetectionCause.kt | 7 + .../billingprotector/data/PirateApp.kt | 43 ++---- .../data/SelectionCriteria.kt | 3 +- .../extensions/ListExtensions.kt | 11 +- .../extensions/StringExtensions.kt | 5 +- .../utils/AssemblerFunctions.kt | 41 +++++ .../billingprotector/utils/RootUtils.kt | 5 +- 16 files changed, 297 insertions(+), 62 deletions(-) rename app/src/main/res/layout/{activity_secondary.xml => activity.xml} (100%) create mode 100644 library/src/main/java/com/andreacioccarelli/billingprotector/assets/definitions.kt create mode 100644 library/src/main/java/com/andreacioccarelli/billingprotector/crypt/HashGeneratior.kt create mode 100644 library/src/main/java/com/andreacioccarelli/billingprotector/data/AppDefinition.kt create mode 100644 library/src/main/java/com/andreacioccarelli/billingprotector/data/DetectionCause.kt create mode 100644 library/src/main/java/com/andreacioccarelli/billingprotector/utils/AssemblerFunctions.kt diff --git a/README.md b/README.md index 917307b..f87b1b7 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ Remember that a skilled hacker will always find a way to crack your code. This l - At the end of December 2018, Lucky Patcher 8.0.0 was released, along with the possibility to randomize package name and make the app invisible from Google Play Protect and other defense systems. The 5th of January, BillingProtector 1.1.0 update introduces support for custom package parameter matching and comes along with the ability of detecting every masked lucky patcher installation - Lucky Patcher (12 March 2018) had a nasty trick which allowed them to show their label normally, [but instread with different charset](https://twitter.com/ACioccarelli/status/1105249064147472385), avoiding normal detction. -BillingProtector 1.1.1 detects that version, the Lucky Patcher emulation server, Installer and the Proxy package to bypass app purchase logic. +BillingProtector 1.3.0 detects that version, the Lucky Patcher emulation server, Installer and the Proxy to bypass app purchase mechanism. # Setup @@ -35,7 +35,7 @@ allprojects { And the dependency to your module build.gradle file: ```gradle dependencies { - implementation 'com.github.AndreaCioccarelli:BillingProtector:1.2.0' + implementation 'com.github.AndreaCioccarelli:BillingProtector:1.3.0' } ``` diff --git a/app/build.gradle b/app/build.gradle index 8b2c459..e6abefe 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -8,8 +8,8 @@ android { applicationId "com.andreacioccarelli.billingprotectorsample" minSdkVersion 14 targetSdkVersion 28 - versionCode 3 - versionName "1.0.2" + versionCode 7 + versionName "1.3.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { diff --git a/app/src/main/java/com/andreacioccarelli/billingprotectorsample/DetectionActivity.java b/app/src/main/java/com/andreacioccarelli/billingprotectorsample/DetectionActivity.java index 0c04036..bfeb641 100644 --- a/app/src/main/java/com/andreacioccarelli/billingprotectorsample/DetectionActivity.java +++ b/app/src/main/java/com/andreacioccarelli/billingprotectorsample/DetectionActivity.java @@ -7,9 +7,12 @@ import android.support.design.widget.FloatingActionButton; import android.view.View; import android.widget.TextView; +import android.widget.Toast; import com.andreacioccarelli.billingprotector.BillingProtector; +import java.util.concurrent.TimeUnit; + public class DetectionActivity extends Activity { BillingProtector bp; @@ -18,10 +21,10 @@ public class DetectionActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - setContentView(R.layout.activity_secondary); + setContentView(R.layout.activity); bp = new BillingProtector(this); - updateData(); + runRefresh(); FloatingActionButton fab = findViewById(R.id.fab); fab.setOnClickListener(new View.OnClickListener() { @@ -30,11 +33,32 @@ public void onClick(View v) { Vibrator vib = (Vibrator) getSystemService(VIBRATOR_SERVICE); vib.vibrate(100); - updateData(); + runRefresh(); } }); } + void runRefresh() { + new Thread(new Runnable() { + @Override + public void run() { + long mills = System.currentTimeMillis(); + updateData(); + + long millsAfter = System.currentTimeMillis(); + long diff = millsAfter - mills; + final long seconds = TimeUnit.MILLISECONDS.toSeconds(diff); + + runOnUiThread(new Runnable() { + @Override + public void run() { + Toast.makeText(DetectionActivity.this, "Re-computed. Time: " + seconds + "s", Toast.LENGTH_SHORT).show(); + } + }); + } + }).run(); + } + @SuppressLint("SetTextI18n") void updateData() { final TextView mxp = findViewById(R.id.mxp); diff --git a/app/src/main/res/layout/activity_secondary.xml b/app/src/main/res/layout/activity.xml similarity index 100% rename from app/src/main/res/layout/activity_secondary.xml rename to app/src/main/res/layout/activity.xml diff --git a/library/build.gradle b/library/build.gradle index a26735d..debdefa 100644 --- a/library/build.gradle +++ b/library/build.gradle @@ -10,14 +10,14 @@ android { defaultConfig { minSdkVersion 14 targetSdkVersion 28 - versionCode 6 - versionName "1.2.0" + versionCode 7 + versionName "1.3.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { release { - minifyEnabled false + minifyEnabled true proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } diff --git a/library/src/main/java/com/andreacioccarelli/billingprotector/BillingProtector.kt b/library/src/main/java/com/andreacioccarelli/billingprotector/BillingProtector.kt index 76b10cf..4f1f6dc 100644 --- a/library/src/main/java/com/andreacioccarelli/billingprotector/BillingProtector.kt +++ b/library/src/main/java/com/andreacioccarelli/billingprotector/BillingProtector.kt @@ -4,17 +4,19 @@ package com.andreacioccarelli.billingprotector import android.content.Context import android.content.pm.PackageManager +import com.andreacioccarelli.billingprotector.data.DetectionCause import com.andreacioccarelli.billingprotector.data.PirateApp import com.andreacioccarelli.billingprotector.data.SelectionCriteria -import com.andreacioccarelli.billingprotector.data.createPirateAppsList import com.andreacioccarelli.billingprotector.extensions.removeDuplicatedPackages +import com.andreacioccarelli.billingprotector.extensions.valueOrNull import com.andreacioccarelli.billingprotector.utils.RootUtils +import com.andreacioccarelli.billingprotector.utils.assembleAppList /** - * Created by andrea on 2018/Jul. - * Part of the package com.andreacioccarelli.billingprotector + * Designed and Developed by Andrea Cioccarelli */ + class BillingProtector(private val context: Context) { /** @@ -38,16 +40,16 @@ class BillingProtector(private val context: Context) { fun getPirateAppsList(): List { val foundThreats = mutableListOf() val installedApps = context.packageManager.getInstalledApplications(PackageManager.GET_META_DATA) - val pirateApps = createPirateAppsList() + val pirateApps = assembleAppList(DetectionCause.PIRACY) installedApps.forEach { installedApp -> pirateApps.forEach { when (it.criteria) { - SelectionCriteria.SLICE -> { + SelectionCriteria.CONTAINS -> { if (installedApp.packageName.contains(it.field)) foundThreats.add(it) } - SelectionCriteria.MATCH_PACKAGE -> { + SelectionCriteria.MATCH -> { if (it.field == installedApp.packageName) foundThreats.add(it) } @@ -57,12 +59,13 @@ class BillingProtector(private val context: Context) { } } - SelectionCriteria.LABEL -> { - val label = installedApp.loadLabel(context.packageManager) - val nonLocalizedLabel = installedApp.nonLocalizedLabel + SelectionCriteria.LABEL_REGEXP -> { + val label = installedApp.loadLabel(context.packageManager).valueOrNull() + val nonLocalizedLabel = installedApp.nonLocalizedLabel.valueOrNull() - when (it.field) { - label, nonLocalizedLabel -> foundThreats.add(it) + when { + label.matches(it.field.toRegex()) + || nonLocalizedLabel.matches(it.field.toRegex()) -> foundThreats.add(it) } } } diff --git a/library/src/main/java/com/andreacioccarelli/billingprotector/assets/definitions.kt b/library/src/main/java/com/andreacioccarelli/billingprotector/assets/definitions.kt new file mode 100644 index 0000000..0446b1e --- /dev/null +++ b/library/src/main/java/com/andreacioccarelli/billingprotector/assets/definitions.kt @@ -0,0 +1,140 @@ +@file:Suppress("ClassName") + +package com.andreacioccarelli.billingprotector.assets + +/** + * Designed and Developed by Andrea Cioccarelli + */ + +object definitions { + + private const val lucky_patcher = "Lucky Patcher" + private const val freedom = "Freedom" + private const val xmodgames = "XModGames" + private const val uret_patcher = "Uret Patcher" + private const val creeplays_patcher = "Creeplays Patcher" + private const val creehack = "Creehack" + private const val playcards = "Leo Playcards" + private const val appsara = "AppSara" + private const val modded_store = "Modded Google Play Store" + + + object match { + /** + * Lucky Patcher + */ + const val field1 = "com.chelpus.lackypatch" + const val khash1 = "419cb6875f3fa235ed925c28afc44f2e" + const val kname1 = lucky_patcher + + const val field2 = "com.dimonvideo.luckypatcher" + const val khash2 = "cd9de8549c3e6e151300734f112091b3" + const val kname2 = lucky_patcher + + const val field3 = "com.forpda.lp" + const val khash3 = "c2f5ef59294b96727c061ecc0a792392" + const val kname3 = lucky_patcher + + const val field4 = "ru.aaaaaaac.installer" + const val khash4 = "e74010e84eb49bc67f51554c60b8e222" + const val kname4 = lucky_patcher + + const val field5 = "com.android.vending.licensing.ILicensingService" + const val khash5 = "238b2cc715459f7b9458e0e0744b15e2" + const val kname5 = lucky_patcher + + /** + * Uret patcher + * */ + const val field6 = "uret.jasi2169.patcher" + const val khash6 = "7a3a1cdb08b74117b3c20f2e04ba099e" + const val kname6 = uret_patcher + + /** + * Creeplays Patcher + * */ + const val field7 = "org.creeplays.hack" + const val khash7 = "b30bec898f00f528e382b95856ebb909" + const val kname7 = creeplays_patcher + + /** + * CreeHack + * */ + const val field8 = "apps.zhasik007.hack" + const val khash8 = "48e3b21aec993834ca0a91f48a7099c6" + const val kname8 = creehack + + /** + * Leo Playcards + * */ + const val field9 = "com.leo.playcard" + const val khash9 = "9d8a3405cd058e411c224fb680fa103c" + const val kname9 = playcards + + /** + * AppSara + * */ + const val field10 = "com.appsara.app" + const val khash10 = "a00e921d238bb1b84d104e293313d225" + const val kname10 = appsara + } + + + object slice { + /** + * Lucky Patcher + */ + const val field1 = "com.android.vending.billing.InAppBillingService." + const val khash1 = "48b19168f8f466638c400c2e8eb8eebe" + const val kname1 = lucky_patcher + + const val field2 = "com.android.vending.billing.InAppBillingService." + const val khash2 = "48b19168f8f466638c400c2e8eb8eebe" + const val kname2 = lucky_patcher + + /** + * Freedom + * */ + const val field3 = "jase.freedom" + const val khash3 = "fde5230b767d93fbc23010f9de757f04" + const val kname3 = freedom + + const val field4 = "madkite.freedom" + const val khash4 = "771df92f8cc82ad893bb3378a155338d" + const val kname4 = freedom + + /** + * Modded Play Store + * */ + const val field5 = "com.android.vendinc" + const val khash5 = "81907933708408ddc91af1f381e65bff" + const val kname5 = modded_store + + /** + * XModGames + * */ + const val field6 = "com.xmodgame" + const val khash6 = "00d0c2bf72590fd9281bb0d60a408092" + const val kname6 = xmodgames + } + + object classname { + /** + * Lucky Patcher + * */ + const val field1 = "com.lp" + const val khash1 = "38d21e850edd2a6c6253918770a59b27" + const val kname1 = lucky_patcher + + } + + object regexp { + /** + * Lucky Patcher + * */ + const val field1 = "-*[LІ][uцџ][cс][kкќӄ][yуӳӱӰӯӮУў][-.#@_*/\\+`\"$   ~][PРҎҏр][aаӑӓ][tт][cс][hнһӈҺ][eєёеҽзэҿ][rя][sѕ]?-*" + const val khash1 = "6a730bba41046d0a9a9ec2a24f871380" + const val kname1 = lucky_patcher + } + +} \ No newline at end of file diff --git a/library/src/main/java/com/andreacioccarelli/billingprotector/crypt/HashGeneratior.kt b/library/src/main/java/com/andreacioccarelli/billingprotector/crypt/HashGeneratior.kt new file mode 100644 index 0000000..40d662e --- /dev/null +++ b/library/src/main/java/com/andreacioccarelli/billingprotector/crypt/HashGeneratior.kt @@ -0,0 +1,23 @@ +package com.andreacioccarelli.billingprotector.crypt + +import java.security.MessageDigest +import kotlin.experimental.and + + +/** + * Designed and Developed by Andrea Cioccarelli + */ + +object HashGeneratior { + fun hash(input: String): String { + val md = MessageDigest.getInstance("MD5") + md.update(input.toByteArray()) + val digest = md.digest() + val sb = StringBuffer() + for (b in digest) { + sb.append(String.format("%02x", b and 0xff.toByte())) + } + + return sb.toString() + } +} \ No newline at end of file diff --git a/library/src/main/java/com/andreacioccarelli/billingprotector/data/AppDefinition.kt b/library/src/main/java/com/andreacioccarelli/billingprotector/data/AppDefinition.kt new file mode 100644 index 0000000..ade8608 --- /dev/null +++ b/library/src/main/java/com/andreacioccarelli/billingprotector/data/AppDefinition.kt @@ -0,0 +1,12 @@ +package com.andreacioccarelli.billingprotector.data + +/** + * Designed and Developed by Andrea Cioccarelli + */ + +abstract class AppDefinition{ + abstract val field: String + abstract val hash: String + abstract val criteria: SelectionCriteria + abstract val name: String +} \ No newline at end of file diff --git a/library/src/main/java/com/andreacioccarelli/billingprotector/data/DetectionCause.kt b/library/src/main/java/com/andreacioccarelli/billingprotector/data/DetectionCause.kt new file mode 100644 index 0000000..6070222 --- /dev/null +++ b/library/src/main/java/com/andreacioccarelli/billingprotector/data/DetectionCause.kt @@ -0,0 +1,7 @@ +package com.andreacioccarelli.billingprotector.data + +/** + * Designed and Developed by Andrea Cioccarelli + */ + +enum class DetectionCause { PIRACY } \ No newline at end of file diff --git a/library/src/main/java/com/andreacioccarelli/billingprotector/data/PirateApp.kt b/library/src/main/java/com/andreacioccarelli/billingprotector/data/PirateApp.kt index 39540e7..7237e26 100644 --- a/library/src/main/java/com/andreacioccarelli/billingprotector/data/PirateApp.kt +++ b/library/src/main/java/com/andreacioccarelli/billingprotector/data/PirateApp.kt @@ -1,41 +1,20 @@ package com.andreacioccarelli.billingprotector.data -import android.util.Base64 import android.util.Log +import com.andreacioccarelli.billingprotector.crypt.HashGeneratior /** * Class representing a pirate app with built-in string sign check * */ -data class PirateApp(val field: String, val encodedField: String, val criteria: SelectionCriteria, val detectionName: String) { +data class PirateApp( + override val field: String, + override val hash: String, + override val criteria: SelectionCriteria, + override val name: String +) : AppDefinition() { + init { - val check = Base64.encodeToString(field.toByteArray(), Base64.DEFAULT) - if (check.trim() != encodedField.trim()) { - Log.e("BillingProtector", "Field=[$field], Check=[$check], Encoded Field=[$encodedField]") - throw SecurityException("Package names mismatch, apk file damaged or corrupted") - } + val localComputedHash = HashGeneratior.hash(field) + if (hash != localComputedHash) throw SecurityException("Mackage name checksum mismatch") } -} - -internal fun createPirateAppsList() = listOf( - PirateApp("com.chelpus.lackypatch", "Y29tLmNoZWxwdXMubGFja3lwYXRjaA==", SelectionCriteria.MATCH_PACKAGE, "Lucky Patcher"), - PirateApp("com.dimonvideo.luckypatcher", "Y29tLmRpbW9udmlkZW8ubHVja3lwYXRjaGVy", SelectionCriteria.MATCH_PACKAGE, "Lucky Patcher"), - PirateApp("com.forpda.lp", "Y29tLmZvcnBkYS5scA==", SelectionCriteria.MATCH_PACKAGE, "4Pda Lucy Patcher"), - PirateApp("com.android.vending.billing.InAppBillingService.", "Y29tLmFuZHJvaWQudmVuZGluZy5iaWxsaW5nLkluQXBwQmlsbGluZ1NlcnZpY2Uu", SelectionCriteria.SLICE, "Lucky Patcher"), - PirateApp("ru.aaaaaaac.installer", "cnUuYWFhYWFhYWMuaW5zdGFsbGVy", SelectionCriteria.MATCH_PACKAGE, "Lucky Patcher Installer"), - PirateApp("com.lp", "Y29tLmxw", SelectionCriteria.CLASS_NAME, "Lucky Patcher"), - PirateApp("Lucky Patcher", "THVja3kgUGF0Y2hlcg==", SelectionCriteria.LABEL, "Lucky Patcher"), - PirateApp("Lucky_Patcher", "THVja3lfUGF0Y2hlcg==", SelectionCriteria.LABEL, "Lucky Patcher"), - - // NOT the same as the one above. Using different chars - PirateApp("Luckу_Pаtcher", "THVja9GDX1DQsHRjaGVy", SelectionCriteria.LABEL, "Lucky Patcher"), - PirateApp("com.android.vending.licensing.ILicensingService", "Y29tLmFuZHJvaWQudmVuZGluZy5saWNlbnNpbmcuSUxpY2Vuc2luZ1NlcnZpY2U=", SelectionCriteria.MATCH_PACKAGE, "Lucky Patcher"), - PirateApp("jase.freedom", "amFzZS5mcmVlZG9t", SelectionCriteria.SLICE, "Freedom"), - PirateApp("madkite.freedom", "bWFka2l0ZS5mcmVlZG9t", SelectionCriteria.SLICE, "Freedom"), - PirateApp("uret.jasi2169.patcher", "dXJldC5qYXNpMjE2OS5wYXRjaGVy", SelectionCriteria.MATCH_PACKAGE, "Uret Patcher"), - PirateApp("org.creeplays.hack", "b3JnLmNyZWVwbGF5cy5oYWNr", SelectionCriteria.MATCH_PACKAGE, "Creeplays Patcher"), - PirateApp("com.android.vendinc", "Y29tLmFuZHJvaWQudmVuZGluYw==", SelectionCriteria.MATCH_PACKAGE, "Fake Google Play Store"), - PirateApp("apps.zhasik007.hack", "YXBwcy56aGFzaWswMDcuaGFjaw==", SelectionCriteria.MATCH_PACKAGE, "CreeHack"), - PirateApp("com.leo.playcard", "Y29tLmxlby5wbGF5Y2FyZA==", SelectionCriteria.MATCH_PACKAGE, "Leo Playcard"), - PirateApp("com.appsara.app", "Y29tLmFwcHNhcmEuYXBw", SelectionCriteria.MATCH_PACKAGE, "AppSara"), - PirateApp("com.xmodgame", "Y29tLnhtb2RnYW1l", SelectionCriteria.MATCH_PACKAGE, "Xmod") -) \ No newline at end of file +} \ No newline at end of file diff --git a/library/src/main/java/com/andreacioccarelli/billingprotector/data/SelectionCriteria.kt b/library/src/main/java/com/andreacioccarelli/billingprotector/data/SelectionCriteria.kt index 0deb12d..3325b4d 100644 --- a/library/src/main/java/com/andreacioccarelli/billingprotector/data/SelectionCriteria.kt +++ b/library/src/main/java/com/andreacioccarelli/billingprotector/data/SelectionCriteria.kt @@ -4,4 +4,5 @@ package com.andreacioccarelli.billingprotector.data * Created by andrea on 2018/Jul. * Part of the package com.andreacioccarelli.billingprotector.data */ -enum class SelectionCriteria { MATCH_PACKAGE, SLICE, CLASS_NAME, LABEL } \ No newline at end of file + +enum class SelectionCriteria { MATCH, CONTAINS, CLASS_NAME, LABEL_REGEXP } \ No newline at end of file diff --git a/library/src/main/java/com/andreacioccarelli/billingprotector/extensions/ListExtensions.kt b/library/src/main/java/com/andreacioccarelli/billingprotector/extensions/ListExtensions.kt index 672a0d0..980b1e1 100644 --- a/library/src/main/java/com/andreacioccarelli/billingprotector/extensions/ListExtensions.kt +++ b/library/src/main/java/com/andreacioccarelli/billingprotector/extensions/ListExtensions.kt @@ -11,8 +11,8 @@ fun MutableList.removeDuplicatedPackages(): List { val list = mutableListOf() forEach { - if (it.criteria == SelectionCriteria.MATCH_PACKAGE || - it.criteria == SelectionCriteria.SLICE || + if (it.criteria == SelectionCriteria.MATCH || + it.criteria == SelectionCriteria.CONTAINS || !list.containsPackage(it.field)) { list.add(it) } @@ -23,8 +23,11 @@ fun MutableList.removeDuplicatedPackages(): List { fun MutableList.containsPackage(pk: String): Boolean { for (item in this) { - if (item.detectionName == pk) return true + if (item.name == pk) return true } return false -} \ No newline at end of file +} + +fun MutableList.add(field: String, hash: String, selectionCriteria: SelectionCriteria, name: String) + = add(PirateApp(field, hash, selectionCriteria, name)) \ No newline at end of file diff --git a/library/src/main/java/com/andreacioccarelli/billingprotector/extensions/StringExtensions.kt b/library/src/main/java/com/andreacioccarelli/billingprotector/extensions/StringExtensions.kt index ccd67b2..e42657a 100644 --- a/library/src/main/java/com/andreacioccarelli/billingprotector/extensions/StringExtensions.kt +++ b/library/src/main/java/com/andreacioccarelli/billingprotector/extensions/StringExtensions.kt @@ -4,4 +4,7 @@ package com.andreacioccarelli.billingprotector.extensions * Designed and Developed by Andrea Cioccarelli */ -fun String?.valueOrNull(): String = this as? String ?: "null" \ No newline at end of file +fun CharSequence?.valueOrNull(): String { + val castResult: String? = this as? String + return if (castResult.isNullOrBlank()) "null" else castResult +} \ No newline at end of file diff --git a/library/src/main/java/com/andreacioccarelli/billingprotector/utils/AssemblerFunctions.kt b/library/src/main/java/com/andreacioccarelli/billingprotector/utils/AssemblerFunctions.kt new file mode 100644 index 0000000..a21b200 --- /dev/null +++ b/library/src/main/java/com/andreacioccarelli/billingprotector/utils/AssemblerFunctions.kt @@ -0,0 +1,41 @@ +package com.andreacioccarelli.billingprotector.utils + +import com.andreacioccarelli.billingprotector.assets.definitions +import com.andreacioccarelli.billingprotector.data.DetectionCause +import com.andreacioccarelli.billingprotector.data.PirateApp +import com.andreacioccarelli.billingprotector.data.SelectionCriteria +import com.andreacioccarelli.billingprotector.extensions.add + +/** + * Designed and Developed by Andrea Cioccarelli + */ + +fun assembleAppList(cause: DetectionCause): List { + when (cause) { + DetectionCause.PIRACY -> { + return mutableListOf().apply { + add(definitions.slice.field1, definitions.slice.khash1, SelectionCriteria.CONTAINS, definitions.slice.kname1) + add(definitions.slice.field2, definitions.slice.khash2, SelectionCriteria.CONTAINS, definitions.slice.kname2) + add(definitions.slice.field3, definitions.slice.khash3, SelectionCriteria.CONTAINS, definitions.slice.kname3) + add(definitions.slice.field4, definitions.slice.khash4, SelectionCriteria.CONTAINS, definitions.slice.kname4) + add(definitions.slice.field5, definitions.slice.khash5, SelectionCriteria.CONTAINS, definitions.slice.kname5) + add(definitions.slice.field6, definitions.slice.khash6, SelectionCriteria.CONTAINS, definitions.slice.kname6) + + add(definitions.match.field1, definitions.match.khash1, SelectionCriteria.MATCH, definitions.match.kname1) + add(definitions.match.field2, definitions.match.khash2, SelectionCriteria.MATCH, definitions.match.kname2) + add(definitions.match.field3, definitions.match.khash3, SelectionCriteria.MATCH, definitions.match.kname3) + add(definitions.match.field4, definitions.match.khash4, SelectionCriteria.MATCH, definitions.match.kname4) + add(definitions.match.field5, definitions.match.khash5, SelectionCriteria.MATCH, definitions.match.kname5) + add(definitions.match.field6, definitions.match.khash6, SelectionCriteria.MATCH, definitions.match.kname6) + add(definitions.match.field7, definitions.match.khash7, SelectionCriteria.MATCH, definitions.match.kname7) + add(definitions.match.field8, definitions.match.khash8, SelectionCriteria.MATCH, definitions.match.kname8) + add(definitions.match.field9, definitions.match.khash9, SelectionCriteria.MATCH, definitions.match.kname9) + add(definitions.match.field10, definitions.match.khash10, SelectionCriteria.MATCH, definitions.match.kname10) + + add(definitions.classname.field1, definitions.classname.khash1, SelectionCriteria.CLASS_NAME, definitions.classname.kname1) + + add(definitions.regexp.field1, definitions.regexp.khash1, SelectionCriteria.LABEL_REGEXP, definitions.regexp.kname1) + } + } + } +} \ No newline at end of file diff --git a/library/src/main/java/com/andreacioccarelli/billingprotector/utils/RootUtils.kt b/library/src/main/java/com/andreacioccarelli/billingprotector/utils/RootUtils.kt index 65b2aba..45b8cff 100644 --- a/library/src/main/java/com/andreacioccarelli/billingprotector/utils/RootUtils.kt +++ b/library/src/main/java/com/andreacioccarelli/billingprotector/utils/RootUtils.kt @@ -3,6 +3,7 @@ package com.andreacioccarelli.billingprotector.utils import java.io.BufferedReader import java.io.IOException import java.io.InputStreamReader +import java.lang.RuntimeException /** * Created by andrea on 2018/Jul. @@ -43,9 +44,7 @@ internal object RootUtils { } while (true) outputBuffer.toString() - } catch (io: IOException) { - "" - } catch (nil: NullPointerException) { + } catch (io: RuntimeException) { "" } }