From 0fac05f134c1940a5f39b6d63a9f180266f653d6 Mon Sep 17 00:00:00 2001 From: naijun0403 Date: Wed, 21 May 2025 18:23:43 +0900 Subject: [PATCH] feat(kakaotalk): add patch and fingerprint to force enable debug mode --- patches/api/patches.api | 4 +++ .../misc/ForceEnableDebugModePatch.kt | 31 +++++++++++++++++++ .../ForceEnableDebugModeFingerprint.kt | 24 ++++++++++++++ 3 files changed, 59 insertions(+) create mode 100644 patches/src/main/kotlin/app/revanced/patches/kakaotalk/misc/ForceEnableDebugModePatch.kt create mode 100644 patches/src/main/kotlin/app/revanced/patches/kakaotalk/misc/fingerprints/ForceEnableDebugModeFingerprint.kt diff --git a/patches/api/patches.api b/patches/api/patches.api index 81506e79e..ee1d3f881 100644 --- a/patches/api/patches.api +++ b/patches/api/patches.api @@ -297,6 +297,10 @@ public final class app/revanced/patches/kakaotalk/integrity/VerifyingSignaturePa public static final fun getVerifyingSignaturePatch ()Lapp/revanced/patcher/patch/BytecodePatch; } +public final class app/revanced/patches/kakaotalk/misc/ForceEnableDebugModePatchKt { + public static final fun getForceEnableDebugModePatch ()Lapp/revanced/patcher/patch/BytecodePatch; +} + public final class app/revanced/patches/kakaotalk/misc/RemoveShopTabPatchKt { public static final fun getRemoveShopTabPatch ()Lapp/revanced/patcher/patch/BytecodePatch; } diff --git a/patches/src/main/kotlin/app/revanced/patches/kakaotalk/misc/ForceEnableDebugModePatch.kt b/patches/src/main/kotlin/app/revanced/patches/kakaotalk/misc/ForceEnableDebugModePatch.kt new file mode 100644 index 000000000..d72ba6ed2 --- /dev/null +++ b/patches/src/main/kotlin/app/revanced/patches/kakaotalk/misc/ForceEnableDebugModePatch.kt @@ -0,0 +1,31 @@ +package app.revanced.patches.kakaotalk.misc + +import app.revanced.patcher.extensions.InstructionExtensions.addInstructions +import app.revanced.patcher.extensions.InstructionExtensions.instructions +import app.revanced.patcher.patch.bytecodePatch +import app.revanced.patches.kakaotalk.misc.fingerprints.configConstructorFingerprint +import com.android.tools.smali.dexlib2.Opcode + +@Suppress("unused") +val forceEnableDebugModePatch = bytecodePatch( + name = "Force enable debug mode", + description = "Enables debug mode in the app.", +) { + compatibleWith("com.kakao.talk"("25.4.2")) + + execute { + val method = configConstructorFingerprint.method + val insns = method.instructions + val idxReturn = insns.indexOfFirst { it.opcode == Opcode.RETURN_VOID } // RETURN_VOID + + val clazz = method.definingClass + + method.addInstructions( + idxReturn, + """ + const/4 v0, 0x1 + sput-boolean v0, $clazz->a:Z + """.trimIndent() + ) + } +} \ No newline at end of file diff --git a/patches/src/main/kotlin/app/revanced/patches/kakaotalk/misc/fingerprints/ForceEnableDebugModeFingerprint.kt b/patches/src/main/kotlin/app/revanced/patches/kakaotalk/misc/fingerprints/ForceEnableDebugModeFingerprint.kt new file mode 100644 index 000000000..3b3206807 --- /dev/null +++ b/patches/src/main/kotlin/app/revanced/patches/kakaotalk/misc/fingerprints/ForceEnableDebugModeFingerprint.kt @@ -0,0 +1,24 @@ +package app.revanced.patches.kakaotalk.misc.fingerprints + +import app.revanced.patcher.fingerprint +import com.android.tools.smali.dexlib2.AccessFlags +import com.android.tools.smali.dexlib2.Opcode + +internal val configConstructorFingerprint = fingerprint { + accessFlags(AccessFlags.STATIC, AccessFlags.CONSTRUCTOR) + returns("V") + parameters() + strings("google", "one", "getBytes(...)") + opcodes( + Opcode.SGET_OBJECT, + Opcode.INVOKE_VIRTUAL, + Opcode.INVOKE_STATIC, + Opcode.MOVE_RESULT_OBJECT, + Opcode.SGET_OBJECT, + Opcode.CONST_4, + Opcode.CONST_4, + Opcode.IF_EQ, + Opcode.MOVE, + Opcode.GOTO, + ) +} \ No newline at end of file