mirror of
https://github.com/rhunk/SnapEnhance.git
synced 2025-06-12 05:07:46 +02:00
feat: LSPatch obfuscation
This commit is contained in:
@ -64,6 +64,10 @@ class SnapEnhance {
|
||||
}
|
||||
runCatching {
|
||||
LSPatchUpdater.onBridgeConnected(appContext, bridgeClient)
|
||||
}.onFailure {
|
||||
logCritical("Failed to init LSPatchUpdater", it)
|
||||
}
|
||||
runCatching {
|
||||
measureTimeMillis {
|
||||
runBlocking {
|
||||
init(this)
|
||||
|
@ -5,8 +5,8 @@ import me.rhunk.snapenhance.core.features.FeatureLoadParams
|
||||
import me.rhunk.snapenhance.core.util.hook.HookStage
|
||||
import me.rhunk.snapenhance.core.util.hook.Hooker
|
||||
|
||||
class DeviceSpooferHook: Feature("device_spoofer", loadParams = FeatureLoadParams.ACTIVITY_CREATE_ASYNC) {
|
||||
override fun asyncOnActivityCreate() {
|
||||
class DeviceSpooferHook: Feature("device_spoofer", loadParams = FeatureLoadParams.INIT_SYNC) {
|
||||
override fun init() {
|
||||
if (context.config.experimental.spoof.globalState != true) return
|
||||
|
||||
val fingerprint by context.config.experimental.spoof.device.fingerprint
|
||||
|
@ -18,11 +18,24 @@ object LSPatchUpdater {
|
||||
}
|
||||
|
||||
fun onBridgeConnected(context: ModContext, bridgeClient: BridgeClient) {
|
||||
val obfuscatedModulePath by lazy {
|
||||
(runCatching {
|
||||
context::class.java.classLoader?.loadClass("org.lsposed.lspatch.share.Constants")
|
||||
}.getOrNull())?.declaredFields?.firstOrNull { it.name == "MANAGER_PACKAGE_NAME" }?.also {
|
||||
it.isAccessible = true
|
||||
}?.get(null) as? String
|
||||
}
|
||||
|
||||
val embeddedModule = context.androidContext.cacheDir
|
||||
.resolve("lspatch")
|
||||
.resolve(BuildConfig.APPLICATION_ID).let { moduleDir ->
|
||||
if (!moduleDir.exists()) return@let null
|
||||
moduleDir.listFiles()?.firstOrNull { it.extension == "apk" }
|
||||
} ?: obfuscatedModulePath?.let { path ->
|
||||
context.androidContext.cacheDir.resolve(path).let dir@{ moduleDir ->
|
||||
if (!moduleDir.exists()) return@dir null
|
||||
moduleDir.listFiles()?.firstOrNull { it.extension == "apk" }
|
||||
} ?: return
|
||||
} ?: return
|
||||
|
||||
context.log.verbose("Found embedded SE at ${embeddedModule.absolutePath}", TAG)
|
||||
|
Reference in New Issue
Block a user