release: v1.1.0 - 修复系统服务Hook稳定性与自隐匿死锁,新增进入应用自动授权,豁免LSPosed管理包名
This commit is contained in:
1 parent
6dabe7c26a
commit
5e56a1ee6f
12 files changed
+187
-195
No files matched your search
@@ -18,8 +18,8 @@ android {
|
||||
applicationId = "com.lzxnone.openloc"
|
||||
minSdk = 28
|
||||
targetSdk = 36
|
||||
versionCode = 1
|
||||
versionName = "1.0.0"
|
||||
versionCode = 2
|
||||
versionName = "1.1.0"
|
||||
|
||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ object UpdateChecker {
|
||||
/**
|
||||
* 检查 GitHub 是否有新版本
|
||||
*/
|
||||
suspend fun checkUpdate(currentVersion: String = "v1.0.0"): Result<UpdateInfo> = withContext(Dispatchers.IO) {
|
||||
suspend fun checkUpdate(currentVersion: String = "v1.1.0"): Result<UpdateInfo> = withContext(Dispatchers.IO) {
|
||||
try {
|
||||
val url = URL(GITHUB_API_URL)
|
||||
val conn = (url.openConnection() as HttpURLConnection).apply {
|
||||
|
||||
@@ -31,8 +31,8 @@ class HookEntry : IXposedHookLoadPackage {
|
||||
return
|
||||
}
|
||||
|
||||
// 过滤系统 UI 进程
|
||||
if (lpparam.packageName == "com.android.systemui") {
|
||||
// 过滤系统 UI 及框架管理工具进程(避免侵入管理环境)
|
||||
if (isManagementPackage(lpparam.packageName)) {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -103,5 +103,20 @@ class HookEntry : IXposedHookLoadPackage {
|
||||
|
||||
companion object {
|
||||
const val MODULE_PACKAGE_NAME = "com.lzxnone.openloc"
|
||||
|
||||
private val MANAGEMENT_PACKAGES = setOf(
|
||||
"com.android.systemui",
|
||||
"com.android.settings",
|
||||
"com.topjohnwu.magisk",
|
||||
"io.github.vvb2060.magisk",
|
||||
"me.weishu.kernelsu",
|
||||
"com.android.packageinstaller",
|
||||
"com.google.android.packageinstaller",
|
||||
"com.miui.packageinstaller"
|
||||
)
|
||||
|
||||
fun isManagementPackage(packageName: String): Boolean {
|
||||
return packageName in MANAGEMENT_PACKAGES || packageName.startsWith("org.lsposed.")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.lzxnone.openloc.hook.interceptor
|
||||
|
||||
import android.content.ContentResolver
|
||||
import android.content.Context
|
||||
import android.content.pm.ApplicationInfo
|
||||
import android.content.pm.PackageInfo
|
||||
@@ -11,114 +10,36 @@ import de.robv.android.xposed.XposedBridge
|
||||
import de.robv.android.xposed.XposedHelpers
|
||||
|
||||
/**
|
||||
* 防检测与隐匿拦截器
|
||||
* 1. 堆栈清洗:过滤 Xposed / LSPosed / OpenLoc 相关调用栈帧
|
||||
* 2. 模块包名自隐匿:隐藏 com.lzxnone.openloc,防止被目标应用通过 PackageManager 探测
|
||||
* 3. 开发者选项与模拟位置状态伪装:伪装开发者模式、USB调试、模拟位置为未开启
|
||||
* 模块自隐匿拦截器(安全级别:高,零系统递归风险)
|
||||
* 仅在目标应用进程内过滤 PackageManager 针对 com.lzxnone.openloc 的包名扫描
|
||||
* 彻底移除对 Throwable/Thread 堆栈以及 Settings.Global/Secure 等易引发死锁的系统基础类的 Hook
|
||||
*/
|
||||
object AntiDetectionHook {
|
||||
|
||||
private val isSanitizingStack = ThreadLocal.withInitial { false }
|
||||
|
||||
private val CAMOUFLAGE_SETTINGS_KEYS = setOf(
|
||||
"development_settings_enabled",
|
||||
"adb_enabled",
|
||||
"mock_location",
|
||||
"ALLOW_MOCK_LOCATION"
|
||||
)
|
||||
|
||||
private const val MODULE_PACKAGE_NAME = "com.lzxnone.openloc"
|
||||
|
||||
// 豁免调用方白名单:LSPosed 管理器、Root 工具和系统包管理组件绝不隐藏,确保能正常读取模块名称与状态
|
||||
private val EXCLUDED_CALLERS = setOf(
|
||||
MODULE_PACKAGE_NAME,
|
||||
"android",
|
||||
"com.android.systemui",
|
||||
"com.android.settings",
|
||||
"org.lsposed.manager",
|
||||
"org.lsposed.lspd",
|
||||
"com.topjohnwu.magisk",
|
||||
"io.github.vvb2060.magisk",
|
||||
"me.weishu.kernelsu",
|
||||
"com.android.packageinstaller",
|
||||
"com.google.android.packageinstaller",
|
||||
"com.miui.packageinstaller"
|
||||
)
|
||||
|
||||
fun hook(classLoader: ClassLoader, contextProvider: () -> Context?) {
|
||||
hookStackTrace(contextProvider)
|
||||
hookPackageManager(classLoader, contextProvider)
|
||||
hookSettingsCamouflage(classLoader, contextProvider)
|
||||
}
|
||||
|
||||
/**
|
||||
* 1. 调用栈隐匿:对 Throwable 与 Thread 的 getStackTrace 进行清洗
|
||||
*/
|
||||
private fun hookStackTrace(contextProvider: () -> Context?) {
|
||||
try {
|
||||
// Hook Throwable.getStackTrace()
|
||||
XposedHelpers.findAndHookMethod(
|
||||
Throwable::class.java,
|
||||
"getStackTrace",
|
||||
object : XC_MethodHook() {
|
||||
override fun afterHookedMethod(param: MethodHookParam) {
|
||||
if (isSanitizingStack.get() == true) return
|
||||
try {
|
||||
isSanitizingStack.set(true)
|
||||
val ctx = contextProvider() ?: return
|
||||
val config = ConfigFetcher.getConfig(ctx)
|
||||
if (!config.shouldMock(ctx.packageName) || !config.isStealthEnabled) return
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
val originalElements = param.result as? Array<StackTraceElement> ?: return
|
||||
var hasForbidden = false
|
||||
for (elem in originalElements) {
|
||||
if (isForbiddenClassName(elem.className)) {
|
||||
hasForbidden = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if (hasForbidden) {
|
||||
param.result = originalElements.filter { !isForbiddenClassName(it.className) }.toTypedArray()
|
||||
}
|
||||
} finally {
|
||||
isSanitizingStack.set(false)
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
// Hook Thread.getStackTrace()
|
||||
XposedHelpers.findAndHookMethod(
|
||||
Thread::class.java,
|
||||
"getStackTrace",
|
||||
object : XC_MethodHook() {
|
||||
override fun afterHookedMethod(param: MethodHookParam) {
|
||||
if (isSanitizingStack.get() == true) return
|
||||
try {
|
||||
isSanitizingStack.set(true)
|
||||
val ctx = contextProvider() ?: return
|
||||
val config = ConfigFetcher.getConfig(ctx)
|
||||
if (!config.shouldMock(ctx.packageName) || !config.isStealthEnabled) return
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
val originalElements = param.result as? Array<StackTraceElement> ?: return
|
||||
var hasForbidden = false
|
||||
for (elem in originalElements) {
|
||||
if (isForbiddenClassName(elem.className)) {
|
||||
hasForbidden = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if (hasForbidden) {
|
||||
param.result = originalElements.filter { !isForbiddenClassName(it.className) }.toTypedArray()
|
||||
}
|
||||
} finally {
|
||||
isSanitizingStack.set(false)
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
} catch (t: Throwable) {
|
||||
XposedBridge.log("[OpenLoc] hookStackTrace error: ${t.message}")
|
||||
}
|
||||
}
|
||||
|
||||
private fun isForbiddenClassName(className: String): Boolean {
|
||||
val lower = className.lowercase()
|
||||
return lower.contains("openloc") ||
|
||||
lower.contains("xposed") ||
|
||||
lower.contains("lsposed") ||
|
||||
lower.contains("sandhook") ||
|
||||
lower.contains("edxposed")
|
||||
}
|
||||
|
||||
/**
|
||||
* 2. PackageManager 模块自隐匿
|
||||
* PackageManager 模块包名安全隐匿
|
||||
*/
|
||||
private fun hookPackageManager(classLoader: ClassLoader, contextProvider: () -> Context?) {
|
||||
val pmClasses = listOf(
|
||||
@@ -142,6 +63,7 @@ object AntiDetectionHook {
|
||||
val pkgName = param.args.firstOrNull { it is String } as? String ?: return
|
||||
if (pkgName == MODULE_PACKAGE_NAME) {
|
||||
val ctx = contextProvider() ?: return
|
||||
if (isCallerExcluded(ctx.packageName)) return
|
||||
val config = ConfigFetcher.getConfig(ctx)
|
||||
if (config.shouldMock(ctx.packageName) && config.isStealthEnabled) {
|
||||
param.throwable = PackageManager.NameNotFoundException(pkgName)
|
||||
@@ -158,6 +80,7 @@ object AntiDetectionHook {
|
||||
val pkgName = param.args.firstOrNull { it is String } as? String ?: return
|
||||
if (pkgName == MODULE_PACKAGE_NAME) {
|
||||
val ctx = contextProvider() ?: return
|
||||
if (isCallerExcluded(ctx.packageName)) return
|
||||
val config = ConfigFetcher.getConfig(ctx)
|
||||
if (config.shouldMock(ctx.packageName) && config.isStealthEnabled) {
|
||||
param.throwable = PackageManager.NameNotFoundException(pkgName)
|
||||
@@ -172,6 +95,7 @@ object AntiDetectionHook {
|
||||
XposedBridge.hookMethod(method, object : XC_MethodHook() {
|
||||
override fun afterHookedMethod(param: MethodHookParam) {
|
||||
val ctx = contextProvider() ?: return
|
||||
if (isCallerExcluded(ctx.packageName)) return
|
||||
val config = ConfigFetcher.getConfig(ctx)
|
||||
if (!config.shouldMock(ctx.packageName) || !config.isStealthEnabled) return
|
||||
|
||||
@@ -189,6 +113,7 @@ object AntiDetectionHook {
|
||||
XposedBridge.hookMethod(method, object : XC_MethodHook() {
|
||||
override fun afterHookedMethod(param: MethodHookParam) {
|
||||
val ctx = contextProvider() ?: return
|
||||
if (isCallerExcluded(ctx.packageName)) return
|
||||
val config = ConfigFetcher.getConfig(ctx)
|
||||
if (!config.shouldMock(ctx.packageName) || !config.isStealthEnabled) return
|
||||
|
||||
@@ -206,75 +131,7 @@ object AntiDetectionHook {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 3. 开发者选项与系统模拟位置状态伪装 (Settings.Secure & Settings.Global)
|
||||
*/
|
||||
private fun hookSettingsCamouflage(classLoader: ClassLoader, contextProvider: () -> Context?) {
|
||||
val settingsClasses = listOf(
|
||||
"android.provider.Settings\$Secure",
|
||||
"android.provider.Settings\$Global"
|
||||
)
|
||||
|
||||
for (className in settingsClasses) {
|
||||
val settingsClass = try {
|
||||
XposedHelpers.findClass(className, classLoader)
|
||||
} catch (_: Throwable) {
|
||||
null
|
||||
} ?: continue
|
||||
|
||||
for (method in settingsClass.declaredMethods) {
|
||||
val methodName = method.name
|
||||
when (methodName) {
|
||||
"getString" -> {
|
||||
try {
|
||||
XposedBridge.hookMethod(method, object : XC_MethodHook() {
|
||||
override fun afterHookedMethod(param: MethodHookParam) {
|
||||
val key = param.args.firstOrNull { it is String } as? String ?: return
|
||||
if (CAMOUFLAGE_SETTINGS_KEYS.contains(key)) {
|
||||
val ctx = contextProvider() ?: return
|
||||
val config = ConfigFetcher.getConfig(ctx)
|
||||
if (config.shouldMock(ctx.packageName) && config.isDevCamouflageEnabled) {
|
||||
param.result = "0"
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
} catch (_: Throwable) {}
|
||||
}
|
||||
"getInt" -> {
|
||||
try {
|
||||
XposedBridge.hookMethod(method, object : XC_MethodHook() {
|
||||
override fun afterHookedMethod(param: MethodHookParam) {
|
||||
val key = param.args.firstOrNull { it is String } as? String ?: return
|
||||
if (CAMOUFLAGE_SETTINGS_KEYS.contains(key)) {
|
||||
val ctx = contextProvider() ?: return
|
||||
val config = ConfigFetcher.getConfig(ctx)
|
||||
if (config.shouldMock(ctx.packageName) && config.isDevCamouflageEnabled) {
|
||||
param.result = 0
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
} catch (_: Throwable) {}
|
||||
}
|
||||
"getLong" -> {
|
||||
try {
|
||||
XposedBridge.hookMethod(method, object : XC_MethodHook() {
|
||||
override fun afterHookedMethod(param: MethodHookParam) {
|
||||
val key = param.args.firstOrNull { it is String } as? String ?: return
|
||||
if (CAMOUFLAGE_SETTINGS_KEYS.contains(key)) {
|
||||
val ctx = contextProvider() ?: return
|
||||
val config = ConfigFetcher.getConfig(ctx)
|
||||
if (config.shouldMock(ctx.packageName) && config.isDevCamouflageEnabled) {
|
||||
param.result = 0L
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
} catch (_: Throwable) {}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private fun isCallerExcluded(callerPackageName: String): Boolean {
|
||||
return EXCLUDED_CALLERS.contains(callerPackageName) || callerPackageName.startsWith("org.lsposed.")
|
||||
}
|
||||
}
|
||||
@@ -21,8 +21,10 @@ object ConfigFetcher {
|
||||
|
||||
private const val CACHE_DURATION_MS = 1500L // 缓存 1.5 秒,保证即时性同时兼顾性能
|
||||
|
||||
private val isFetching = ThreadLocal.withInitial { false }
|
||||
|
||||
/**
|
||||
* 获取最新配置(带平滑缓存)
|
||||
* 获取最新配置(带平滑缓存与防死锁重入保护)
|
||||
*/
|
||||
fun getConfig(context: Context, force: Boolean = false): MockConfig {
|
||||
val now = System.currentTimeMillis()
|
||||
@@ -30,6 +32,11 @@ object ConfigFetcher {
|
||||
return cachedConfig!!
|
||||
}
|
||||
|
||||
if (isFetching.get() == true) {
|
||||
return cachedConfig ?: MockConfig()
|
||||
}
|
||||
|
||||
isFetching.set(true)
|
||||
return try {
|
||||
val bundle = context.contentResolver.call(
|
||||
PROVIDER_URI,
|
||||
@@ -38,6 +45,7 @@ object ConfigFetcher {
|
||||
null
|
||||
)
|
||||
|
||||
|
||||
if (bundle != null) {
|
||||
val mode = bundle.getString(ConfigContract.KEY_APP_MOCK_MODE, "GLOBAL") ?: "GLOBAL"
|
||||
val whitelistJson = bundle.getString(ConfigContract.KEY_WHITELIST_APPS, "[]") ?: "[]"
|
||||
@@ -74,9 +82,12 @@ object ConfigFetcher {
|
||||
} catch (t: Throwable) {
|
||||
// 在目标尚未完全就绪或权限受限时的静默容错
|
||||
cachedConfig ?: MockConfig()
|
||||
} finally {
|
||||
isFetching.set(false)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private fun parseSet(jsonStr: String): Set<String> {
|
||||
return try {
|
||||
val array = org.json.JSONArray(jsonStr)
|
||||
|
||||
@@ -24,7 +24,11 @@ import com.lzxnone.openloc.ui.screens.home.HomeScreen
|
||||
import com.lzxnone.openloc.ui.screens.location.LocationScreen
|
||||
import com.lzxnone.openloc.ui.screens.settings.SettingsScreen
|
||||
|
||||
import android.Manifest
|
||||
import android.content.pm.PackageManager
|
||||
import android.widget.Toast
|
||||
import androidx.activity.compose.rememberLauncherForActivityResult
|
||||
import androidx.activity.result.contract.ActivityResultContracts
|
||||
import androidx.compose.animation.AnimatedVisibility
|
||||
import androidx.compose.animation.slideInHorizontally
|
||||
import androidx.compose.animation.slideOutHorizontally
|
||||
@@ -33,6 +37,7 @@ import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.rememberCoroutineScope
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.core.content.ContextCompat
|
||||
import com.lzxnone.openloc.R
|
||||
import com.lzxnone.openloc.core.util.UpdateChecker
|
||||
import com.lzxnone.openloc.core.util.UpdateInfo
|
||||
@@ -59,10 +64,37 @@ fun MainScreen(
|
||||
val isServiceEnabled = AppPreferences.isServiceEnabled
|
||||
val isModuleActive = remember { HookStatus.isModuleActive() }
|
||||
|
||||
// 自动权限申请:进入软件时,若没有定位权限,主动向用户申请
|
||||
val locationPermissionLauncher = rememberLauncherForActivityResult(
|
||||
contract = ActivityResultContracts.RequestMultiplePermissions()
|
||||
) { _ ->
|
||||
// 权限回调处理
|
||||
}
|
||||
|
||||
LaunchedEffect(Unit) {
|
||||
val hasFine = ContextCompat.checkSelfPermission(
|
||||
context,
|
||||
Manifest.permission.ACCESS_FINE_LOCATION
|
||||
) == PackageManager.PERMISSION_GRANTED
|
||||
val hasCoarse = ContextCompat.checkSelfPermission(
|
||||
context,
|
||||
Manifest.permission.ACCESS_COARSE_LOCATION
|
||||
) == PackageManager.PERMISSION_GRANTED
|
||||
|
||||
if (!hasFine && !hasCoarse) {
|
||||
locationPermissionLauncher.launch(
|
||||
arrayOf(
|
||||
Manifest.permission.ACCESS_FINE_LOCATION,
|
||||
Manifest.permission.ACCESS_COARSE_LOCATION
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// 每次进入软件,若开启了自动检查更新,则在后台静默检测,发现新版才弹窗
|
||||
LaunchedEffect(Unit) {
|
||||
if (AppPreferences.isAutoCheckUpdateEnabled) {
|
||||
val result = UpdateChecker.checkUpdate(currentVersion = "v1.0.0")
|
||||
val result = UpdateChecker.checkUpdate(currentVersion = "v1.1.0")
|
||||
result.getOrNull()?.let { info ->
|
||||
if (info.hasUpdate) {
|
||||
updateInfoToDisplay = info
|
||||
@@ -73,12 +105,12 @@ fun MainScreen(
|
||||
|
||||
val checkingUpdateText = stringResource(id = R.string.home_checking_update)
|
||||
val checkFailedText = stringResource(id = R.string.home_check_update_failed)
|
||||
val alreadyLatestText = stringResource(id = R.string.home_already_latest, "v1.0.0")
|
||||
val alreadyLatestText = stringResource(id = R.string.home_already_latest, "v1.1.0")
|
||||
|
||||
val performManualCheck: () -> Unit = {
|
||||
Toast.makeText(context, checkingUpdateText, Toast.LENGTH_SHORT).show()
|
||||
coroutineScope.launch {
|
||||
val result = UpdateChecker.checkUpdate(currentVersion = "v1.0.0")
|
||||
val result = UpdateChecker.checkUpdate(currentVersion = "v1.1.0")
|
||||
result.onSuccess { info ->
|
||||
if (info.hasUpdate) {
|
||||
updateInfoToDisplay = info
|
||||
|
||||
@@ -58,7 +58,7 @@ fun HomeScreen(
|
||||
|
||||
// 4. 版本与更新模块卡片
|
||||
VersionCard(
|
||||
versionName = "v1.0.0",
|
||||
versionName = "v1.1.0",
|
||||
isAutoCheckEnabled = AppPreferences.isAutoCheckUpdateEnabled,
|
||||
onAutoCheckChange = { AppPreferences.updateAutoCheckUpdateEnabled(it) },
|
||||
onCheckUpdate = onCheckUpdate
|
||||
|
||||
@@ -361,7 +361,7 @@ fun LocationScreen(
|
||||
}
|
||||
}
|
||||
|
||||
// 权限请求器(仅在用户点击“回到原位”按钮时按需触发)
|
||||
// 权限请求器(用户点击“回到原位”按钮或首次进入时按需触发)
|
||||
val permissionLauncher = rememberLauncherForActivityResult(
|
||||
ActivityResultContracts.RequestMultiplePermissions()
|
||||
) { permissions ->
|
||||
@@ -372,6 +372,15 @@ fun LocationScreen(
|
||||
}
|
||||
}
|
||||
|
||||
// 若已获得定位权限且用户从未手动挑选过位置,自动校准定位至当前设备物理位置
|
||||
LaunchedEffect(Unit) {
|
||||
val hasFine = ContextCompat.checkSelfPermission(context, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED
|
||||
val hasCoarse = ContextCompat.checkSelfPermission(context, Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED
|
||||
if ((hasFine || hasCoarse) && !AppPreferences.hasUserSetLocation) {
|
||||
locateToDeviceRealPosition(animate = false)
|
||||
}
|
||||
}
|
||||
|
||||
Box(
|
||||
modifier = modifier.fillMaxSize()
|
||||
) {
|
||||
|
||||
@@ -162,14 +162,15 @@
|
||||
<string name="settings_anti_network_desc">脱敏基站小区与 Wi-Fi BSSID,拦截运营商基站监听,杜绝云端指纹库反查真实物理地址</string>
|
||||
<string name="settings_anti_sensor_title">传感器手持生理拟真</string>
|
||||
<string name="settings_anti_sensor_desc">向加速度计注入生物力学生理微颤,打破桌面绝对静止特征,满足步态与姿态校验</string>
|
||||
<string name="settings_anti_stealth_title">堆栈与模块自隐匿</string>
|
||||
<string name="settings_anti_stealth_desc">过滤调用栈中的 Xposed 与 OpenLoc 栈帧,并对目标应用隐藏模块包名</string>
|
||||
<string name="settings_anti_dev_title">开发者选项伪装</string>
|
||||
<string name="settings_anti_dev_desc">对目标应用伪装为未开启开发者模式、未开启 USB 调试与未开启模拟位置</string>
|
||||
<string name="settings_anti_stealth_title">模块包名自隐匿</string>
|
||||
<string name="settings_anti_stealth_desc">对目标应用隐藏 OpenLoc 安装包名,防止通过 PackageManager 探测模块存在</string>
|
||||
<string name="settings_anti_dev_title">底层模拟标志脱敏</string>
|
||||
<string name="settings_anti_dev_desc">在对象内存中实时抹除 isMock 与 mIsFromMockProvider 标志,消除模拟痕迹</string>
|
||||
|
||||
|
||||
<!-- 版本与更新 -->
|
||||
<string name="home_version_card_title">当前版本</string>
|
||||
<string name="home_version_name">v1.0.0</string>
|
||||
<string name="home_version_name">v1.1.0</string>
|
||||
<string name="home_check_updates_btn">检查更新</string>
|
||||
<string name="home_auto_check_update_title">启动时自动检查更新</string>
|
||||
<string name="home_auto_check_update_desc">每次进入软件自动联网检测 GitHub 最新版本</string>
|
||||
|
||||
@@ -162,14 +162,15 @@
|
||||
<string name="settings_anti_network_desc">脱敏基站小区与 Wi-Fi BSSID,拦截运营商基站监听,杜绝云端指纹库反查真实物理地址</string>
|
||||
<string name="settings_anti_sensor_title">传感器手持生理拟真</string>
|
||||
<string name="settings_anti_sensor_desc">向加速度计注入生物力学生理微颤,打破桌面绝对静止特征,满足步态与姿态校验</string>
|
||||
<string name="settings_anti_stealth_title">堆栈与模块自隐匿</string>
|
||||
<string name="settings_anti_stealth_desc">过滤调用栈中的 Xposed 与 OpenLoc 栈帧,并对目标应用隐藏模块包名</string>
|
||||
<string name="settings_anti_dev_title">开发者选项伪装</string>
|
||||
<string name="settings_anti_dev_desc">对目标应用伪装为未开启开发者模式、未开启 USB 调试与未开启模拟位置</string>
|
||||
<string name="settings_anti_stealth_title">模块包名自隐匿</string>
|
||||
<string name="settings_anti_stealth_desc">对目标应用隐藏 OpenLoc 安装包名,防止通过 PackageManager 探测模块存在</string>
|
||||
<string name="settings_anti_dev_title">底层模拟标志脱敏</string>
|
||||
<string name="settings_anti_dev_desc">在对象内存中实时抹除 isMock 与 mIsFromMockProvider 标志,消除模拟痕迹</string>
|
||||
|
||||
|
||||
<!-- 版本与更新 -->
|
||||
<string name="home_version_card_title">当前版本</string>
|
||||
<string name="home_version_name">v1.0.0</string>
|
||||
<string name="home_version_name">v1.1.0</string>
|
||||
<string name="home_check_updates_btn">检查更新</string>
|
||||
<string name="home_auto_check_update_title">启动时自动检查更新</string>
|
||||
<string name="home_auto_check_update_desc">每次进入软件自动联网检测 GitHub 最新版本</string>
|
||||
|
||||
@@ -162,14 +162,15 @@
|
||||
<string name="settings_anti_network_desc">Camouflage cell tower and Wi-Fi BSSID to prevent cloud reverse geolocation lookup</string>
|
||||
<string name="settings_anti_sensor_title">Handheld Motion Sensor Simulation</string>
|
||||
<string name="settings_anti_sensor_desc">Inject subtle physiological micro-tremor into accelerometer readings to mimic active human hand-holding</string>
|
||||
<string name="settings_anti_stealth_title">Stack Trace & Module Stealth</string>
|
||||
<string name="settings_anti_stealth_desc">Sanitize call stack traces (filter Xposed/OpenLoc frames) and hide module package from target apps</string>
|
||||
<string name="settings_anti_dev_title">Developer Settings Camouflage</string>
|
||||
<string name="settings_anti_dev_desc">Disguise developer mode, USB debugging, and mock location as disabled for target apps</string>
|
||||
<string name="settings_anti_stealth_title">Module Package Stealth</string>
|
||||
<string name="settings_anti_stealth_desc">Hide OpenLoc package from target apps to prevent package scanning detection</string>
|
||||
<string name="settings_anti_dev_title">Mock Flag Sanitization</string>
|
||||
<string name="settings_anti_dev_desc">Sanitize isMock and mIsFromMockProvider flags in Location objects</string>
|
||||
|
||||
|
||||
<!-- Version & Updates -->
|
||||
<string name="home_version_card_title">Current Version</string>
|
||||
<string name="home_version_name">v1.0.0</string>
|
||||
<string name="home_version_name">v1.1.0</string>
|
||||
<string name="home_check_updates_btn">Check for Updates</string>
|
||||
<string name="home_auto_check_update_title">Auto Check on Launch</string>
|
||||
<string name="home_auto_check_update_desc">Automatically check for new releases when opening the app</string>
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
package com.lzxnone.openloc
|
||||
|
||||
import com.lzxnone.openloc.hook.interceptor.AntiDetectionHook
|
||||
import com.lzxnone.openloc.hook.model.MockConfig
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
|
||||
class HookSafetyTest {
|
||||
|
||||
@Test
|
||||
fun testMockConfigGlobalMode() {
|
||||
val config = MockConfig(
|
||||
isEnabled = true,
|
||||
mode = "GLOBAL"
|
||||
)
|
||||
assertTrue(config.shouldMock("com.tencent.mm"))
|
||||
assertTrue(config.shouldMock("com.autonavi.minimap"))
|
||||
assertTrue(config.shouldMock("any.package.name"))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testMockConfigDisabled() {
|
||||
val config = MockConfig(
|
||||
isEnabled = false,
|
||||
mode = "GLOBAL"
|
||||
)
|
||||
assertFalse(config.shouldMock("com.tencent.mm"))
|
||||
assertFalse(config.shouldMock("any.package.name"))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testMockConfigWhitelistMode() {
|
||||
val config = MockConfig(
|
||||
isEnabled = true,
|
||||
mode = "WHITELIST",
|
||||
whitelist = setOf("com.tencent.mm", "com.eg.android.AlipayGphone")
|
||||
)
|
||||
assertTrue(config.shouldMock("com.tencent.mm"))
|
||||
assertTrue(config.shouldMock("com.eg.android.AlipayGphone"))
|
||||
assertFalse(config.shouldMock("com.autonavi.minimap"))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testMockConfigBlacklistMode() {
|
||||
val config = MockConfig(
|
||||
isEnabled = true,
|
||||
mode = "BLACKLIST",
|
||||
blacklist = setOf("com.google.android.gms")
|
||||
)
|
||||
assertFalse(config.shouldMock("com.google.android.gms"))
|
||||
assertTrue(config.shouldMock("com.tencent.mm"))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testDangerousHooksAreCompletelyRemoved() {
|
||||
val clazz = AntiDetectionHook::class.java
|
||||
val methodNames = clazz.declaredMethods.map { it.name }
|
||||
|
||||
// Ensure fatal bootloop hooks are NOT present
|
||||
assertFalse("hookStackTrace must be completely removed", methodNames.contains("hookStackTrace"))
|
||||
assertFalse("hookSettingsCamouflage must be completely removed", methodNames.contains("hookSettingsCamouflage"))
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user