From 8681f89b7061a0db0f5bfb78b1cb514a18dfaca7 Mon Sep 17 00:00:00 2001 From: chiteroman <98092901+chiteroman@users.noreply.github.com> Date: Thu, 18 Jul 2024 13:40:26 +0200 Subject: [PATCH] updates --- .idea/other.xml | 263 -------------------------------- .idea/runConfigurations.xml | 13 ++ .idea/vcs.xml | 2 +- app/build.gradle.kts | 13 +- app/src/main/cpp/CMakeLists.txt | 4 +- app/src/main/cpp/main.cpp | 159 ++++++++----------- build.gradle.kts | 2 +- module/customize.sh | 6 + module/pif.json | 91 +---------- 9 files changed, 95 insertions(+), 458 deletions(-) delete mode 100644 .idea/other.xml create mode 100644 .idea/runConfigurations.xml diff --git a/.idea/other.xml b/.idea/other.xml deleted file mode 100644 index 8047a35..0000000 --- a/.idea/other.xml +++ /dev/null @@ -1,263 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 0000000..aaa17d9 --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,13 @@ + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml index aa851fd..c741307 100644 --- a/.idea/vcs.xml +++ b/.idea/vcs.xml @@ -2,6 +2,6 @@ - + \ No newline at end of file diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 81f6e41..28530af 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -4,8 +4,8 @@ plugins { android { namespace = "es.chiteroman.playintegrityfix" - compileSdk = 34 - ndkVersion = "26.3.11579264" + compileSdk = 35 + ndkVersion = "27.0.12077973" buildToolsVersion = "34.0.0" buildFeatures { @@ -15,17 +15,16 @@ android { defaultConfig { applicationId = "es.chiteroman.playintegrityfix" minSdk = 26 - targetSdk = 34 + targetSdk = 35 versionCode = 16500 versionName = "v16.6" multiDexEnabled = false packaging { resources { - excludes += "META-INF/**" + excludes += "**" } jniLibs { - excludes += "**/liblog.so" excludes += "**/libdobby.so" } } @@ -38,7 +37,7 @@ android { cFlags += "-w" cppFlags += "-w" - cppFlags += "-std=c++20" + cppFlags += "-std=c++2c" cppFlags += "-fno-exceptions" cppFlags += "-fno-rtti" cppFlags += "-fvisibility=hidden" @@ -72,7 +71,7 @@ android { } dependencies { - implementation("dev.rikka.ndk.thirdparty:cxx:1.2.0") + implementation("org.lsposed.libcxx:libcxx:27.0.12077973") } tasks.register("updateModuleProp") { diff --git a/app/src/main/cpp/CMakeLists.txt b/app/src/main/cpp/CMakeLists.txt index d3b8b4f..6c9464f 100644 --- a/app/src/main/cpp/CMakeLists.txt +++ b/app/src/main/cpp/CMakeLists.txt @@ -4,12 +4,10 @@ project(playintegrityfix) find_package(cxx REQUIRED CONFIG) -link_libraries(log) - link_libraries(cxx::cxx) add_library(${CMAKE_PROJECT_NAME} SHARED main.cpp) add_subdirectory(Dobby) -target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE dobby_static) \ No newline at end of file +target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE log dobby_static) \ No newline at end of file diff --git a/app/src/main/cpp/main.cpp b/app/src/main/cpp/main.cpp index ed5873e..8c8e7f0 100644 --- a/app/src/main/cpp/main.cpp +++ b/app/src/main/cpp/main.cpp @@ -2,9 +2,10 @@ #include #include #include -#include "dobby.h" -#include "json.hpp" +#include #include "zygisk.hpp" +#include "json.hpp" +#include "dobby.h" #define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG, "PIF", __VA_ARGS__) #define LOGE(...) __android_log_print(ANDROID_LOG_ERROR, "PIF", __VA_ARGS__) @@ -15,35 +16,11 @@ #define PIF_JSON_DEFAULT "/data/adb/modules/playintegrityfix/pif.json" -static ssize_t xread(int fd, void *buffer, size_t count) { - ssize_t total = 0; - char *buf = (char *) buffer; - while (count > 0) { - ssize_t ret = read(fd, buf, count); - if (ret < 0) return -1; - buf += ret; - total += ret; - count -= ret; - } - return total; -} +static std::string DEVICE_INITIAL_SDK_INT = "21"; +static std::string SECURITY_PATCH; +static std::string BUILD_ID; -static ssize_t xwrite(int fd, void *buffer, size_t count) { - ssize_t total = 0; - char *buf = (char *) buffer; - while (count > 0) { - ssize_t ret = write(fd, buf, count); - if (ret < 0) return -1; - buf += ret; - total += ret; - count -= ret; - } - return total; -} - -static int verboseLogs = 0; - -static std::map props; +static bool DEBUG = false; typedef void (*T_Callback)(void *, const char *, const char *, uint32_t); @@ -59,51 +36,46 @@ static void modify_callback(void *cookie, const char *name, const char *value, u if (prop == "init.svc.adbd") { value = "stopped"; + if (!DEBUG) LOGD("[%s]: %s", name, value); } else if (prop == "sys.usb.state") { value = "mtp"; + if (!DEBUG) LOGD("[%s]: %s", name, value); + } else if (prop.ends_with("api_level") && !DEVICE_INITIAL_SDK_INT.empty()) { + value = DEVICE_INITIAL_SDK_INT.c_str(); + if (!DEBUG) LOGD("[%s]: %s", name, value); + } else if (prop.ends_with(".security_patch") && !SECURITY_PATCH.empty()) { + value = SECURITY_PATCH.c_str(); + if (!DEBUG) LOGD("[%s]: %s", name, value); + } else if (prop.ends_with(".build.id") && !BUILD_ID.empty()) { + value = BUILD_ID.c_str(); + if (!DEBUG) LOGD("[%s]: %s", name, value); } - if (props.contains(name)) { - value = props[name].c_str(); - if (verboseLogs > 49) LOGD("[%s]: %s", name, value); - } else { - for (const auto &item: props) { - if (item.first.starts_with("*") && prop.ends_with(item.first.substr(1))) { - value = item.second.c_str(); - if (verboseLogs > 49) LOGD("[%s]: %s", name, value); - break; - } - } - } - - if (verboseLogs > 99) LOGD("[%s]: %s", name, value); + if (DEBUG) LOGD("[%s]: %s", name, value); return callbacks[cookie](cookie, name, value, serial); } -static void (*o_system_property_read_callback)(const prop_info *, T_Callback, void *); +static void (*o_system_property_read_callback)(const prop_info *, T_Callback, void *) = nullptr; static void my_system_property_read_callback(const prop_info *pi, T_Callback callback, void *cookie) { - if (pi == nullptr || callback == nullptr || cookie == nullptr) { - return o_system_property_read_callback(pi, callback, cookie); - } - callbacks[cookie] = callback; + if (callback && cookie) callbacks[cookie] = callback; return o_system_property_read_callback(pi, modify_callback, cookie); } static void doHook() { - auto handle = DobbySymbolResolver(nullptr, "__system_property_read_callback"); + void *handle = DobbySymbolResolver(nullptr, "__system_property_read_callback"); if (!handle) { - LOGE("Couldn't find __system_property_read_callback symbol!"); + LOGE("error resolving __system_property_read_callback symbol!"); return; } - if (DobbyHook(handle, (dobby_dummy_func_t) my_system_property_read_callback, - (dobby_dummy_func_t *) &o_system_property_read_callback)) { - LOGE("Couldn't hook __system_property_read_callback!"); - return; + if (DobbyHook(handle, (void *) my_system_property_read_callback, + (void **) &o_system_property_read_callback)) { + LOGE("hook failed!"); + } else { + LOGD("hook __system_property_read_callback success at %p", handle); } - LOGD("Hooked __system_property_read_callback at %p", handle); } class PlayIntegrityFix : public zygisk::ModuleBase { @@ -159,17 +131,17 @@ public: int dexSize = 0, jsonSize = 0; std::vector jsonVector; - xread(fd, &dexSize, sizeof(int)); - xread(fd, &jsonSize, sizeof(int)); + read(fd, &dexSize, sizeof(int)); + read(fd, &jsonSize, sizeof(int)); if (dexSize > 0) { dexVector.resize(dexSize); - xread(fd, dexVector.data(), dexSize * sizeof(uint8_t)); + read(fd, dexVector.data(), dexSize * sizeof(uint8_t)); } if (jsonSize > 0) { jsonVector.resize(jsonSize); - xread(fd, jsonVector.data(), jsonSize * sizeof(uint8_t)); + read(fd, jsonVector.data(), jsonSize * sizeof(uint8_t)); json = nlohmann::json::parse(jsonVector, nullptr, false, true); } @@ -177,13 +149,13 @@ public: LOGD("Dex file size: %d", dexSize); LOGD("Json file size: %d", jsonSize); - - parseJSON(); } void postAppSpecialize(const zygisk::AppSpecializeArgs *args) override { if (dexVector.empty()) return; + parseJSON(); + doHook(); injectDex(); @@ -202,39 +174,27 @@ private: void parseJSON() { if (json.empty()) return; - if (json.contains("verboseLogs") && !json["verboseLogs"].empty()) { - if (json["verboseLogs"].is_string()) { - verboseLogs = std::stoi(json["verboseLogs"].get()); - } else if (json["verboseLogs"].is_number_integer()) { - verboseLogs = json["verboseLogs"].get(); + if (json.contains("DEVICE_INITIAL_SDK_INT")) { + if (json["DEVICE_INITIAL_SDK_INT"].is_string()) { + DEVICE_INITIAL_SDK_INT = json["DEVICE_INITIAL_SDK_INT"].get(); + } else if (json["DEVICE_INITIAL_SDK_INT"].is_number_integer()) { + DEVICE_INITIAL_SDK_INT = std::to_string(json["DEVICE_INITIAL_SDK_INT"].get()); } - json.erase("verboseLogs"); + json.erase("DEVICE_INITIAL_SDK_INT"); } - if (verboseLogs > 0) LOGD("Verbose logging (level %d) enabled", verboseLogs); - - std::vector removeKeys; - - // Java fields are always uppercase, system props are always lowercase - for (const auto &item: json.items()) { - if (std::all_of(item.key().cbegin(), item.key().cend(), [](unsigned char c) { - return c == '_' || (std::isalpha(c) && std::isupper(c)); - })) { - // Java field - if (verboseLogs > 99) LOGD("Skip Java field: %s", item.key().c_str()); - continue; - } - // System prop - if (item.value().is_string()) { - props.insert({item.key(), item.value().get()}); - if (verboseLogs > 99) LOGD("Got system prop: %s", item.key().c_str()); - } - removeKeys.push_back(item.key()); + if (json.contains("SECURITY_PATCH") && json["SECURITY_PATCH"].is_string()) { + SECURITY_PATCH = json["SECURITY_PATCH"].get(); } - LOGD("Loaded %d props to spoof", props.size()); + if (json.contains("ID") && json["ID"].is_string()) { + BUILD_ID = json["ID"].get(); + } - for (const auto &item: removeKeys) json.erase(item); + if (json.contains("DEBUG") && json["DEBUG"].is_boolean()) { + DEBUG = json["DEBUG"].get(); + json.erase("DEBUG"); + } } void injectDex() { @@ -291,23 +251,30 @@ static std::vector readFile(const char *path) { static void companion(int fd) { - auto dex = readFile(DEX_PATH); + std::vector dex, json; - auto json = readFile(PIF_JSON); - if (json.empty()) json = readFile(PIF_JSON_DEFAULT); + if (std::filesystem::exists(DEX_PATH)) { + dex = readFile(DEX_PATH); + } + + if (std::filesystem::exists(PIF_JSON)) { + json = readFile(PIF_JSON); + } else if (std::filesystem::exists(PIF_JSON_DEFAULT)) { + json = readFile(PIF_JSON_DEFAULT); + } int dexSize = static_cast(dex.size()); int jsonSize = static_cast(json.size()); - xwrite(fd, &dexSize, sizeof(int)); - xwrite(fd, &jsonSize, sizeof(int)); + write(fd, &dexSize, sizeof(int)); + write(fd, &jsonSize, sizeof(int)); if (dexSize > 0) { - xwrite(fd, dex.data(), dexSize * sizeof(uint8_t)); + write(fd, dex.data(), dexSize * sizeof(uint8_t)); } if (jsonSize > 0) { - xwrite(fd, json.data(), jsonSize * sizeof(uint8_t)); + write(fd, json.data(), jsonSize * sizeof(uint8_t)); } } diff --git a/build.gradle.kts b/build.gradle.kts index 3ac3a33..f34f357 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,3 +1,3 @@ plugins { - id("com.android.application") version "8.5.0" apply false + id("com.android.application") version "8.5.1" apply false } \ No newline at end of file diff --git a/module/customize.sh b/module/customize.sh index ef235da..bfeacbf 100644 --- a/module/customize.sh +++ b/module/customize.sh @@ -20,6 +20,12 @@ if [ -d "/data/adb/modules/MagiskHidePropsConf" ]; then ui_print "! WARNING, MagiskHidePropsConf module may cause issues with PIF." fi +# tricky_store must be removed when flashing PIF +if [ -d "/data/adb/modules/tricky_store" ]; then + touch "/data/adb/modules/tricky_store/remove" + ui_print "! tricky_store module removed!" +fi + # Check custom fingerprint if [ -f "/data/adb/pif.json" ]; then mv -f "/data/adb/pif.json" "/data/adb/pif.json.old" diff --git a/module/pif.json b/module/pif.json index f6f60ca..1370ba3 100644 --- a/module/pif.json +++ b/module/pif.json @@ -1,95 +1,12 @@ { + "ID": "AP31.240517.022", "BRAND": "google", "DEVICE": "husky", "FINGERPRINT": "google/husky_beta/husky:15/AP31.240517.022/11948202:user/release-keys", - "ID": "AP31.240517.022", "MANUFACTURER": "Google", "MODEL": "Pixel 8 Pro", "PRODUCT": "husky_beta", "SECURITY_PATCH": "2024-06-05", - "*.security_patch": "2024-06-05", - "*api_level": "24", - "dalvik.vm.appimageformat": "lz4", - "dalvik.vm.dex2oat-Xms": "64m", - "dalvik.vm.dex2oat-Xmx": "512m", - "dalvik.vm.dex2oat-max-image-block-size": "524288", - "dalvik.vm.dex2oat-minidebuginfo": "true", - "dalvik.vm.dex2oat-resolve-startup-strings": "true", - "dalvik.vm.dexopt.secondary": "true", - "dalvik.vm.dexopt.thermal-cutoff": "2", - "dalvik.vm.image-dex2oat-Xms": "64m", - "dalvik.vm.image-dex2oat-Xmx": "64m", - "dalvik.vm.madvise.artfile.size": "4294967295", - "dalvik.vm.madvise.odexfile.size": "104857600", - "dalvik.vm.madvise.vdexfile.size": "104857600", - "dalvik.vm.minidebuginfo": "true", - "dalvik.vm.usap_pool_enabled": "false", - "dalvik.vm.usap_pool_refill_delay_ms": "3000", - "dalvik.vm.usap_pool_size_max": "3", - "dalvik.vm.usap_pool_size_min": "1", - "dalvik.vm.usap_refill_threshold": "1", - "dalvik.vm.useartservice": "true", - "dalvik.vm.usejit": "true", - "debug.atrace.tags.enableflags": "0", - "net.bt.name": "Android", - "persist.settings.large_screen_opt.enabled": "false", - "persist.traced.enable": "1", - "pm.dexopt.ab-ota": "speed-profile", - "pm.dexopt.bg-dexopt": "speed-profile", - "pm.dexopt.boot-after-mainline-update": "verify", - "pm.dexopt.boot-after-ota": "verify", - "pm.dexopt.cmdline": "verify", - "pm.dexopt.first-boot": "verify", - "pm.dexopt.inactive": "verify", - "pm.dexopt.install": "speed-profile", - "pm.dexopt.install-bulk": "speed-profile", - "pm.dexopt.install-bulk-downgraded": "verify", - "pm.dexopt.install-bulk-secondary": "verify", - "pm.dexopt.install-bulk-secondary-downgraded": "verify", - "pm.dexopt.install-fast": "skip", - "pm.dexopt.post-boot": "verify", - "pm.dexopt.shared": "speed", - "ro.actionable_compatible_property.enabled": "true", - "ro.adb.secure": "1", - "ro.allow.mock.location": "0", - "ro.apex.updatable": "true", - "ro.build.date": "Mon Jun 10 17:11:45 UTC 2024", - "ro.build.date.utc": "1718039505", - "ro.build.description": "husky_beta-user 15 AP31.240517.022 11948202 release-keys", - "ro.build.display.id": "AP31.240517.022", - "ro.build.flavor": "husky_beta-user", - "ro.build.host": "r-5ed19c9f6e4ddbc5-v0mt", - "ro.build.user": "android-build", - "ro.build.version.all_codenames": "REL", - "ro.build.version.codename": "REL", - "ro.build.version.known_codenames": "Base,Base11,Cupcake,Donut,Eclair,Eclair01,EclairMr1,Froyo,Gingerbread,GingerbreadMr1,Honeycomb,HoneycombMr1,HoneycombMr2,IceCreamSandwich,IceCreamSandwichMr1,JellyBean,JellyBeanMr1,JellyBeanMr2,Kitkat,KitkatWatch,Lollipop,LollipopMr1,M,N,NMr1,O,OMr1,P,Q,R,S,Sv2,Tiramisu,UpsideDownCake,VanillaIceCream", - "ro.build.version.min_supported_target_sdk": "28", - "ro.build.version.preview_sdk": "0", - "ro.build.version.preview_sdk_fingerprint": "REL", - "ro.build.version.release_or_codename": "15", - "ro.build.version.release_or_preview_display": "15", - "ro.camerax.extensions.enabled": "true", - "ro.dalvik.vm.native.bridge": "0", - "ro.debuggable": "0", - "ro.force.debuggable": "0", - "ro.hotword.detection_service_required": "true", - "ro.launcher.blur.appLaunch": "0", - "ro.llndk.api_level": "202404", - "ro.postinstall.fstab.prefix": "/system", - "ro.product.cpu.abi": "arm64-v8a", - "ro.product.locale": "en-US", - "ro.secure": "1", - "ro.system.build.date": "Mon Jun 10 17:11:45 UTC 2024", - "ro.system.build.date.utc": "1718039505", - "ro.system.build.id": "AP31.240517.022", - "ro.system.build.tags": "release-keys", - "ro.system.build.type": "user", - "ro.system.build.version.incremental": "11948202", - "ro.system.build.version.release": "15", - "ro.system.build.version.release_or_codename": "15", - "ro.system.product.cpu.abilist": "arm64-v8a", - "ro.system.product.cpu.abilist64": "arm64-v8a", - "ro.treble.enabled": "true", - "security.perf_harden": "1", - "verboseLogs": 100 -} + "DEVICE_INITIAL_SDK_INT": 21, + "DEBUG": false +} \ No newline at end of file