diff --git a/app/src/main/cpp/main.cpp b/app/src/main/cpp/main.cpp index 034ad45..6e9b763 100644 --- a/app/src/main/cpp/main.cpp +++ b/app/src/main/cpp/main.cpp @@ -1,7 +1,6 @@ #include #include #include -#include #include "zygisk.hpp" #include "shadowhook.h" @@ -11,7 +10,7 @@ #define DEX_FILE_PATH "/data/adb/modules/playintegrityfix/classes.dex" -#define PROP_FILE_PATH "/data/adb/modules/playintegrityfix/pif.json" +#define JSON_FILE_PATH "/data/adb/modules/playintegrityfix/pif.json" static std::string FIRST_API_LEVEL, SECURITY_PATCH; @@ -72,27 +71,6 @@ static void doHook() { LOGD("Found '__system_property_read_callback' handle at %p", handle); } -static void sendVector(int fd, const std::vector &vec) { - // Send the size of the vector - size_t size = vec.size(); - write(fd, &size, sizeof(size_t)); - - // Send the vector data - write(fd, vec.data(), size); -} - -static std::vector receiveVector(int fd) { - // Receive the size of the vector - size_t size; - read(fd, &size, sizeof(size_t)); - - // Receive the vector data - std::vector vec(size); - read(fd, vec.data(), size); - - return vec; -} - class PlayIntegrityFix : public zygisk::ModuleBase { public: void onLoad(zygisk::Api *api, JNIEnv *env) override { @@ -124,10 +102,36 @@ public: return; } + long size = 0; int fd = api->connectCompanion(); - dexVector = receiveVector(fd); - propVector = receiveVector(fd); + read(fd, &size, sizeof(long)); + + if (size < 1) { + close(fd); + LOGD("Couldn't read from file descriptor 'classes.dex' file!"); + api->setOption(zygisk::DLCLOSE_MODULE_LIBRARY); + return; + } + + dexVector.resize(size); + + read(fd, dexVector.data(), size); + + size = 0; + + read(fd, &size, sizeof(long)); + + if (size < 1) { + close(fd); + LOGD("Couldn't read from file descriptor 'pif.json' file!"); + api->setOption(zygisk::DLCLOSE_MODULE_LIBRARY); + return; + } + + propVector.resize(size); + + read(fd, propVector.data(), size); close(fd); @@ -135,8 +139,6 @@ public: static_cast(dexVector.size())); LOGD("Read from file descriptor file 'pif.json' -> %d bytes", static_cast(propVector.size())); - - if (dexVector.empty() || propVector.empty()) api->setOption(zygisk::DLCLOSE_MODULE_LIBRARY); } void postAppSpecialize(const zygisk::AppSpecializeArgs *args) override { @@ -211,24 +213,39 @@ private: }; static void companion(int fd) { - std::ifstream dex(DEX_FILE_PATH, std::ios::binary); - std::ifstream prop(PROP_FILE_PATH); + FILE *dex = fopen(DEX_FILE_PATH, "rb"); - std::vector dexVector((std::istreambuf_iterator(dex)), - std::istreambuf_iterator()); - std::vector propVector((std::istreambuf_iterator(prop)), - std::istreambuf_iterator()); + fseek(dex, 0, SEEK_END); + long dexSize = ftell(dex); + fseek(dex, 0, SEEK_SET); - dex.close(); - prop.close(); + char dexBuffer[dexSize]; + fread(dexBuffer, 1, dexSize, dex); - sendVector(fd, dexVector); - sendVector(fd, propVector); + fclose(dex); - dexVector.clear(); - propVector.clear(); + FILE *json = fopen(JSON_FILE_PATH, "r"); + + fseek(json, 0, SEEK_END); + long jsonSize = ftell(json); + fseek(json, 0, SEEK_SET); + + char jsonBuffer[jsonSize]; + fread(jsonBuffer, 1, jsonSize, json); + + fclose(json); + + dexBuffer[dexSize] = 0; + jsonBuffer[jsonSize] = 0; + + write(fd, &dexSize, sizeof(long)); + write(fd, dexBuffer, dexSize); + + write(fd, &jsonSize, sizeof(long)); + write(fd, jsonBuffer, jsonSize); } + REGISTER_ZYGISK_MODULE(PlayIntegrityFix) REGISTER_ZYGISK_COMPANION(companion) \ No newline at end of file diff --git a/module/bin/x86/resetprop b/module/bin/x86/resetprop deleted file mode 100644 index b479c19..0000000 Binary files a/module/bin/x86/resetprop and /dev/null differ diff --git a/module/bin/x86_64/resetprop b/module/bin/x86_64/resetprop deleted file mode 100644 index 5b8dec7..0000000 Binary files a/module/bin/x86_64/resetprop and /dev/null differ diff --git a/module/customize.sh b/module/customize.sh index 2c09f41..a6d50c0 100644 --- a/module/customize.sh +++ b/module/customize.sh @@ -6,9 +6,13 @@ fi # safetynet-fix module is incompatible if [ -d "/data/adb/modules/safetynet-fix" ]; then touch "/data/adb/modules/safetynet-fix/remove" - ui_print "!!! safetynet-fix module removed!" + ui_print "- 'safetynet-fix' module will be removed in next reboot." +fi + +# Use custom resetprop only in Android 10+ +if [ "$API" -gt 28 ]; then + mv -f "$MODPATH/bin/$ABI/resetprop" "$MODPATH" + ui_print "- Using custom resetprop to avoid detections." fi -# use our resetprop -mv -f "$MODPATH/bin/$ABI/resetprop" "$MODPATH" rm -rf "$MODPATH/bin" \ No newline at end of file diff --git a/module/module.prop b/module/module.prop index ff98b47..6c77468 100644 --- a/module/module.prop +++ b/module/module.prop @@ -1,6 +1,7 @@ id=playintegrityfix name=Play Integrity Fix -version=v1.2-PROPS -versionCode=12 +version=v13.8-beta +versionCode=137 author=chiteroman -description=Fix CTS profile (SafetyNet) and DEVICE verdict (Play Integrity). \ No newline at end of file +description=Fix CTS profile (SafetyNet) and DEVICE verdict (Play Integrity). +updateJson=https://raw.githubusercontent.com/chiteroman/PlayIntegrityFix/main/update.json \ No newline at end of file diff --git a/module/service.sh b/module/service.sh index 05b9825..0cdd82a 100644 --- a/module/service.sh +++ b/module/service.sh @@ -2,7 +2,11 @@ RESETPROP="${0%/*}/resetprop" -chmod 755 $RESETPROP +if [ -x "$RESETPROP" ]; then + chmod 755 $RESETPROP +else + RESETPROP="resetprop" +fi check_resetprop() { local NAME=$1