Skip to content

Commit

Permalink
feat(Digitales Amt): Bump compatibility to 3.0.2 (#3217)
Browse files Browse the repository at this point in the history
Co-authored-by: oSumAtrIX <johan.melkonyan1@web.de>
  • Loading branch information
1fexd and oSumAtrIX committed Nov 4, 2023
1 parent c04c54e commit 79a1571
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 37 deletions.
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
package app.revanced.patches.idaustria.detection.root

import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.annotation.CompatiblePackage
import app.revanced.patcher.patch.annotation.Patch
import app.revanced.patches.idaustria.detection.root.fingerprints.RootDetectionFingerprint
import app.revanced.patches.idaustria.detection.root.fingerprints.AttestationSupportedCheckFingerprint
import app.revanced.patches.idaustria.detection.root.fingerprints.BootloaderCheckFingerprint
import app.revanced.patches.idaustria.detection.root.fingerprints.RootCheckFingerprint
import app.revanced.util.Utils.returnEarly

@Patch(
name = "Remove root detection",
description = "Removes the check for root permissions and unlocked bootloader.",
compatiblePackages = [CompatiblePackage("at.gv.oe.app", ["2.7.1"])]
compatiblePackages = [CompatiblePackage("at.gv.oe.app", ["3.0.2"])]
)
@Suppress("unused")
object RootDetectionPatch : BytecodePatch(
setOf(RootDetectionFingerprint)
setOf(AttestationSupportedCheckFingerprint, BootloaderCheckFingerprint, RootCheckFingerprint)
) {
override fun execute(context: BytecodeContext) =
RootDetectionFingerprint.result!!.mutableMethod.addInstruction(0, "return-void")
override fun execute(context: BytecodeContext) = listOf(
AttestationSupportedCheckFingerprint,
BootloaderCheckFingerprint,
RootCheckFingerprint
).returnEarly(true)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package app.revanced.patches.idaustria.detection.root.fingerprints

import app.revanced.patcher.fingerprint.MethodFingerprint
import com.android.tools.smali.dexlib2.AccessFlags

object AttestationSupportedCheckFingerprint : MethodFingerprint(
"V",
accessFlags = AccessFlags.PUBLIC.value,
customFingerprint = { methodDef, _ ->
methodDef.name == "attestationSupportCheck" &&
methodDef.definingClass.endsWith("/DeviceIntegrityCheck;")
}
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package app.revanced.patches.idaustria.detection.root.fingerprints

import app.revanced.patcher.fingerprint.MethodFingerprint
import com.android.tools.smali.dexlib2.AccessFlags

object BootloaderCheckFingerprint : MethodFingerprint(
"Z",
accessFlags = AccessFlags.PUBLIC.value,
customFingerprint = { methodDef, _ ->
methodDef.name == "bootloaderCheck" &&
methodDef.definingClass.endsWith("/DeviceIntegrityCheck;")
}
)
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ package app.revanced.patches.idaustria.detection.root.fingerprints
import app.revanced.patcher.fingerprint.MethodFingerprint
import com.android.tools.smali.dexlib2.AccessFlags

object RootDetectionFingerprint : MethodFingerprint(
object RootCheckFingerprint : MethodFingerprint(
"V",
accessFlags = AccessFlags.PUBLIC.value,
customFingerprint = { methodDef, _ ->
methodDef.name == "rootCheck" &&
methodDef.definingClass.endsWith("/DeviceIntegrityCheck;")
}
)
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import app.revanced.patches.idaustria.detection.signature.fingerprints.SpoofSign
@Patch(
name = "Spoof signature",
description = "Spoofs the signature of the app.",
compatiblePackages = [CompatiblePackage("at.gv.oe.app", ["2.7.1"])]
compatiblePackages = [CompatiblePackage("at.gv.oe.app", ["3.0.2"])]
)
@Suppress("unused")
object SpoofSignaturePatch : BytecodePatch(
Expand Down
32 changes: 32 additions & 0 deletions src/main/kotlin/app/revanced/util/Utils.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package app.revanced.util

import app.revanced.extensions.exception
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.fingerprint.MethodFingerprint

object Utils {
/**
* Return the resolved methods of [MethodFingerprint]s early.
*/
fun List<MethodFingerprint>.returnEarly(bool: Boolean = false) {
val const = if (bool) "0x1" else "0x0"
this.forEach { fingerprint ->
fingerprint.result?.let { result ->
val stringInstructions = when (result.method.returnType.first()) {
'L' -> """
const/4 v0, $const
return-object v0
"""
'V' -> "return-void"
'I', 'Z' -> """
const/4 v0, $const
return v0
"""
else -> throw Exception("This case should never happen.")
}

result.mutableMethod.addInstructions(0, stringInstructions)
} ?: throw fingerprint.exception
}
}
}
30 changes: 1 addition & 29 deletions src/main/kotlin/app/revanced/util/microg/MicroGBytecodeHelper.kt
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package app.revanced.util.microg

import app.revanced.extensions.exception
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
import app.revanced.patcher.fingerprint.MethodFingerprint
import app.revanced.patcher.util.proxy.mutableTypes.MutableClass
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
import app.revanced.util.Utils.returnEarly
import app.revanced.util.microg.Constants.ACTIONS
import app.revanced.util.microg.Constants.AUTHORITIES
import app.revanced.util.microg.Constants.MICROG_VENDOR
Expand Down Expand Up @@ -213,31 +212,4 @@ internal object MicroGBytecodeHelper {
}
}
}

/**
* Return the resolved methods of a list of [MethodFingerprint] early.
*/
private fun List<MethodFingerprint>.returnEarly() {
this.forEach { fingerprint ->
fingerprint.result?.let { result ->
val stringInstructions = when (result.method.returnType.first()) {
'L' -> """
const/4 v0, 0x0
return-object v0
"""

'V' -> "return-void"
'I' -> """
const/4 v0, 0x0
return v0
"""

else -> throw Exception("This case should never happen.")
}
result.mutableMethod.addInstructions(
0, stringInstructions
)
} ?: throw fingerprint.exception
}
}
}

0 comments on commit 79a1571

Please sign in to comment.