mirror of
https://github.com/chiteroman/PlayIntegrityFix.git
synced 2025-01-19 11:02:20 +08:00
Fix JSON parsing, less libs size and few code updates!
This commit is contained in:
parent
6282b326e3
commit
72f3882054
10
.idea/deploymentTargetDropDown.xml
Normal file
10
.idea/deploymentTargetDropDown.xml
Normal file
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="deploymentTargetDropDown">
|
||||
<value>
|
||||
<entry key="app">
|
||||
<State />
|
||||
</entry>
|
||||
</value>
|
||||
</component>
|
||||
</project>
|
@ -1,18 +1,18 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="GradleMigrationSettings" migrationVersion="1" />
|
||||
<component name="GradleSettings">
|
||||
<option name="linkedExternalProjectsSettings">
|
||||
<GradleProjectSettings>
|
||||
<option name="testRunner" value="GRADLE" />
|
||||
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||
<option name="gradleJvm" value="jbr-17" />
|
||||
<option name="gradleJvm" value="#GRADLE_LOCAL_JAVA_HOME" />
|
||||
<option name="modules">
|
||||
<set>
|
||||
<option value="$PROJECT_DIR$" />
|
||||
<option value="$PROJECT_DIR$/app" />
|
||||
</set>
|
||||
</option>
|
||||
<option name="resolveExternalAnnotations" value="false" />
|
||||
</GradleProjectSettings>
|
||||
</option>
|
||||
</component>
|
||||
|
10
.idea/migrations.xml
Normal file
10
.idea/migrations.xml
Normal file
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectMigrations">
|
||||
<option name="MigrateToGradleLocalJavaHome">
|
||||
<set>
|
||||
<option value="$PROJECT_DIR$" />
|
||||
</set>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
@ -1,4 +1,3 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="jbr-17" project-jdk-type="JavaSDK">
|
||||
|
@ -2,5 +2,6 @@
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$/app/src/main/cpp/libcxx" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
@ -1,4 +1,3 @@
|
||||
APP_STL := none
|
||||
APP_CFLAGS := -Oz -fno-exceptions -fno-rtti -fvisibility=hidden -fvisibility-inlines-hidden
|
||||
APP_CPPFLAGS := -std=c++20
|
||||
APP_LDFLAGS := -Oz
|
||||
APP_CPPFLAGS := -std=c++20
|
File diff suppressed because it is too large
Load Diff
@ -1,7 +1,6 @@
|
||||
#include <android/log.h>
|
||||
#include <sys/system_properties.h>
|
||||
#include <unistd.h>
|
||||
#include <fstream>
|
||||
|
||||
#include "zygisk.hpp"
|
||||
#include "shadowhook.h"
|
||||
@ -28,15 +27,17 @@ 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 == "nullptr") {
|
||||
if (FIRST_API_LEVEL.empty()) {
|
||||
LOGD("FIRST_API_LEVEL is empty, ignoring it...");
|
||||
} else if (FIRST_API_LEVEL == "nullptr") {
|
||||
value = nullptr;
|
||||
} else {
|
||||
value = FIRST_API_LEVEL.c_str();
|
||||
}
|
||||
LOGD("[%s] -> %s", name, value);
|
||||
} else if (prop.ends_with("security_patch")) {
|
||||
if (SECURITY_PATCH == "nullptr") {
|
||||
value = nullptr;
|
||||
if (SECURITY_PATCH.empty()) {
|
||||
LOGD("SECURITY_PATCH is empty, ignoring it...");
|
||||
} else {
|
||||
value = SECURITY_PATCH.c_str();
|
||||
}
|
||||
@ -80,12 +81,16 @@ public:
|
||||
}
|
||||
|
||||
void preAppSpecialize(zygisk::AppSpecializeArgs *args) override {
|
||||
bool isGms = false, isGmsUnstable = false;
|
||||
|
||||
auto rawProcess = env->GetStringUTFChars(args->nice_name, nullptr);
|
||||
|
||||
std::string_view process(rawProcess);
|
||||
if (rawProcess) {
|
||||
std::string_view process(rawProcess);
|
||||
|
||||
bool isGms = process.starts_with("com.google.android.gms");
|
||||
bool isGmsUnstable = process.compare("com.google.android.gms.unstable") == 0;
|
||||
isGms = process.starts_with("com.google.android.gms");
|
||||
isGmsUnstable = process.compare("com.google.android.gms.unstable") == 0;
|
||||
}
|
||||
|
||||
env->ReleaseStringUTFChars(args->nice_name, rawProcess);
|
||||
|
||||
@ -101,13 +106,11 @@ public:
|
||||
return;
|
||||
}
|
||||
|
||||
int dexSize = 0;
|
||||
int jsonSize = 0;
|
||||
|
||||
long dexSize = 0, jsonSize = 0;
|
||||
int fd = api->connectCompanion();
|
||||
|
||||
read(fd, &dexSize, sizeof(int));
|
||||
read(fd, &jsonSize, sizeof(int));
|
||||
read(fd, &dexSize, sizeof(long));
|
||||
read(fd, &jsonSize, sizeof(long));
|
||||
|
||||
if (dexSize < 1) {
|
||||
close(fd);
|
||||
@ -124,19 +127,25 @@ public:
|
||||
}
|
||||
|
||||
dexVector.resize(dexSize);
|
||||
jsonVector.resize(jsonSize);
|
||||
|
||||
read(fd, dexVector.data(), dexSize);
|
||||
|
||||
std::vector<char> jsonVector(jsonSize);
|
||||
read(fd, jsonVector.data(), jsonSize);
|
||||
|
||||
close(fd);
|
||||
|
||||
LOGD("Read from file descriptor file 'classes.dex' -> %d bytes", dexSize);
|
||||
LOGD("Read from file descriptor file 'pif.json' -> %d bytes", jsonSize);
|
||||
LOGD("Read from file descriptor file 'classes.dex' -> %ld bytes", dexSize);
|
||||
LOGD("Read from file descriptor file 'pif.json' -> %ld bytes", jsonSize);
|
||||
|
||||
std::string data(jsonVector.cbegin(), jsonVector.cend());
|
||||
json = nlohmann::json::parse(data, nullptr, false, true);
|
||||
|
||||
jsonVector.clear();
|
||||
data.clear();
|
||||
}
|
||||
|
||||
void postAppSpecialize(const zygisk::AppSpecializeArgs *args) override {
|
||||
if (dexVector.empty() || jsonVector.empty()) return;
|
||||
if (dexVector.empty() || json.empty()) return;
|
||||
|
||||
readJson();
|
||||
|
||||
@ -145,7 +154,7 @@ public:
|
||||
inject();
|
||||
|
||||
dexVector.clear();
|
||||
jsonVector.clear();
|
||||
json.clear();
|
||||
}
|
||||
|
||||
void preServerSpecialize(zygisk::ServerSpecializeArgs *args) override {
|
||||
@ -155,15 +164,13 @@ public:
|
||||
private:
|
||||
zygisk::Api *api = nullptr;
|
||||
JNIEnv *env = nullptr;
|
||||
std::vector<char> dexVector, jsonVector;
|
||||
std::vector<char> dexVector;
|
||||
nlohmann::json json;
|
||||
|
||||
void readJson() {
|
||||
std::string data(jsonVector.cbegin(), jsonVector.cend());
|
||||
nlohmann::json json = nlohmann::json::parse(data, nullptr, false, true);
|
||||
|
||||
if (json.contains("SECURITY_PATCH")) {
|
||||
if (json["SECURITY_PATCH"].is_null()) {
|
||||
SECURITY_PATCH = "nullptr";
|
||||
LOGD("Key SECURITY_PATCH is null!");
|
||||
} else if (json["SECURITY_PATCH"].is_string()) {
|
||||
SECURITY_PATCH = json["SECURITY_PATCH"].get<std::string>();
|
||||
} else {
|
||||
@ -175,17 +182,17 @@ private:
|
||||
|
||||
if (json.contains("FIRST_API_LEVEL")) {
|
||||
if (json["FIRST_API_LEVEL"].is_null()) {
|
||||
LOGD("Key FIRST_API_LEVEL is null!");
|
||||
FIRST_API_LEVEL = "nullptr";
|
||||
} else if (json["FIRST_API_LEVEL"].is_string()) {
|
||||
FIRST_API_LEVEL = json["FIRST_API_LEVEL"].get<std::string>();
|
||||
} else {
|
||||
LOGD("Error parsing FIRST_API_LEVEL!");
|
||||
}
|
||||
json.erase("FIRST_API_LEVEL");
|
||||
} else {
|
||||
LOGD("Key FIRST_API_LEVEL doesn't exist in JSON file!");
|
||||
}
|
||||
|
||||
json.clear();
|
||||
}
|
||||
|
||||
void inject() {
|
||||
@ -214,8 +221,7 @@ private:
|
||||
LOGD("read json");
|
||||
auto readProps = env->GetStaticMethodID(entryClass, "readJson",
|
||||
"(Ljava/lang/String;)V");
|
||||
std::string data(jsonVector.cbegin(), jsonVector.cend());
|
||||
auto javaStr = env->NewStringUTF(data.c_str());
|
||||
auto javaStr = env->NewStringUTF(json.dump().c_str());
|
||||
env->CallStaticVoidMethod(entryClass, readProps, javaStr);
|
||||
|
||||
LOGD("call init");
|
||||
@ -225,22 +231,43 @@ private:
|
||||
};
|
||||
|
||||
static void companion(int fd) {
|
||||
std::ifstream dex(DEX_FILE_PATH, std::ios::binary);
|
||||
std::ifstream json(JSON_FILE_PATH);
|
||||
long dexSize = 0, jsonSize = 0;
|
||||
std::vector<char> dexVector, jsonVector;
|
||||
|
||||
std::vector<char> dexVector((std::istreambuf_iterator<char>(dex)),
|
||||
std::istreambuf_iterator<char>());
|
||||
std::vector<char> jsonVector((std::istreambuf_iterator<char>(json)),
|
||||
std::istreambuf_iterator<char>());
|
||||
FILE *dex = fopen(DEX_FILE_PATH, "rb");
|
||||
|
||||
int dexSize = static_cast<int>(dexVector.size());
|
||||
int jsonSize = static_cast<int>(jsonVector.size());
|
||||
if (dex) {
|
||||
fseek(dex, 0, SEEK_END);
|
||||
dexSize = ftell(dex);
|
||||
fseek(dex, 0, SEEK_SET);
|
||||
|
||||
write(fd, &dexSize, sizeof(int));
|
||||
write(fd, &jsonSize, sizeof(int));
|
||||
dexVector.resize(dexSize);
|
||||
fread(dexVector.data(), 1, dexSize, dex);
|
||||
|
||||
fclose(dex);
|
||||
}
|
||||
|
||||
FILE *json = fopen(JSON_FILE_PATH, "r");
|
||||
|
||||
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));
|
||||
write(fd, &jsonSize, sizeof(long));
|
||||
|
||||
write(fd, dexVector.data(), dexSize);
|
||||
write(fd, jsonVector.data(), jsonSize);
|
||||
|
||||
dexVector.clear();
|
||||
jsonVector.clear();
|
||||
}
|
||||
|
||||
REGISTER_ZYGISK_MODULE(PlayIntegrityFix)
|
||||
|
@ -1 +1 @@
|
||||
#MAGISK
|
||||
#MAGISK
|
@ -11,4 +11,4 @@ fi
|
||||
|
||||
# Clean up any leftover files from previous deprecated methods
|
||||
rm -f /data/data/com.google.android.gms/cache/pif.prop /data/data/com.google.android.gms/pif.prop
|
||||
rm -f /data/data/com.google.android.gms/cache/pif.json /data/data/com.google.android.gms/pif.json
|
||||
rm -f /data/data/com.google.android.gms/cache/pif.json /data/data/com.google.android.gms/pif.json
|
@ -1,7 +1,7 @@
|
||||
id=playintegrityfix
|
||||
name=Play Integrity Fix
|
||||
version=PROPS-v2.0
|
||||
versionCode=2000
|
||||
version=PROPS-v2.1
|
||||
versionCode=2001
|
||||
author=chiteroman
|
||||
description=Fix CTS profile (SafetyNet) and DEVICE verdict (Play Integrity).
|
||||
updateJson=https://raw.githubusercontent.com/chiteroman/PlayIntegrityFix/main/update.json
|
@ -6,4 +6,4 @@ fi
|
||||
# Remove safetynet-fix module if installed
|
||||
if [ -d /data/adb/modules/safetynet-fix ]; then
|
||||
touch /data/adb/modules/safetynet-fix/remove
|
||||
fi
|
||||
fi
|
@ -38,7 +38,10 @@ resetprop_if_match ro.boot.mode recovery unknown
|
||||
resetprop_if_match vendor.boot.mode recovery unknown
|
||||
|
||||
# SELinux
|
||||
resetprop --delete ro.build.selinux
|
||||
if [ -n "$(getprop ro.build.selinux)" ]; then
|
||||
resetprop --delete ro.build.selinux
|
||||
fi
|
||||
|
||||
# use toybox to protect *stat* access time reading
|
||||
if [ "$(toybox cat /sys/fs/selinux/enforce)" == "0" ]; then
|
||||
chmod 640 /sys/fs/selinux/enforce
|
||||
@ -65,4 +68,4 @@ fi
|
||||
resetprop_if_diff ro.boot.verifiedbootstate green
|
||||
resetprop_if_diff ro.boot.veritymode enforcing
|
||||
resetprop_if_diff vendor.boot.vbmeta.device_state locked
|
||||
}&
|
||||
}&
|
Loading…
Reference in New Issue
Block a user