Add SECURITY_PATCH and fix null props

This commit is contained in:
chiteroman
2023-11-21 14:04:33 +01:00
parent bf9ce4eb73
commit abc57e0a46
11 changed files with 73 additions and 117 deletions
@@ -60,10 +60,17 @@ public final class EntryPoint {
}
public static void spoofDevice() {
props.forEach((field, value) -> setProp((String) field, (String) value));
setProp("PRODUCT", props.getProperty("PRODUCT"));
setProp("DEVICE", props.getProperty("DEVICE"));
setProp("MANUFACTURER", props.getProperty("MANUFACTURER"));
setProp("BRAND", props.getProperty("BRAND"));
setProp("MODEL", props.getProperty("MODEL"));
setProp("FINGERPRINT", props.getProperty("FINGERPRINT"));
setVersionProp("SECURITY_PATCH", props.getProperty("SECURITY_PATCH"));
}
private static void setProp(String name, String value) {
if (name == null || value == null || name.isEmpty() || value.isEmpty()) return;
try {
Field field = Build.class.getDeclaredField(name);
field.setAccessible(true);
@@ -79,6 +86,23 @@ public final class EntryPoint {
}
}
private static void setVersionProp(String name, String value) {
if (name == null || value == null || name.isEmpty() || value.isEmpty()) return;
try {
Field field = Build.VERSION.class.getDeclaredField(name);
field.setAccessible(true);
String oldValue = (String) field.get(null);
field.set(null, value);
field.setAccessible(false);
if (value.equals(oldValue)) return;
LOG(String.format("[%s]: %s -> %s", name, oldValue, value));
} catch (NoSuchFieldException e) {
LOG(String.format("Couldn't find '%s' field name.", name));
} catch (IllegalAccessException e) {
LOG(String.format("Couldn't modify '%s' field value.", name));
}
}
public static void LOG(String msg) {
Log.d("PIF/Java", msg);
}