From e397ca3db10308e484f40e7b4748eaddfc1da036 Mon Sep 17 00:00:00 2001 From: chiteroman <98092901+chiteroman@users.noreply.github.com> Date: Tue, 23 Jan 2024 04:12:52 +0100 Subject: [PATCH] v15.3-test --- .gitmodules | 3 ++ app/build.gradle.kts | 15 +++++-- app/src/main/cpp/CMakeLists.txt | 4 ++ app/src/main/cpp/main.cpp | 41 +++++++++++-------- .../playintegrityfix/EntryPoint.java | 4 +- changelog.md | 2 +- module/module.prop | 4 +- 7 files changed, 49 insertions(+), 24 deletions(-) create mode 100644 .gitmodules diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..bc42722 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "app/src/main/cpp/Dobby"] + path = app/src/main/cpp/Dobby + url = https://github.com/LSPosed/Dobby.git diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 556109a..81dda4d 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -12,18 +12,23 @@ android { applicationId = "es.chiteroman.playintegrityfix" minSdk = 26 targetSdk = 34 - versionCode = 15320 - versionName = "v15.3.2" + versionCode = 15330 + versionName = "v15.3.3" + + buildFeatures { + prefab = true + } packaging { jniLibs { + excludes += "**/liblog.so" excludes += "**/libdobby.so" } } externalNativeBuild { cmake { - arguments += "-DANDROID_STL=c++_static" + arguments += "-DANDROID_STL=none" arguments += "-DCMAKE_BUILD_TYPE=MinSizeRel" cppFlags += "-std=c++20" @@ -58,6 +63,10 @@ android { } } +dependencies { + implementation("dev.rikka.ndk.thirdparty:cxx:1.2.0") +} + tasks.register("updateModuleProp") { doLast { val versionName = project.android.defaultConfig.versionName diff --git a/app/src/main/cpp/CMakeLists.txt b/app/src/main/cpp/CMakeLists.txt index 8302781..7199d37 100644 --- a/app/src/main/cpp/CMakeLists.txt +++ b/app/src/main/cpp/CMakeLists.txt @@ -2,6 +2,10 @@ cmake_minimum_required(VERSION 3.22.1) project("playintegrityfix") +find_package(cxx REQUIRED CONFIG) + +link_libraries(cxx::cxx) + add_library(${CMAKE_PROJECT_NAME} SHARED main.cpp) if (NOT TARGET dobby) diff --git a/app/src/main/cpp/main.cpp b/app/src/main/cpp/main.cpp index afe14e6..6e4a872 100644 --- a/app/src/main/cpp/main.cpp +++ b/app/src/main/cpp/main.cpp @@ -20,6 +20,11 @@ static jmethodID spoofFieldsMethod = nullptr; static void spoofFields() { + if (jvm == nullptr) { + LOGD("JavaVM is null!"); + return; + } + JNIEnv *env; jvm->GetEnv(reinterpret_cast(&env), JNI_VERSION_1_6); @@ -119,11 +124,28 @@ public: void preAppSpecialize(zygisk::AppSpecializeArgs *args) override { - auto rawProcess = env->GetStringUTFChars(args->nice_name, nullptr); + if (args == nullptr || args->nice_name == nullptr || args->app_data_dir == nullptr) { + api->setOption(zygisk::DLCLOSE_MODULE_LIBRARY); + return; + } + auto rawDir = env->GetStringUTFChars(args->app_data_dir, nullptr); - std::string_view process(rawProcess); + if (rawDir == nullptr) { + api->setOption(zygisk::DLCLOSE_MODULE_LIBRARY); + return; + } + + auto rawProcess = env->GetStringUTFChars(args->nice_name, nullptr); + + if (rawProcess == nullptr) { + env->ReleaseStringUTFChars(args->app_data_dir, rawDir); + api->setOption(zygisk::DLCLOSE_MODULE_LIBRARY); + return; + } + std::string_view dir(rawDir); + std::string_view process(rawProcess); bool isGms = dir.ends_with("/com.google.android.gms"); bool isGmsUnstable = process == "com.google.android.gms.unstable"; @@ -178,8 +200,7 @@ public: close(fd); - std::string_view jsonStr(jsonVector.cbegin(), jsonVector.cend()); - json = nlohmann::json::parse(jsonStr, nullptr, false, true); + json = nlohmann::json::parse(jsonVector, nullptr, false, true); parseJson(); } @@ -187,18 +208,6 @@ public: void postAppSpecialize(const zygisk::AppSpecializeArgs *args) override { if (vector.empty() || json.empty()) return; - LOGD("JSON keys: %d", static_cast(json.size())); - - if (!json.contains("PRODUCT") || - !json.contains("DEVICE") || - !json.contains("MANUFACTURER") || - !json.contains("BRAND") || - !json.contains("MODEL") || - !json.contains("FINGERPRINT")) { - LOGD("JSON doesn't contain important fields to spoof!"); - return; - } - injectDex(); doHook(); diff --git a/app/src/main/java/es/chiteroman/playintegrityfix/EntryPoint.java b/app/src/main/java/es/chiteroman/playintegrityfix/EntryPoint.java index e494e60..84598d5 100644 --- a/app/src/main/java/es/chiteroman/playintegrityfix/EntryPoint.java +++ b/app/src/main/java/es/chiteroman/playintegrityfix/EntryPoint.java @@ -76,14 +76,12 @@ public final class EntryPoint { public static void spoofFields() { map.forEach((field, s) -> { - field.setAccessible(true); try { field.set(null, s); LOG("Set " + field.getName() + " field value: " + s); } catch (IllegalAccessException e) { LOG("Couldn't set " + field.getName() + " value " + s + " | Exception: " + e); } - field.setAccessible(false); }); } @@ -100,6 +98,8 @@ public final class EntryPoint { } } + field.setAccessible(true); + return field; } diff --git a/changelog.md b/changelog.md index ad34c20..2673063 100644 --- a/changelog.md +++ b/changelog.md @@ -4,6 +4,6 @@ https://t.me/playintegrityfix # v15.3 -- Migrated from Dobby to ShadowHook (again) +- New way to spoof field values! - Update code logic. - Fixed few bugs. diff --git a/module/module.prop b/module/module.prop index e256c68..e4d19e3 100644 --- a/module/module.prop +++ b/module/module.prop @@ -1,7 +1,7 @@ id=playintegrityfix name=Play Integrity Fix -version=v15.3.2 -versionCode=15320 +version=v15.3.3 +versionCode=15330 author=chiteroman description=Universal modular fix for Play Integrity (and SafetyNet) on devices running Android 8+. updateJson=https://raw.githubusercontent.com/chiteroman/PlayIntegrityFix/main/update.json