commit beb52174047f08029e3d8cd106cb61deb61714ca
parent 574775f65c3790a42d97d45cc2d257d34353addf
Author: rhunk <101876869+rhunk@users.noreply.github.com>
Date: Sun, 6 Oct 2024 11:43:42 +0200
feat(security_features): mod detection version check
This feature tells users who are using more recent/latest versions to use earlier versions, because after version 12.81.0.44 (126022), Snapchat now detects changes made to the app
Diffstat:
4 files changed, 27 insertions(+), 35 deletions(-)
diff --git a/app/src/main/kotlin/me/rhunk/snapenhance/ui/manager/pages/home/HomeSettings.kt b/app/src/main/kotlin/me/rhunk/snapenhance/ui/manager/pages/home/HomeSettings.kt
@@ -18,7 +18,6 @@ import androidx.compose.ui.window.Dialog
import androidx.core.net.toUri
import androidx.navigation.NavBackStackEntry
import kotlinx.coroutines.launch
-import me.rhunk.snapenhance.common.Constants
import me.rhunk.snapenhance.common.action.EnumAction
import me.rhunk.snapenhance.common.bridge.InternalFileHandleType
import me.rhunk.snapenhance.common.ui.rememberAsyncMutableState
@@ -60,7 +59,7 @@ class HomeSettings : Routes.Route() {
horizontalArrangement = Arrangement.SpaceBetween,
verticalAlignment = Alignment.CenterVertically
) {
- Text(text = text)
+ Text(text = text, modifier = Modifier.padding(end = 16.dp), fontSize = 14.sp)
Switch(checked = value, onCheckedChange = {
value = it
sharedPreferences.edit().putBoolean(realKey, it).apply()
@@ -288,6 +287,7 @@ class HomeSettings : Routes.Route() {
PreferenceToggle(context.sharedPreferences, key = "disable_feature_loading", text = "Disable Feature Loading")
PreferenceToggle(context.sharedPreferences, key = "disable_mapper", text = "Disable Auto Mapper")
PreferenceToggle(context.sharedPreferences, key = "disable_sif", text = "Disable Security Features")
+ PreferenceToggle(context.sharedPreferences, key = "disable_mod_detection_version_check", text = "Disable Mod Detection Version Check")
}
}
Spacer(modifier = Modifier.height(50.dp))
diff --git a/common/src/main/kotlin/me/rhunk/snapenhance/common/config/ConfigConstants.kt b/common/src/main/kotlin/me/rhunk/snapenhance/common/config/ConfigConstants.kt
@@ -3,4 +3,9 @@ package me.rhunk.snapenhance.common.config
/*
Due to recent resource obfuscation, some UI features will no longer work because it depends on non obfuscated resources
*/
-val RES_OBF_VERSION_CHECK = VersionCheck(maxVersion = ("13.7.0.42" to 157172))-
\ No newline at end of file
+val RES_OBF_VERSION_CHECK = VersionCheck(maxVersion = ("13.7.0.42" to 157172))
+
+/*
+ After this version, Snapchat will start detecting modifications to their app (to be confirmed)
+*/
+val MOD_DETECTION_VERSION_CHECK = VersionCheck(maxVersion = ("12.81.0.44 (126022)" to 126023))+
\ No newline at end of file
diff --git a/core/src/main/kotlin/me/rhunk/snapenhance/core/features/impl/SecurityFeatures.kt b/core/src/main/kotlin/me/rhunk/snapenhance/core/features/impl/SecurityFeatures.kt
@@ -2,23 +2,19 @@ package me.rhunk.snapenhance.core.features.impl
import android.annotation.SuppressLint
import android.system.Os
-import android.widget.TextView
-import androidx.compose.ui.graphics.Color
-import androidx.compose.ui.graphics.toArgb
-import kotlinx.coroutines.Dispatchers
-import kotlinx.coroutines.delay
-import kotlinx.coroutines.launch
-import kotlinx.coroutines.withContext
+import androidx.compose.material.icons.Icons
+import androidx.compose.material.icons.filled.NotInterested
+import me.rhunk.snapenhance.common.config.MOD_DETECTION_VERSION_CHECK
+import me.rhunk.snapenhance.common.config.VersionRequirement
import me.rhunk.snapenhance.common.util.protobuf.ProtoEditor
import me.rhunk.snapenhance.common.util.protobuf.ProtoReader
import me.rhunk.snapenhance.core.event.events.impl.UnaryCallEvent
import me.rhunk.snapenhance.core.features.Feature
-import me.rhunk.snapenhance.core.util.ktx.getId
import me.rhunk.snapenhance.core.util.ktx.setObjectField
import java.io.FileDescriptor
class SecurityFeatures : Feature("Security Features") {
- private fun transact(option: Int, option2: Long) = kotlin.runCatching { Os.prctl(option, option2, 0, 0, 0) }.getOrNull()
+ private fun transact(option: Int, option2: Long) = runCatching { Os.prctl(option, option2, 0, 0, 0) }.getOrNull()
private val token by lazy {
transact(0, 0)
@@ -71,28 +67,18 @@ class SecurityFeatures : Feature("Security Features") {
}
}
- val hovaPageTitleId = context.resources.getId("hova_page_title")
+ val status = getStatus()
+ val canCheckVersion = context.bridgeClient.getDebugProp("disable_mod_detection_version_check", "false") != "true"
+ val snapchatVersionCode = context.androidContext.packageManager.getPackageInfo(context.androidContext.packageName, 0).longVersionCode
- fun findHovaPageTitle(): TextView? {
- return context.mainActivity?.findViewById(hovaPageTitleId)
- }
-
- context.coroutineScope.launch {
- while (true) {
- val status = getStatus()
- withContext(Dispatchers.Main) {
- val textView = findHovaPageTitle() ?: return@withContext
- if (status == null || status == 0) {
- textView.text = "SIF not loaded"
- textView.textSize = 13F
- textView.setTextColor(Color.Red.toArgb())
- } else {
- textView.setTextColor(Color.Green.toArgb())
- val prefix = textView.text.toString().substringBeforeLast(" (")
- textView.text = "$prefix (${status})"
- }
- }
- delay(1000)
+ if (canCheckVersion && MOD_DETECTION_VERSION_CHECK.checkVersion(snapchatVersionCode)?.second == VersionRequirement.OLDER_REQUIRED && (status == null || status < 2)) {
+ onNextActivityCreate {
+ context.inAppOverlay.showStatusToast(
+ icon = Icons.Filled.NotInterested,
+ text = "SnapEnhance is not compatible with this version of Snapchat without SIF and will result in a ban.\nUse Snapchat ${MOD_DETECTION_VERSION_CHECK.maxVersion?.first ?: "0.0.0"} or older to avoid detections or use test accounts.",
+ durationMs = 10000,
+ maxLines = 6
+ )
}
}
}
diff --git a/core/src/main/kotlin/me/rhunk/snapenhance/core/ui/InAppOverlay.kt b/core/src/main/kotlin/me/rhunk/snapenhance/core/ui/InAppOverlay.kt
@@ -255,11 +255,12 @@ class InAppOverlay(
text: String,
durationMs: Int = 2000,
showDuration: Boolean = true,
+ maxLines: Int = 3
) {
showToast(
icon = { Icon(icon, contentDescription = "icon", modifier = Modifier.size(32.dp)) },
text = {
- Text(text, modifier = Modifier.fillMaxWidth(), maxLines = 3, overflow = TextOverflow.Ellipsis, lineHeight = 15.sp, fontSize = 15.sp)
+ Text(text, modifier = Modifier.fillMaxWidth(), maxLines = maxLines, overflow = TextOverflow.Ellipsis, lineHeight = 15.sp, fontSize = 15.sp)
},
durationMs = durationMs,
showDuration = showDuration