From d953c6bdd4315d2ba44845fd569a3d12ac4d1af0 Mon Sep 17 00:00:00 2001 From: Romain Date: Sat, 18 May 2024 23:04:58 +0200 Subject: [PATCH] feat(Piccoma): Add `Spoof Android device ID` patch (#3145) Co-authored-by: oSumAtrIX --- api/revanced-patches.api | 6 ++ .../misc/SpoofAndroidDeviceIdPatch.kt | 59 +++++++++++++++++++ .../fingerprints/GetAndroidIDFingerprint.kt | 16 +++++ 3 files changed, 81 insertions(+) create mode 100644 src/main/kotlin/app/revanced/patches/piccomafr/misc/SpoofAndroidDeviceIdPatch.kt create mode 100644 src/main/kotlin/app/revanced/patches/piccomafr/misc/fingerprints/GetAndroidIDFingerprint.kt diff --git a/api/revanced-patches.api b/api/revanced-patches.api index cfe80faef0..620ca8e9a4 100644 --- a/api/revanced-patches.api +++ b/api/revanced-patches.api @@ -487,6 +487,12 @@ public final class app/revanced/patches/photomath/misc/unlock/plus/UnlockPlusPat public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V } +public final class app/revanced/patches/piccomafr/misc/SpoofAndroidDeviceIdPatch : app/revanced/patcher/patch/BytecodePatch { + public static final field INSTANCE Lapp/revanced/patches/piccomafr/misc/SpoofAndroidDeviceIdPatch; + public fun execute (Lapp/revanced/patcher/data/BytecodeContext;)V + public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V +} + public final class app/revanced/patches/piccomafr/tracking/DisableTrackingPatch : app/revanced/patcher/patch/BytecodePatch { public static final field INSTANCE Lapp/revanced/patches/piccomafr/tracking/DisableTrackingPatch; public fun execute (Lapp/revanced/patcher/data/BytecodeContext;)V diff --git a/src/main/kotlin/app/revanced/patches/piccomafr/misc/SpoofAndroidDeviceIdPatch.kt b/src/main/kotlin/app/revanced/patches/piccomafr/misc/SpoofAndroidDeviceIdPatch.kt new file mode 100644 index 0000000000..a2a9205261 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/piccomafr/misc/SpoofAndroidDeviceIdPatch.kt @@ -0,0 +1,59 @@ +package app.revanced.patches.piccomafr.misc + +import app.revanced.patcher.data.BytecodeContext +import app.revanced.patcher.extensions.InstructionExtensions.addInstructions +import app.revanced.patcher.patch.BytecodePatch +import app.revanced.patcher.patch.annotation.CompatiblePackage +import app.revanced.patcher.patch.annotation.Patch +import app.revanced.patcher.patch.options.PatchOption.PatchExtensions.stringPatchOption +import app.revanced.patches.piccomafr.misc.fingerprints.GetAndroidIDFingerprint +import app.revanced.util.exception + +@Patch( + name = "Spoof Android device ID", + description = "Spoofs the Android device ID used by the app for account authentication." + + "This can be used to copy the account to another device.", + compatiblePackages = [ + CompatiblePackage( + "com.piccomaeurope.fr", + [ + "6.4.0", + "6.4.1", + "6.4.2", + "6.4.3", + "6.4.4", + "6.4.5", + "6.5.0", + "6.5.1", + "6.5.2", + "6.5.3", + "6.5.4", + "6.6.0", + "6.6.1", + "6.6.2", + ], + ), + ], + use = false, +) +@Suppress("unused") +object SpoofAndroidDeviceIdPatch : BytecodePatch( + setOf(GetAndroidIDFingerprint), +) { + private var androidDeviceId = + stringPatchOption( + key = "android-device-id", + default = "0011223344556677", + title = "Android device ID", + description = "The Android device ID to spoof to.", + required = true, + ) { it!!.matches("[A-Fa-f0-9]{16}".toRegex()) } + + override fun execute(context: BytecodeContext) = GetAndroidIDFingerprint.result?.mutableMethod?.addInstructions( + 0, + """ + const-string v0, "$androidDeviceId" + return-object v0 + """, + ) ?: throw GetAndroidIDFingerprint.exception +} diff --git a/src/main/kotlin/app/revanced/patches/piccomafr/misc/fingerprints/GetAndroidIDFingerprint.kt b/src/main/kotlin/app/revanced/patches/piccomafr/misc/fingerprints/GetAndroidIDFingerprint.kt new file mode 100644 index 0000000000..31e1ca6ab2 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/piccomafr/misc/fingerprints/GetAndroidIDFingerprint.kt @@ -0,0 +1,16 @@ +package app.revanced.patches.piccomafr.misc.fingerprints + +import app.revanced.patcher.extensions.or +import app.revanced.patcher.fingerprint.MethodFingerprint +import com.android.tools.smali.dexlib2.AccessFlags + + +internal object GetAndroidIDFingerprint : MethodFingerprint( + parameters = listOf("Landroid/content/Context"), + accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL, + strings = listOf( + "context", + "android_id" + ), + returnType = "Ljava/lang/String" +) \ No newline at end of file