Skip to content

Commit

Permalink
Add json key to enable/disable package manager spoofing
Browse files Browse the repository at this point in the history
  • Loading branch information
chiteroman committed Jul 24, 2024
1 parent 2c149cb commit 68adc95
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 20 deletions.
51 changes: 31 additions & 20 deletions app/src/main/java/es/chiteroman/playintegrityfix/EntryPoint.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import android.util.Base64;
import android.util.Log;

import org.json.JSONException;
import org.json.JSONObject;
import org.lsposed.hiddenapibypass.HiddenApiBypass;

Expand All @@ -20,6 +21,7 @@
import java.security.Provider;
import java.security.Security;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Objects;

Expand Down Expand Up @@ -75,8 +77,6 @@ public final class EntryPoint {

Security.removeProvider("AndroidKeyStore");
Security.insertProviderAt(customProvider, 1);

spoofPackageManager();
}

private static void spoofPackageManager() {
Expand Down Expand Up @@ -139,37 +139,48 @@ private static Field findField(Class<?> currentClass, String fieldName) throws N
}

public static void init(String json) {
boolean spoofPackageManager = false;

if (TextUtils.isEmpty(json)) {
Log.e(TAG, "JSON is empty!");
} else {
try {
JSONObject jsonObject = new JSONObject(json);
JSONObject jsonObject = null;

jsonObject.keys().forEachRemaining(s -> {
try {
String value = jsonObject.getString(s);
try {
jsonObject = new JSONObject(json);
} catch (JSONException e) {
Log.e(TAG, "Can't parse json", e);
}

if (TextUtils.isEmpty(value)) return;
if (jsonObject == null || jsonObject.length() == 0) return;

Field field = getFieldByName(s);
Iterator<String> it = jsonObject.keys();

if (field == null) return;
while (it.hasNext()) {
String key = it.next();

map.put(field, value);
if ("SPOOF_PACKAGE_MANAGER".equals(key)) {
spoofPackageManager = true;
continue;
}

} catch (Throwable t) {
Log.e(TAG, "Error parsing JSON", t);
}
});
} catch (Throwable t) {
Log.e(TAG, "Error parsing JSON", t);
String value = "";
try {
value = jsonObject.getString(key);
} catch (JSONException e) {
Log.e(TAG, "Couldn't get value from key", e);
}

if (TextUtils.isEmpty(value)) continue;

Field field = getFieldByName(key);

if (field == null) continue;

map.put(field, value);
}

Log.i(TAG, "Fields ready to spoof: " + map.size());

spoofFields();
if (spoofPackageManager) spoofPackageManager();
}

static void spoofFields() {
Expand Down
1 change: 1 addition & 0 deletions module/pif.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@
"PRODUCT": "husky_beta",
"SECURITY_PATCH": "2024-06-05",
"DEVICE_INITIAL_SDK_INT": 21,
"SPOOF_PACKAGE_MANAGER": true,
"DEBUG": false
}

0 comments on commit 68adc95

Please sign in to comment.