From 2f56b7320cdacf97758d2283e75454505f6e3737 Mon Sep 17 00:00:00 2001 From: Danny Lin Date: Mon, 6 Sep 2021 03:43:04 -0700 Subject: [PATCH] java: Append space character to device model name This bypasses Google's new device-based hardware attestation enforcement as of September 2, 2021. --- .../java/dev/kdrag0n/safetynetriru/BuildHooks.kt | 13 +++++++++++++ .../java/dev/kdrag0n/safetynetriru/EntryPoint.kt | 3 ++- 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 java_module/app/src/main/java/dev/kdrag0n/safetynetriru/BuildHooks.kt diff --git a/java_module/app/src/main/java/dev/kdrag0n/safetynetriru/BuildHooks.kt b/java_module/app/src/main/java/dev/kdrag0n/safetynetriru/BuildHooks.kt new file mode 100644 index 0000000..8e9f082 --- /dev/null +++ b/java_module/app/src/main/java/dev/kdrag0n/safetynetriru/BuildHooks.kt @@ -0,0 +1,13 @@ +package dev.kdrag0n.safetynetriru + +import android.os.Build + +internal object BuildHooks { + fun init() { + // Append a space to the device model name + Build::class.java.getDeclaredField("MODEL").let { field -> + field.isAccessible = true + field.set(null, Build.MODEL + " ") + } + } +} diff --git a/java_module/app/src/main/java/dev/kdrag0n/safetynetriru/EntryPoint.kt b/java_module/app/src/main/java/dev/kdrag0n/safetynetriru/EntryPoint.kt index 625487a..baf294a 100644 --- a/java_module/app/src/main/java/dev/kdrag0n/safetynetriru/EntryPoint.kt +++ b/java_module/app/src/main/java/dev/kdrag0n/safetynetriru/EntryPoint.kt @@ -5,8 +5,9 @@ object EntryPoint { @JvmStatic fun init() { runCatching { - logDebug("Entry point: Initializing SafetyNet patch") + logDebug("Entry point: Initializing SafetyNet patches") SecurityBridge.init() + BuildHooks.init() }.recoverCatching { e -> // Throwing an exception would require the JNI code to handle exceptions, so just catch // everything here.