Skip to content

Commit

Permalink
feat: disable verification agent
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonKhew96 committed Jun 8, 2024
1 parent 8408a9d commit 148d92e
Show file tree
Hide file tree
Showing 7 changed files with 90 additions and 1 deletion.
5 changes: 5 additions & 0 deletions app/src/main/java/org/lsposed/corepatch/Config.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ object Config {
const val ENHANCED_MODE = "enhanced_mode"
const val USE_PREVIOUS_SIGNATURES = "use_previous_signatures"
const val BYPASS_SHARED_USER = "bypass_shared_user"
const val DISABLE_VERIFICATION_AGENT = "disable_verification_agent"

private val allConfig = arrayOf(
BYPASS_DOWNGRADE,
Expand Down Expand Up @@ -50,6 +51,10 @@ object Config {
return prefs.getBoolean(BYPASS_SHARED_USER, false)
}

fun isDisableVerificationAgentEnabled(): Boolean {
return prefs.getBoolean(DISABLE_VERIFICATION_AGENT, false)
}

fun getConfig(key: String): Boolean {
return rwPrefs?.getBoolean(key, false) ?: false
}
Expand Down
6 changes: 5 additions & 1 deletion app/src/main/java/org/lsposed/corepatch/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,18 @@ class MainActivity : Activity() {
val bypassSharedUser = SwitchData(
getString(R.string.bypass_shared_user), "", Config.BYPASS_SHARED_USER
)
val disableVerificationAgent = SwitchData(
getString(R.string.disable_verification_agent), "", Config.DISABLE_VERIFICATION_AGENT
)

val dataSet = arrayListOf(
bypassDowngrade,
bypassVerification,
bypassDigest,
enhancedMode,
usePreviousSignatures,
bypassSharedUser
bypassSharedUser,
disableVerificationAgent
)

val adapter = MultiTypeListAdapter(dataSet)
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/java/org/lsposed/corepatch/XposedMain.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import org.lsposed.corepatch.hook.ScanPackageUtilsHook
import org.lsposed.corepatch.hook.SharedUserSettingHook
import org.lsposed.corepatch.hook.SigningDetailsHook
import org.lsposed.corepatch.hook.StrictJarVerifierHook
import org.lsposed.corepatch.hook.VerificationParamsHook
import org.lsposed.corepatch.hook.VerifyingSessionHook

class XposedMain(
base: XposedInterface, param: XposedModuleInterface.ModuleLoadedParam
Expand Down Expand Up @@ -50,6 +52,8 @@ class XposedMain(
SharedUserSettingHook,
SigningDetailsHook,
StrictJarVerifierHook,
VerificationParamsHook,
VerifyingSessionHook,
)
hooks.forEach { it.init() }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,16 @@ object PackageManagerServiceHook : BaseHook() {
}
})

val isVerificationEnabledMethod =
packageManagerServiceClazz.declaredMethods.first { m -> m.name == "isVerificationEnabled" }
hookBefore(isVerificationEnabledMethod, object : BeforeCallback {
override fun before(callback: BeforeHookCallback) {
if (Config.isDisableVerificationAgentEnabled()) {
callback.returnAndSkip(false)
}
}
})

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
val doesSignatureMatchForPermissionsMethod =
packageManagerServiceClazz.declaredMethods.first { m -> m.name == "doesSignatureMatchForPermissions" }
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package org.lsposed.corepatch.hook

import android.annotation.SuppressLint
import android.os.Build
import io.github.libxposed.api.XposedInterface.BeforeHookCallback
import org.lsposed.corepatch.Config
import org.lsposed.corepatch.XposedHelper.BeforeCallback
import org.lsposed.corepatch.XposedHelper.hookBefore
import org.lsposed.corepatch.XposedHelper.hostClassLoader

object VerificationParamsHook: BaseHook() {
override val name = "VerificationParamsHook"

@SuppressLint("PrivateApi")
override fun hook() {
if (Build.VERSION.SDK_INT != Build.VERSION_CODES.TIRAMISU) {
return
}

val verificationParamsClazz = hostClassLoader.loadClass("com.android.server.pm.VerificationParams")

val isVerificationEnabledMethod = verificationParamsClazz.declaredMethods.first { m -> m.name == "isVerificationEnabled" }
hookBefore(isVerificationEnabledMethod, object : BeforeCallback {
override fun before(callback: BeforeHookCallback) {
if (Config.isDisableVerificationAgentEnabled()) {
callback.returnAndSkip(false)
}
}
})
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package org.lsposed.corepatch.hook

import android.annotation.SuppressLint
import android.os.Build
import io.github.libxposed.api.XposedInterface.BeforeHookCallback
import org.lsposed.corepatch.Config
import org.lsposed.corepatch.XposedHelper.BeforeCallback
import org.lsposed.corepatch.XposedHelper.hookBefore
import org.lsposed.corepatch.XposedHelper.hostClassLoader

object VerifyingSessionHook : BaseHook() {
override val name = "VerifyingSessionHook"

@SuppressLint("PrivateApi")
override fun hook() {
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.TIRAMISU) {
return
}

val verifyingSessionClazz =
hostClassLoader.loadClass("com.android.server.pm.VerifyingSession")

val isVerificationEnabledMethod =
verifyingSessionClazz.declaredMethods.first { m -> m.name == "isVerificationEnabled" }
hookBefore(isVerificationEnabledMethod, object : BeforeCallback {
override fun before(callback: BeforeHookCallback) {
if (Config.isDisableVerificationAgentEnabled()) {
callback.returnAndSkip(false)
}
}
})

}
}
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@
<string name="enhanced_mode">Enhanced mode</string>
<string name="use_previous_signatures">Use previous signatures</string>
<string name="bypass_shared_user">Bypass shared user verification</string>
<string name="disable_verification_agent">Disable Package Verification Agent</string>
</resources>

0 comments on commit 148d92e

Please sign in to comment.