You've already forked PlayIntegrityFork
mirror of
https://github.com/osm0sis/PlayIntegrityFork.git
synced 2025-09-06 06:37:06 +00:00
Add SECURITY_PATCH and fix null props
This commit is contained in:
@@ -19,7 +19,7 @@ android {
|
||||
ndk {
|
||||
//noinspection ChromeOsAbiSupport
|
||||
abiFilters += setOf("armeabi-v7a", "arm64-v8a")
|
||||
jobs = 4
|
||||
jobs = Runtime.getRuntime().availableProcessors()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
#include <jni.h>
|
||||
|
||||
#define ZYGISK_API_VERSION 2
|
||||
#define ZYGISK_API_VERSION 4
|
||||
|
||||
/*
|
||||
|
||||
@@ -142,6 +142,7 @@ struct AppSpecializeArgs {
|
||||
jint &gid;
|
||||
jintArray &gids;
|
||||
jint &runtime_flags;
|
||||
jobjectArray &rlimits;
|
||||
jint &mount_external;
|
||||
jstring &se_info;
|
||||
jstring &nice_name;
|
||||
@@ -149,6 +150,7 @@ struct AppSpecializeArgs {
|
||||
jstring &app_data_dir;
|
||||
|
||||
// Optional arguments. Please check whether the pointer is null before de-referencing
|
||||
jintArray *const fds_to_ignore;
|
||||
jboolean *const is_child_zygote;
|
||||
jboolean *const is_top_app;
|
||||
jobjectArray *const pkg_data_info_list;
|
||||
@@ -241,6 +243,14 @@ struct Api {
|
||||
// Returns bitwise-or'd zygisk::StateFlag values.
|
||||
uint32_t getFlags();
|
||||
|
||||
// Exempt the provided file descriptor from being automatically closed.
|
||||
//
|
||||
// This API only make sense in preAppSpecialize; calling this method in any other situation
|
||||
// is either a no-op (returns true) or an error (returns false).
|
||||
//
|
||||
// When false is returned, the provided file descriptor will eventually be closed by zygote.
|
||||
bool exemptFd(int fd);
|
||||
|
||||
// Hook JNI native methods for a class
|
||||
//
|
||||
// Lookup all registered JNI native methods and replace it with your own methods.
|
||||
@@ -257,13 +267,10 @@ struct Api {
|
||||
// 56b4346000-56b4347000 r-xp 00002000 fe:00 235 /system/bin/app_process64
|
||||
// (More details: https://man7.org/linux/man-pages/man5/proc.5.html)
|
||||
//
|
||||
// For ELFs loaded in memory with pathname matching `regex`, replace function `symbol` with `newFunc`.
|
||||
// The `dev` and `inode` pair uniquely identifies a file being mapped into memory.
|
||||
// For matching ELFs loaded in memory, replace function `symbol` with `newFunc`.
|
||||
// If `oldFunc` is not nullptr, the original function pointer will be saved to `oldFunc`.
|
||||
void pltHookRegister(const char *regex, const char *symbol, void *newFunc, void **oldFunc);
|
||||
|
||||
// For ELFs loaded in memory with pathname matching `regex`, exclude hooks registered for `symbol`.
|
||||
// If `symbol` is nullptr, then all symbols will be excluded.
|
||||
void pltHookExclude(const char *regex, const char *symbol);
|
||||
void pltHookRegister(dev_t dev, ino_t inode, const char *symbol, void *newFunc, void **oldFunc);
|
||||
|
||||
// Commit all the hooks that was previously registered.
|
||||
// Returns false if an error occurred.
|
||||
@@ -324,8 +331,8 @@ struct api_table {
|
||||
bool (*registerModule)(api_table *, module_abi *);
|
||||
|
||||
void (*hookJniNativeMethods)(JNIEnv *, const char *, JNINativeMethod *, int);
|
||||
void (*pltHookRegister)(const char *, const char *, void *, void **);
|
||||
void (*pltHookExclude)(const char *, const char *);
|
||||
void (*pltHookRegister)(dev_t, ino_t, const char *, void *, void **);
|
||||
bool (*exemptFd)(int);
|
||||
bool (*pltHookCommit)();
|
||||
int (*connectCompanion)(void * /* impl */);
|
||||
void (*setOption)(void * /* impl */, Option);
|
||||
@@ -358,14 +365,14 @@ inline void Api::setOption(Option opt) {
|
||||
inline uint32_t Api::getFlags() {
|
||||
return tbl->getFlags ? tbl->getFlags(tbl->impl) : 0;
|
||||
}
|
||||
inline bool Api::exemptFd(int fd) {
|
||||
return tbl->exemptFd != nullptr && tbl->exemptFd(fd);
|
||||
}
|
||||
inline void Api::hookJniNativeMethods(JNIEnv *env, const char *className, JNINativeMethod *methods, int numMethods) {
|
||||
if (tbl->hookJniNativeMethods) tbl->hookJniNativeMethods(env, className, methods, numMethods);
|
||||
}
|
||||
inline void Api::pltHookRegister(const char *regex, const char *symbol, void *newFunc, void **oldFunc) {
|
||||
if (tbl->pltHookRegister) tbl->pltHookRegister(regex, symbol, newFunc, oldFunc);
|
||||
}
|
||||
inline void Api::pltHookExclude(const char *regex, const char *symbol) {
|
||||
if (tbl->pltHookExclude) tbl->pltHookExclude(regex, symbol);
|
||||
inline void Api::pltHookRegister(dev_t dev, ino_t inode, const char *symbol, void *newFunc, void **oldFunc) {
|
||||
if (tbl->pltHookRegister) tbl->pltHookRegister(dev, inode, symbol, newFunc, oldFunc);
|
||||
}
|
||||
inline bool Api::pltHookCommit() {
|
||||
return tbl->pltHookCommit != nullptr && tbl->pltHookCommit();
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user