mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-06-13 05:37:40 +02:00
fix(Spoof user agent): Use original package name in query parameter of api/stats
This commit is contained in:
@ -1,13 +1,19 @@
|
|||||||
package app.revanced.patches.shared.spoof.useragent
|
package app.revanced.patches.shared.spoof.useragent
|
||||||
|
|
||||||
|
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
|
||||||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||||
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
|
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
|
||||||
import app.revanced.patches.shared.transformation.IMethodCall
|
import app.revanced.patches.shared.transformation.IMethodCall
|
||||||
import app.revanced.patches.shared.transformation.filterMapInstruction35c
|
import app.revanced.patches.shared.transformation.filterMapInstruction35c
|
||||||
import app.revanced.patches.shared.transformation.transformInstructionsPatch
|
import app.revanced.patches.shared.transformation.transformInstructionsPatch
|
||||||
|
import app.revanced.util.fingerprint.methodOrThrow
|
||||||
import app.revanced.util.getReference
|
import app.revanced.util.getReference
|
||||||
import app.revanced.util.indexOfFirstInstruction
|
import app.revanced.util.indexOfFirstInstruction
|
||||||
|
import app.revanced.util.indexOfFirstInstructionOrThrow
|
||||||
|
import app.revanced.util.indexOfFirstInstructionReversedOrThrow
|
||||||
|
import app.revanced.util.indexOfFirstStringInstructionOrThrow
|
||||||
import com.android.tools.smali.dexlib2.Opcode
|
import com.android.tools.smali.dexlib2.Opcode
|
||||||
|
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
|
||||||
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
||||||
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
|
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
|
||||||
import com.android.tools.smali.dexlib2.iface.reference.StringReference
|
import com.android.tools.smali.dexlib2.iface.reference.StringReference
|
||||||
@ -66,6 +72,22 @@ fun baseSpoofUserAgentPatch(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
executeBlock = {
|
||||||
|
apiStatsFingerprint.methodOrThrow().apply {
|
||||||
|
val stringIndex = indexOfFirstStringInstructionOrThrow(CLIENT_PACKAGE_NAME)
|
||||||
|
val putIndex = indexOfFirstInstructionOrThrow(stringIndex) {
|
||||||
|
opcode == Opcode.INVOKE_INTERFACE &&
|
||||||
|
getReference<MethodReference>()?.name == "put"
|
||||||
|
}
|
||||||
|
val packageNameRegister = getInstruction<FiveRegisterInstruction>(putIndex).registerE
|
||||||
|
val insertIndex = indexOfFirstInstructionReversedOrThrow(putIndex, Opcode.INVOKE_STATIC)
|
||||||
|
|
||||||
|
addInstruction(
|
||||||
|
insertIndex,
|
||||||
|
"const-string v$packageNameRegister, \"$packageName\"",
|
||||||
|
)
|
||||||
|
}
|
||||||
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
@Suppress("unused")
|
@Suppress("unused")
|
||||||
|
@ -0,0 +1,14 @@
|
|||||||
|
package app.revanced.patches.shared.spoof.useragent
|
||||||
|
|
||||||
|
import app.revanced.util.fingerprint.legacyFingerprint
|
||||||
|
import app.revanced.util.or
|
||||||
|
import com.android.tools.smali.dexlib2.AccessFlags
|
||||||
|
|
||||||
|
const val CLIENT_PACKAGE_NAME = "cbr"
|
||||||
|
|
||||||
|
internal val apiStatsFingerprint = legacyFingerprint(
|
||||||
|
name = "apiStatsFingerprint",
|
||||||
|
accessFlags = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR,
|
||||||
|
returnType = "V",
|
||||||
|
strings = listOf(CLIENT_PACKAGE_NAME),
|
||||||
|
)
|
Reference in New Issue
Block a user