refactor(nunl): SpoofCertificatePatch

This commit is contained in:
Pun Butrach
2026-01-11 23:11:02 +07:00
parent 678645723a
commit 8fbcf002e4
2 changed files with 20 additions and 17 deletions

View File

@@ -1,20 +1,24 @@
package app.revanced.patches.nunl.firebase
import app.revanced.patcher.fingerprint
import app.revanced.patcher.BytecodePatchContextMethodMatching.firstMutableMethodDeclaratively
import app.revanced.patcher.accessFlags
import app.revanced.patcher.definingClass
import app.revanced.patcher.name
import app.revanced.patcher.parameterTypes
import app.revanced.patcher.patch.BytecodePatchContext
import app.revanced.patcher.returnType
import com.android.tools.smali.dexlib2.AccessFlags
internal val getFingerprintHashForPackageFingerprints = arrayOf(
internal val firebaseClasses = arrayOf(
"Lcom/google/firebase/installations/remote/FirebaseInstallationServiceClient;",
"Lcom/google/firebase/remoteconfig/internal/ConfigFetchHttpClient;",
"Lcom/google/firebase/remoteconfig/internal/ConfigRealtimeHttpClient;"
).map { className ->
fingerprint {
accessFlags(AccessFlags.PRIVATE)
parameters()
returns("Ljava/lang/String;")
)
custom { methodDef, classDef ->
classDef.type == className && methodDef.name == "getFingerprintHashForPackage"
}
}
internal fun BytecodePatchContext.getFingerprintHashForPackageMethod(className: String) = firstMutableMethodDeclaratively {
accessFlags(AccessFlags.PRIVATE)
definingClass(className)
name("getFingerprintHashForPackage")
returnType("Ljava/lang/String;")
parameterTypes()
}

View File

@@ -1,18 +1,17 @@
package app.revanced.patches.nunl.firebase
import app.revanced.patcher.patch.bytecodePatch
import app.revanced.patcher.patch.creatingBytecodePatch
import app.revanced.util.returnEarly
@Suppress("unused")
val spoofCertificatePatch = bytecodePatch(
name = "Spoof certificate",
@Suppress("unused", "ObjectPropertyName")
val `Spoof certificate` by creatingBytecodePatch(
description = "Spoofs the X-Android-Cert header to allow push messages.",
) {
compatibleWith("nl.sanomamedia.android.nu")
apply {
getFingerprintHashForPackageFingerprints.forEach { fingerprint ->
fingerprint.method.returnEarly("eae41fc018df2731a9b6ae1ac327da44a288667b")
firebaseClasses.forEach { className ->
getFingerprintHashForPackageMethod(className).returnEarly("eae41fc018df2731a9b6ae1ac327da44a288667b")
}
}
}