From c1f1c77811f1e450f2442e069679562db96498d9 Mon Sep 17 00:00:00 2001 From: chiteroman <98092901+chiteroman@users.noreply.github.com> Date: Sun, 3 Dec 2023 14:32:47 +0100 Subject: [PATCH] Test v14.1 --- app/src/main/cpp/main.cpp | 46 ++++++++++++++++++++++------------- module/customize.sh | 6 ----- module/service.sh | 3 +++ module_resetprop/customize.sh | 6 ----- module_resetprop/service.sh | 3 +++ pif.json | 10 ++++++++ 6 files changed, 45 insertions(+), 29 deletions(-) create mode 100644 pif.json diff --git a/app/src/main/cpp/main.cpp b/app/src/main/cpp/main.cpp index 55f5d87..e982ad5 100644 --- a/app/src/main/cpp/main.cpp +++ b/app/src/main/cpp/main.cpp @@ -12,7 +12,7 @@ #define JSON_FILE_PATH "/data/adb/pif.json" -#define DEFAULT_FIRST_API_LEVEL "23" +#define JSON_TEMP_FILE "/data/adb/modules/playintegrityfix/temp" static std::string FIRST_API_LEVEL, SECURITY_PATCH; @@ -29,19 +29,16 @@ static void modify_callback(void *cookie, const char *name, const char *value, u std::string_view prop(name); if (prop.ends_with("api_level")) { - if (FIRST_API_LEVEL.empty()) { - LOGD("[%s]: %s -> %s", name, value, DEFAULT_FIRST_API_LEVEL); - return callbacks[cookie](cookie, name, DEFAULT_FIRST_API_LEVEL, serial); - } else { - LOGD("[%s]: %s -> %s", name, value, FIRST_API_LEVEL.c_str()); - return callbacks[cookie](cookie, name, FIRST_API_LEVEL.c_str(), serial); + if (!FIRST_API_LEVEL.empty()) { + value = FIRST_API_LEVEL.c_str(); + LOGD("[%s]: %s", name, value); } } if (prop.ends_with("security_patch")) { if (!SECURITY_PATCH.empty()) { - LOGD("[%s]: %s -> %s", name, value, SECURITY_PATCH.c_str()); - return callbacks[cookie](cookie, name, SECURITY_PATCH.c_str(), serial); + value = SECURITY_PATCH.c_str(); + LOGD("[%s]: %s", name, value); } } @@ -238,17 +235,32 @@ static void companion(int fd) { fclose(dex); } - FILE *json = fopen(JSON_FILE_PATH, "r"); + if (std::filesystem::exists(JSON_FILE_PATH)) { + FILE *json = fopen(JSON_FILE_PATH, "rb"); - if (json) { - fseek(json, 0, SEEK_END); - jsonSize = ftell(json); - fseek(json, 0, SEEK_SET); + if (json) { + fseek(json, 0, SEEK_END); + jsonSize = ftell(json); + fseek(json, 0, SEEK_SET); - jsonVector.resize(jsonSize); - fread(jsonVector.data(), 1, jsonSize, json); + jsonVector.resize(jsonSize); + fread(jsonVector.data(), 1, jsonSize, json); - fclose(json); + fclose(json); + } + } else if (std::filesystem::exists(JSON_TEMP_FILE)) { + FILE *json = fopen(JSON_TEMP_FILE, "rb"); + + if (json) { + fseek(json, 0, SEEK_END); + jsonSize = ftell(json); + fseek(json, 0, SEEK_SET); + + jsonVector.resize(jsonSize); + fread(jsonVector.data(), 1, jsonSize, json); + + fclose(json); + } } write(fd, &dexSize, sizeof(long)); diff --git a/module/customize.sh b/module/customize.sh index 9de2fea..43ed0ef 100644 --- a/module/customize.sh +++ b/module/customize.sh @@ -3,12 +3,6 @@ if [ "$API" -lt 26 ]; then abort "!!! You can't use this module on Android < 8.0" fi -# Copy default pif.json if it doesn't exist. -if [ ! -e /data/adb/pif.json ]; then - cp -af $MODPATH/pif.json /data/adb/pif.json - ui_print "Moved default pif.json file!" -fi - # SafetyNet-Fix module is obsolete and it's incompatible with PIF. if [ -d /data/adb/modules/safetynet-fix ]; then touch /data/adb/modules/safetynet-fix/remove diff --git a/module/service.sh b/module/service.sh index ec1d1f8..ee63f7d 100644 --- a/module/service.sh +++ b/module/service.sh @@ -1,3 +1,6 @@ +# Remove temp file +rm -f /data/adb/modules/playintegrityfix/temp + # Conditional sensitive properties resetprop_if_diff() { diff --git a/module_resetprop/customize.sh b/module_resetprop/customize.sh index d64705f..1a56b3e 100644 --- a/module_resetprop/customize.sh +++ b/module_resetprop/customize.sh @@ -3,12 +3,6 @@ if [ "$API" -lt 26 ]; then abort "!!! You can't use this module on Android < 8.0" fi -# Copy default pif.json if it doesn't exist. -if [ ! -e /data/adb/pif.json ]; then - cp -af $MODPATH/pif.json /data/adb/pif.json - ui_print "- Moved default pif.json file!" -fi - # SafetyNet-Fix module is obsolete and it's incompatible with PIF. if [ -d /data/adb/modules/safetynet-fix ]; then touch /data/adb/modules/safetynet-fix/remove diff --git a/module_resetprop/service.sh b/module_resetprop/service.sh index 809dafa..c161eb7 100644 --- a/module_resetprop/service.sh +++ b/module_resetprop/service.sh @@ -1,3 +1,6 @@ +# Remove temp file +rm -f /data/adb/modules/playintegrityfix/temp + # Conditional sensitive properties RESETPROP="${0%/*}/resetprop" diff --git a/pif.json b/pif.json new file mode 100644 index 0000000..c042861 --- /dev/null +++ b/pif.json @@ -0,0 +1,10 @@ +{ + "PRODUCT": "WW_Phone", + "DEVICE": "ASUS_Z012D", + "MANUFACTURER": "asus", + "BRAND": "asus", + "MODEL": "ASUS_Z012D", + "FINGERPRINT": "asus/WW_Phone/ASUS_Z012D:7.0/NRD90M/14.2015.1701.8-20170222:user/release-keys", + "SECURITY_PATCH": "2017-01-01", + "FIRST_API_LEVEL": "23" +} \ No newline at end of file