Skip to content

Commit 3eb4412

Browse files
committed
Initialize DEVICE_INITIAL_SDK_INT
* Move changing ro.product.first_api_level from global namespace to GMS only * Set "walleye" as fake device (Google bug -> STRONG)
1 parent 4afc912 commit 3eb4412

File tree

5 files changed

+36
-29
lines changed

5 files changed

+36
-29
lines changed

java/app/src/main/java/dev/kdrag0n/safetynetfix/EntryPoint.kt

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ object EntryPoint {
77
try {
88
logDebug("Entry point: Initializing SafetyNet patches")
99
SecurityHooks.init()
10+
InitSdk.init()
1011
} catch (e: Throwable) {
1112
// Throwing an exception would require the JNI code to handle exceptions, so just catch
1213
// everything here.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package dev.kdrag0n.safetynetfix
2+
3+
import android.os.Build
4+
import dev.kdrag0n.safetynetfix.logDebug
5+
6+
internal object InitSdk {
7+
fun init() {
8+
val patchedFirstApiLevel = Build.VERSION_CODES.O
9+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
10+
logDebug("Patch DEVICE_INITIAL_SDK_INT prop. Set it to: $patchedFirstApiLevel")
11+
@Suppress("BlockedPrivateApi")
12+
Build.VERSION::class.java.getDeclaredField("DEVICE_INITIAL_SDK_INT").let { field ->
13+
field.isAccessible = true
14+
field.set(null, patchedFirstApiLevel)
15+
}
16+
}
17+
}
18+
}

java/app/src/main/java/dev/kdrag0n/safetynetfix/proxy/ProxyProvider.kt

+9-17
Original file line numberDiff line numberDiff line change
@@ -21,37 +21,29 @@ class ProxyProvider(
2121

2222
override fun getService(type: String?, algorithm: String?): Service? {
2323
logDebug("Provider: get service - type=$type algorithm=$algorithm")
24-
val host = Build.HOST
25-
if (type == "KeyStore" && host != "xiaomi.eu") {
24+
if (type == "KeyStore" && Build.HOST != "xiaomi.eu") {
2625

27-
val origProduct = Build.PRODUCT
28-
val patchedProduct = "marlin"
26+
val patchedProduct = "walleye"
27+
val patchedDevice = "walleye"
28+
val patchedModel = "Pixel 2"
29+
val patchedFingerprint = "google/walleye/walleye:8.1.0/OPM1.171019.011/4448085:user/release-keys"
2930

30-
val origDevice = Build.DEVICE
31-
val patchedDevice = "marlin"
32-
33-
val origModel = Build.MODEL
34-
val patchedModel = "Pixel XL"
35-
36-
val origFingerprint = Build.FINGERPRINT
37-
val patchedFingerprint = "google/marlin/marlin:7.1.2/NJH47F/4146041:user/release-keys"
38-
39-
logDebug("Patch PRODUCT for KeyStore $origProduct -> $patchedProduct")
31+
logDebug("Patch PRODUCT prop. Set it to: $patchedProduct")
4032
Build::class.java.getDeclaredField("PRODUCT").let { field ->
4133
field.isAccessible = true
4234
field.set(null, patchedProduct)
4335
}
44-
logDebug("Patch DEVICE for KeyStore $origDevice -> $patchedDevice")
36+
logDebug("Patch DEVICE prop. Set it to: $patchedDevice")
4537
Build::class.java.getDeclaredField("DEVICE").let { field ->
4638
field.isAccessible = true
4739
field.set(null, patchedDevice)
4840
}
49-
logDebug("Patch MODEL for KeyStore $origModel -> $patchedModel")
41+
logDebug("Patch MODEL prop. Set it to: $patchedModel")
5042
Build::class.java.getDeclaredField("MODEL").let { field ->
5143
field.isAccessible = true
5244
field.set(null, patchedModel)
5345
}
54-
logDebug("Patch FINGERPRINT for KeyStore $origFingerprint -> $patchedFingerprint")
46+
logDebug("Patch FINGERPRINT prop. Set it to: $patchedFingerprint")
5547
Build::class.java.getDeclaredField("FINGERPRINT").let { field ->
5648
field.isAccessible = true
5749
field.set(null, patchedFingerprint)

magisk/post-fs-data.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22

33
# Remove Play Services from the Magisk Denylist when set to enforcing.
44
if magisk --denylist status; then
5-
magisk --denylist rm com.google.android.gms
5+
magisk --denylist rm com.google.android.gms
66
fi

magisk/service.sh

+7-11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/system/bin/sh
2-
# Conditional MagiskHide properties
2+
# Sensitive properties
33

44
maybe_set_prop() {
55
local prop="$1"
@@ -16,9 +16,10 @@ maybe_set_prop ro.bootmode recovery unknown
1616
maybe_set_prop ro.boot.mode recovery unknown
1717
maybe_set_prop vendor.boot.mode recovery unknown
1818

19+
# Hiding SELinux | Permissive status
1920
resetprop --delete ro.build.selinux
2021

21-
# SELinux permissive | use toybox to protect stat access time
22+
# Hiding SELinux | Use toybox to protect *stat* access time reading
2223
if [[ "$(toybox cat /sys/fs/selinux/enforce)" == "0" ]]; then
2324
chmod 640 /sys/fs/selinux/enforce
2425
chmod 440 /sys/fs/selinux/policy
@@ -30,22 +31,17 @@ fi
3031
sleep 1
3132
done
3233

33-
# Avoid breaking Realme fingerprint scanners
34+
# SafetyNet/Play Integrity | Avoid breaking Realme fingerprint scanners
3435
resetprop ro.boot.flash.locked 1
3536

36-
# Avoid breaking Oppo fingerprint scanners
37+
# SafetyNet/Play Integrity | Avoid breaking Oppo fingerprint scanners
3738
resetprop ro.boot.vbmeta.device_state locked
3839

39-
# Avoid breaking OnePlus display modes/fingerprint scanners
40+
# SafetyNet/Play Integrity | Avoid breaking OnePlus display modes/fingerprint scanners
4041
resetprop vendor.boot.verifiedbootstate green
4142

42-
# Safetynet (avoid breaking OnePlus display modes/fingerprint scanners on OOS 12)
43+
# SafetyNet/Play Integrity | Avoid breaking OnePlus display modes/fingerprint scanners on OOS 12
4344
resetprop ro.boot.verifiedbootstate green
4445
resetprop ro.boot.veritymode enforcing
4546
resetprop vendor.boot.vbmeta.device_state locked
46-
47-
# Avoid breaking encryption, set shipping level to 32 for devices >=33 to allow for software attestation
48-
if [[ "$(getprop ro.product.first_api_level)" -ge 33 ]]; then
49-
resetprop ro.product.first_api_level 32
50-
fi
5147
}&

0 commit comments

Comments
 (0)