From 5af55f3b2f2e0598e28bda38efc2ed56f74a7620 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yi=C4=9Fit?= <40565628+tryigit@users.noreply.github.com> Date: Mon, 15 Jan 2024 17:45:50 +0300 Subject: [PATCH 1/2] Update EntryPoint.java --- .../playintegrityfix/EntryPoint.java | 83 ++++++++++--------- 1 file changed, 44 insertions(+), 39 deletions(-) diff --git a/app/src/main/java/es/chiteroman/playintegrityfix/EntryPoint.java b/app/src/main/java/es/chiteroman/playintegrityfix/EntryPoint.java index d1f8cec..da7f36c 100644 --- a/app/src/main/java/es/chiteroman/playintegrityfix/EntryPoint.java +++ b/app/src/main/java/es/chiteroman/playintegrityfix/EntryPoint.java @@ -17,37 +17,38 @@ public final class EntryPoint { static { try { - KeyStore keyStore = KeyStore.getInstance("AndroidKeyStore"); - keyStore.load(null); - - Field f = keyStore.getClass().getDeclaredField("keyStoreSpi"); - f.setAccessible(true); - CustomKeyStoreSpi.keyStoreSpi = (KeyStoreSpi) f.get(keyStore); - f.setAccessible(false); - - Provider provider = Security.getProvider("AndroidKeyStore"); - - Provider customProvider = new CustomProvider(provider); - - Security.removeProvider("AndroidKeyStore"); - Security.insertProviderAt(customProvider, 1); - - LOG("Spoof KeyStoreSpi and Provider done!"); - + spoofProvider(); } catch (Throwable t) { LOG("spoofProvider exception: " + t); } } - public static void init(String json) { + private static void spoofProvider() throws Exception { + KeyStore keyStore = KeyStore.getInstance("AndroidKeyStore"); + keyStore.load(null); + Field f = keyStore.getClass().getDeclaredField("keyStoreSpi"); + f.setAccessible(true); + CustomKeyStoreSpi.keyStoreSpi = (KeyStoreSpi) f.get(keyStore); + f.setAccessible(false); + + Provider provider = Security.getProvider("AndroidKeyStore"); + + Provider customProvider = new CustomProvider(provider); + + Security.removeProvider("AndroidKeyStore"); + Security.insertProviderAt(customProvider, 1); + + LOG("Spoof KeyStoreSpi and Provider done!"); + } + + public static void init(String json) { try { jsonObject = new JSONObject(json); + spoofDevice(); } catch (JSONException e) { LOG("Couldn't parse JSON from Zygisk"); } - - spoofDevice(); } static void LOG(String msg) { @@ -65,10 +66,30 @@ public final class EntryPoint { } private static void setFieldValue(String name, Object value) { - if (name == null || value == null || name.isEmpty()) return; + if (name == null value == null name.isEmpty()) return; if (value instanceof String str) if (str.isEmpty() || str.isBlank()) return; + Field field = getField(name); + + if (field == null) return; + + field.setAccessible(true); + try { + Object oldValue = field.get(null); + + if (!value.equals(oldValue)) { + field.set(null, value); + LOG("Set [" + name + "] field value to [" + value + "]"); + } + + } catch (IllegalAccessException e) { + LOG("Couldn't modify field: " + e); + } + field.setAccessible(false); + } + + private static Field getField(String name) { Field field = null; try { @@ -81,22 +102,6 @@ public final class EntryPoint { } } - if (field == null) return; - - field.setAccessible(true); - try { - - Object oldValue = field.get(null); - - if (!value.equals(oldValue)) { - - field.set(null, value); - LOG("Set [" + name + "] field value to [" + value + "]"); - } - - } catch (IllegalAccessException e) { - LOG("Couldn't modify field: " + e); - } - field.setAccessible(false); + return field; } -} \ No newline at end of file +} From 5e6f43e80d3efc6975154eacef5917fe93c5c5c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yi=C4=9Fit?= <40565628+tryigit@users.noreply.github.com> Date: Mon, 15 Jan 2024 17:48:43 +0300 Subject: [PATCH 2/2] Update EntryPoint.java --- .../main/java/es/chiteroman/playintegrityfix/EntryPoint.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/es/chiteroman/playintegrityfix/EntryPoint.java b/app/src/main/java/es/chiteroman/playintegrityfix/EntryPoint.java index da7f36c..d3acf00 100644 --- a/app/src/main/java/es/chiteroman/playintegrityfix/EntryPoint.java +++ b/app/src/main/java/es/chiteroman/playintegrityfix/EntryPoint.java @@ -66,7 +66,7 @@ public final class EntryPoint { } private static void setFieldValue(String name, Object value) { - if (name == null value == null name.isEmpty()) return; + if (name == null || value == null || name.isEmpty()) return; if (value instanceof String str) if (str.isEmpty() || str.isBlank()) return;