Skip to content

feat(Instagram): Support app version 378.0.0.52.68 and add bypass check signature #4901

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
May 13, 2025
Prev Previous commit
Next Next commit
Implementing bypass of signature check
  • Loading branch information
hoo-dles committed May 3, 2025
commit 25d6a269527844dcb25d436ca71ac13b2cec02f0
4 changes: 4 additions & 0 deletions patches/api/patches.api
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,10 @@ public final class app/revanced/patches/instagram/ads/HideAdsPatchKt {
public static final fun getHideAdsPatch ()Lapp/revanced/patcher/patch/BytecodePatch;
}

public final class app/revanced/patches/instagram/misc/signature/SignatureCheckPatchKt {
public static final fun getSignatureCheckPatch ()Lapp/revanced/patcher/patch/BytecodePatch;
}

public final class app/revanced/patches/irplus/ad/RemoveAdsPatchKt {
public static final fun getRemoveAdsPatch ()Lapp/revanced/patcher/patch/BytecodePatch;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package app.revanced.patches.instagram.misc.signature

import app.revanced.patcher.fingerprint
import com.android.tools.smali.dexlib2.Opcode

internal val launcherFingerprint = fingerprint {
opcodes(
Opcode.INVOKE_STATIC,
Opcode.INVOKE_VIRTUAL,
Opcode.RETURN_VOID
)
strings(
"com.instagram.mainactivity.InstagramMainActivity",
"redirect_from_launcher_activity"
)
}

internal val onReceiveNotificationFingerprint = fingerprint {
opcodes(
Opcode.INVOKE_STATIC,
Opcode.CONST,
Opcode.GOTO
)
custom { method, classDef ->
method.name == "onReceive" && classDef.endsWith("/NotificationActionReceiver;")
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package app.revanced.patches.instagram.misc.signature

import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
import app.revanced.patcher.patch.bytecodePatch
import app.revanced.util.indexOfFirstInstruction
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction

@Suppress("unused")
val signatureCheckPatch = bytecodePatch(
name = "Disable signature check",
description = "Disables the signature check that causes any modified app to crash on startup."
) {
compatibleWith("com.instagram.android"("378.0.0.52.68"))

// Patching method is inspired by:
// https://github.com/mamiiblt/instafel/blob/032c6a714a4a862462cd4bcd106083f640b13219/instafel.patcher/src/main/java/me/mamiiblt/instafel/patcher/patches/fix/FixSecureCtxCrash.java
//
// Logic has been adapted to rely less on garbled method names that are likely to change. Instagram's code is
// highly obfuscated, so any comments on code flow are best guesses.
execute {
// Main activity insertion point from NotificationAction receiver bypasses IgSecureContext check. Get the
// method it calls, and use it to replace the method called by the Launcher.
val safeMethod = onReceiveNotificationFingerprint.let { it ->
navigate(it.method)
.to(it.patternMatch!!.startIndex) // navigate into invoke-static
.to { instr -> instr.opcode == Opcode.INVOKE_VIRTUAL } // navigate to first invoke-virtual
.original()
}

launcherFingerprint.let {
navigate(it.method)
.to(it.patternMatch!!.startIndex) // navigate into invoke-static
.stop() // patch this method
}.apply {
val targetIndex = indexOfFirstInstruction(Opcode.INVOKE_VIRTUAL)
val origReg = getInstruction<FiveRegisterInstruction>(targetIndex).registerD

// Only replace the method called on this class's singleton.
replaceInstruction(
targetIndex,
"invoke-virtual { v$origReg }, $safeMethod"
)
}
}
}