This commit is contained in:
chiteroman 2024-05-16 10:51:44 +02:00
parent 9e2b59e72f
commit 763607e2f8
9 changed files with 148 additions and 108 deletions

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="deploymentTargetSelector">
<selectionStates>
<SelectionState runConfigName="app">
<option name="selectionMode" value="DROPDOWN" />
</SelectionState>
</selectionStates>
</component>
</project>

View File

@ -1,4 +1,3 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" /> <component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="temurin-21" project-jdk-type="JavaSDK"> <component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="temurin-21" project-jdk-type="JavaSDK">

View File

@ -47,9 +47,7 @@ android {
isMinifyEnabled = true isMinifyEnabled = true
isShrinkResources = true isShrinkResources = true
multiDexEnabled = false multiDexEnabled = false
proguardFiles( proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro"
)
} }
} }
@ -92,10 +90,8 @@ tasks.register("copyFiles") {
doLast { doLast {
val moduleFolder = project.rootDir.resolve("module") val moduleFolder = project.rootDir.resolve("module")
val dexFile = val dexFile = project.layout.buildDirectory.get().asFile.resolve("intermediates/dex/release/minifyReleaseWithR8/classes.dex")
project.layout.buildDirectory.get().asFile.resolve("intermediates/dex/release/minifyReleaseWithR8/classes.dex") val soDir = project.layout.buildDirectory.get().asFile.resolve("intermediates/stripped_native_libs/release/stripReleaseDebugSymbols/out/lib")
val soDir =
project.layout.buildDirectory.get().asFile.resolve("intermediates/stripped_native_libs/release/stripReleaseDebugSymbols/out/lib")
dexFile.copyTo(moduleFolder.resolve("classes.dex"), overwrite = true) dexFile.copyTo(moduleFolder.resolve("classes.dex"), overwrite = true)

View File

@ -1,6 +1,7 @@
#include <android/log.h> #include <android/log.h>
#include <sys/system_properties.h> #include <sys/system_properties.h>
#include <unistd.h> #include <unistd.h>
#include <regex>
#include "dobby.h" #include "dobby.h"
#include "json.hpp" #include "json.hpp"
#include "zygisk.hpp" #include "zygisk.hpp"
@ -13,7 +14,7 @@
#define PIF_JSON_DEFAULT "/data/adb/modules/playintegrityfix/pif.json" #define PIF_JSON_DEFAULT "/data/adb/modules/playintegrityfix/pif.json"
static nlohmann::json json; static nlohmann::json PROPS;
typedef void (*T_Callback)(void *, const char *, const char *, uint32_t); typedef void (*T_Callback)(void *, const char *, const char *, uint32_t);
@ -23,35 +24,20 @@ static void modify_callback(void *cookie, const char *name, const char *value, u
if (cookie == nullptr || name == nullptr || value == nullptr || o_callback == nullptr) return; if (cookie == nullptr || name == nullptr || value == nullptr || o_callback == nullptr) return;
std::string_view prop(name); std::string prop(name);
if (prop.ends_with("security_patch")) { for (auto &[key, val]: PROPS.items()) {
if (key.starts_with('*')) {
if (json.contains("SECURITY_PATCH")) { if (prop.ends_with(key.substr(1))) {
if (json["SECURITY_PATCH"].is_string()) { value = val.get<std::string>().c_str();
value = json["SECURITY_PATCH"].get<std::string>().c_str(); break;
}
} else {
if (prop == key) {
value = val.get<std::string>().c_str();
break;
} }
} }
} else if (prop.ends_with("api_level")) {
if (json.contains("FIRST_API_LEVEL")) {
if (json["FIRST_API_LEVEL"].is_number_integer()) {
value = std::to_string(json["FIRST_API_LEVEL"].get<int>()).c_str();
}
}
} else if (prop.ends_with("build.id")) {
if (json.contains("BUILD_ID")) {
if (json["BUILD_ID"].is_string()) {
value = json["BUILD_ID"].get<std::string>().c_str();
}
}
} else if (prop == "sys.usb.state") {
value = "none";
} }
if (!prop.starts_with("persist") && !prop.starts_with("cache") && !prop.starts_with("debug")) { if (!prop.starts_with("persist") && !prop.starts_with("cache") && !prop.starts_with("debug")) {
@ -92,30 +78,43 @@ public:
void preAppSpecialize(zygisk::AppSpecializeArgs *args) override { void preAppSpecialize(zygisk::AppSpecializeArgs *args) override {
if (args != nullptr) { if (!args) {
api->setOption(zygisk::DLCLOSE_MODULE_LIBRARY);
return;
}
auto dir = env->GetStringUTFChars(args->app_data_dir, nullptr); const char *rawDir = env->GetStringUTFChars(args->app_data_dir, nullptr);
if (dir != nullptr) { if (!rawDir) {
api->setOption(zygisk::DLCLOSE_MODULE_LIBRARY);
return;
}
bool isGms = std::string_view(dir).ends_with("/com.google.android.gms"); const char *rawName = env->GetStringUTFChars(args->nice_name, nullptr);
env->ReleaseStringUTFChars(args->app_data_dir, dir); if (!rawName) {
env->ReleaseStringUTFChars(args->app_data_dir, rawDir);
api->setOption(zygisk::DLCLOSE_MODULE_LIBRARY);
return;
}
if (isGms) { std::string dir(rawDir);
std::string name(rawName);
env->ReleaseStringUTFChars(args->app_data_dir, rawDir);
env->ReleaseStringUTFChars(args->nice_name, rawName);
if (!dir.ends_with("/com.google.android.gms")) {
api->setOption(zygisk::DLCLOSE_MODULE_LIBRARY);
return;
}
api->setOption(zygisk::FORCE_DENYLIST_UNMOUNT); api->setOption(zygisk::FORCE_DENYLIST_UNMOUNT);
auto name = env->GetStringUTFChars(args->nice_name, nullptr); if (name != "com.google.android.gms.unstable") {
api->setOption(zygisk::DLCLOSE_MODULE_LIBRARY);
if (name != nullptr) { return;
}
bool isGmsUnstable =
std::string_view(name) == "com.google.android.gms.unstable";
env->ReleaseStringUTFChars(args->nice_name, name);
if (isGmsUnstable) {
long dexSize = 0, jsonSize = 0; long dexSize = 0, jsonSize = 0;
@ -127,7 +126,11 @@ public:
LOGD("Dex file size: %ld", dexSize); LOGD("Dex file size: %ld", dexSize);
LOGD("Json file size: %ld", jsonSize); LOGD("Json file size: %ld", jsonSize);
if (dexSize > 0 && jsonSize > 0) { if (dexSize < 1 || jsonSize < 1) {
close(fd);
api->setOption(zygisk::DLCLOSE_MODULE_LIBRARY);
return;
}
dexVector.resize(dexSize); dexVector.resize(dexSize);
read(fd, dexVector.data(), dexSize); read(fd, dexVector.data(), dexSize);
@ -137,19 +140,14 @@ public:
jsonVector.resize(jsonSize); jsonVector.resize(jsonSize);
read(fd, jsonVector.data(), jsonSize); read(fd, jsonVector.data(), jsonSize);
json = nlohmann::json::parse(jsonVector, nullptr, false, true);
}
close(fd); close(fd);
return; json = nlohmann::json::parse(jsonVector, nullptr, false, true);
}
}
}
}
}
api->setOption(zygisk::DLCLOSE_MODULE_LIBRARY); if (json.contains("PROPS")) {
PROPS = json["PROPS"];
json.erase("PROPS");
}
} }
void postAppSpecialize(const zygisk::AppSpecializeArgs *args) override { void postAppSpecialize(const zygisk::AppSpecializeArgs *args) override {
@ -168,6 +166,7 @@ private:
zygisk::Api *api = nullptr; zygisk::Api *api = nullptr;
JNIEnv *env = nullptr; JNIEnv *env = nullptr;
std::vector<uint8_t> dexVector; std::vector<uint8_t> dexVector;
nlohmann::json json;
void injectDex() { void injectDex() {
LOGD("get system classloader"); LOGD("get system classloader");

View File

@ -3,6 +3,7 @@ package es.chiteroman.playintegrityfix;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
import java.lang.reflect.Method;
import java.security.Key; import java.security.Key;
import java.security.KeyStoreException; import java.security.KeyStoreException;
import java.security.KeyStoreSpi; import java.security.KeyStoreSpi;
@ -10,6 +11,7 @@ import java.security.NoSuchAlgorithmException;
import java.security.UnrecoverableKeyException; import java.security.UnrecoverableKeyException;
import java.security.cert.Certificate; import java.security.cert.Certificate;
import java.security.cert.CertificateException; import java.security.cert.CertificateException;
import java.util.Arrays;
import java.util.Date; import java.util.Date;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.Locale; import java.util.Locale;
@ -22,14 +24,33 @@ public final class CustomKeyStoreSpi extends KeyStoreSpi {
return keyStoreSpi.engineGetKey(alias, password); return keyStoreSpi.engineGetKey(alias, password);
} }
private static String getProcessName() {
try {
Class<?> activityThread = Class.forName("android.app.ActivityThread");
Method method = activityThread.getDeclaredMethod("currentProcessName");
method.setAccessible(true);
return (String) method.invoke(null);
} catch (Throwable t) {
EntryPoint.LOG(t.toString());
}
return null;
}
@Override @Override
public Certificate[] engineGetCertificateChain(String alias) { public Certificate[] engineGetCertificateChain(String alias) {
for (StackTraceElement element : Thread.currentThread().getStackTrace()) { boolean droidGuard = Arrays.stream(Thread.currentThread().getStackTrace()).anyMatch(e -> e.getClassName().toLowerCase(Locale.US).contains("droidguard"));
if (element.getClassName().toLowerCase(Locale.US).contains("droidguard")) {
String processName = getProcessName();
if (processName != null && droidGuard && processName.equals("com.google.android.gms.unstable")) {
EntryPoint.LOG("DroidGuard call detected. Throw exception!");
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
}
return keyStoreSpi.engineGetCertificateChain(alias); return keyStoreSpi.engineGetCertificateChain(alias);
} }

View File

@ -14,7 +14,9 @@ public final class CustomProvider extends Provider {
public synchronized Service getService(String type, String algorithm) { public synchronized Service getService(String type, String algorithm) {
EntryPoint.LOG(String.format("Service: '%s' | Algorithm: '%s'", type, algorithm)); EntryPoint.LOG(String.format("Service: '%s' | Algorithm: '%s'", type, algorithm));
EntryPoint.spoofFields(); Thread t = new Thread(EntryPoint::spoofFields);
t.setDaemon(true);
t.start();
return super.getService(type, algorithm); return super.getService(type, algorithm);
} }

View File

@ -7,6 +7,8 @@ If not, try removing /data/adb/pif.json file.
Donations: Donations:
https://www.paypal.com/paypalme/chiteroman https://www.paypal.com/paypalme/chiteroman
# v15.9.7 # v15.9.8
- Improve code detecting attestation extensions. - MEETS_DEVICE_INTEGRITY is green again ✅
- Refine code
- You can define your own native props in pif.json!

View File

@ -1,11 +1,22 @@
{ {
"PRODUCT": "griffin_retcn",
"DEVICE": "griffin",
"MANUFACTURER": "motorola", "MANUFACTURER": "motorola",
"MODEL": "XT1575",
"FINGERPRINT": "motorola/clark_retus/clark:6.0/MPHS24.49-18-8/4:user/release-keys",
"BRAND": "motorola", "BRAND": "motorola",
"MODEL": "XT1650-05", "PRODUCT": "clark_retus",
"FINGERPRINT": "motorola/griffin_retcn/griffin:6.0.1/MCC24.246-37/42:user/release-keys", "DEVICE": "clark",
"SECURITY_PATCH": "2016-07-01", "RELEASE": "6.0",
"ID": "MCC24.246-37", "ID": "MPHS24.49-18-8",
"FIRST_API_LEVEL": 21 "INCREMENTAL": "4",
"TYPE": "user",
"TAGS": "release-keys",
"SECURITY_PATCH": "2016-09-01",
"PROPS": {
"*api_level": "25",
"*.security_patch": "2016-09-01",
"*.build.id": "MPHS24.49-18-8",
"*.fingerprint": "motorola/clark_retus/clark:6.0/MPHS24.49-18-8/4:user/release-keys",
"sys.usb.state": "none",
"ro.secureboot.lockstate": "locked"
}
} }

View File

@ -1,6 +1,6 @@
{ {
"version": "v15.9.7", "version": "v15.9.8",
"versionCode": 15970, "versionCode": 15980,
"zipUrl": "https://github.com/chiteroman/PlayIntegrityFix/releases/download/v15.9.7/PlayIntegrityFix_v15.9.7.zip", "zipUrl": "https://github.com/chiteroman/PlayIntegrityFix/releases/download/v15.9.8/PlayIntegrityFix_v15.9.8.zip",
"changelog": "https://raw.githubusercontent.com/chiteroman/PlayIntegrityFix/main/changelog.md" "changelog": "https://raw.githubusercontent.com/chiteroman/PlayIntegrityFix/main/changelog.md"
} }