|
|
@@ -1,49 +1,116 @@
|
|
|
package com.example.modifiermodule;
|
|
|
|
|
|
import android.annotation.SuppressLint;
|
|
|
+import android.app.Application;
|
|
|
+import android.content.ContentResolver;
|
|
|
+import android.content.Context;
|
|
|
+import android.database.Cursor;
|
|
|
+import android.net.Uri;
|
|
|
import android.text.TextUtils;
|
|
|
+import android.util.Base64;
|
|
|
import android.util.Log;
|
|
|
|
|
|
+import org.apache.commons.io.FileUtils;
|
|
|
+import org.json.JSONObject;
|
|
|
+
|
|
|
+import java.io.File;
|
|
|
import java.lang.reflect.Method;
|
|
|
+import java.nio.charset.StandardCharsets;
|
|
|
|
|
|
import de.robv.android.xposed.XposedBridge;
|
|
|
+import de.robv.android.xposed.XposedHelpers;
|
|
|
|
|
|
public class BaseHook {
|
|
|
- static final String PROP_MCC = "persist.spoof.mcc";
|
|
|
- static final String PROP_MNC = "persist.spoof.mnc";
|
|
|
- static final String PROP_ICCID = "persist.spoof.iccid";
|
|
|
- static final String PROP_IMSI = "persist.spoof.imsi";
|
|
|
- static final String PROP_IMEI = "persist.spoof.imei";
|
|
|
- static final String PROP_NUMBER = "persist.spoof.number";
|
|
|
- static final String PROP_COUNTRY = "persist.spoof.country";
|
|
|
- static final String PROP_CARRIER_ID = "persist.spoof.carrier.id";
|
|
|
- static final String PROP_CARRIER_NAME = "persist.spoof.carrier.name";
|
|
|
- static final String PROP_UPI_POLICY = "persist.spoof.upi.policy";
|
|
|
+// static final String PROP_MCC = "persist.spoof.mcc";
|
|
|
+// static final String PROP_MNC = "persist.spoof.mnc";
|
|
|
+// static final String PROP_ICCID = "persist.spoof.iccid";
|
|
|
+// static final String PROP_IMSI = "persist.spoof.imsi";
|
|
|
+// static final String PROP_IMEI = "persist.spoof.imei";
|
|
|
+// static final String PROP_NUMBER = "persist.spoof.number";
|
|
|
+// static final String PROP_COUNTRY = "persist.spoof.country";
|
|
|
+// static final String PROP_CARRIER_ID = "persist.spoof.carrier.id";
|
|
|
+// static final String PROP_CARRIER_NAME = "persist.spoof.carrier.name";
|
|
|
+// static final String PROP_UPI_POLICY = "persist.spoof.upi.policy";
|
|
|
+
|
|
|
+ static final String PROP_MCC = "mcc";
|
|
|
+ static final String PROP_MNC = "mnc";
|
|
|
+ static final String PROP_ICCID = "iccid";
|
|
|
+ static final String PROP_IMSI = "imsi";
|
|
|
+ static final String PROP_IMEI = "imei";
|
|
|
+ static final String PROP_NUMBER = "number";
|
|
|
+ static final String PROP_COUNTRY = "country";
|
|
|
+ static final String PROP_CARRIER_ID = "carrier_id";
|
|
|
+ static final String PROP_CARRIER_NAME = "carrier_name";
|
|
|
+ static final String PROP_UPI_POLICY = "upi_policy";
|
|
|
|
|
|
static final String TAG = "Modifier";
|
|
|
|
|
|
+ public BaseHook(ClassLoader classLoader) {
|
|
|
+ this.classLoader = classLoader;
|
|
|
+ }
|
|
|
+
|
|
|
static void log(String message) {
|
|
|
Log.i(TAG, message);
|
|
|
XposedBridge.log(TAG + ": " + message);
|
|
|
}
|
|
|
|
|
|
+ private ClassLoader classLoader;
|
|
|
+
|
|
|
+// @SuppressLint("PrivateApi")
|
|
|
+// public String getProperty(String key, String defaultValue) {
|
|
|
+// String value = defaultValue;
|
|
|
+// try {
|
|
|
+// Class<?> c = Class.forName("android.os.SystemProperties");
|
|
|
+// Method get = c.getMethod("get", String.class, String.class);
|
|
|
+// value = (String) (get.invoke(c, key, defaultValue));
|
|
|
+// if (TextUtils.isEmpty(value)) {
|
|
|
+// value = defaultValue;
|
|
|
+// }
|
|
|
+// } catch (Exception e) {
|
|
|
+// e.printStackTrace();
|
|
|
+// }
|
|
|
+// return value;
|
|
|
+// }
|
|
|
+//
|
|
|
+// public int getIntProperty(String key, int defaultValue) {
|
|
|
+// int value = defaultValue;
|
|
|
+// try {
|
|
|
+// String prop = getProperty(key, String.valueOf(defaultValue));
|
|
|
+// if (TextUtils.isEmpty(prop)) {
|
|
|
+// return defaultValue;
|
|
|
+// }
|
|
|
+// value = Integer.parseInt(prop);
|
|
|
+// } catch (NumberFormatException e) {
|
|
|
+// e.printStackTrace();
|
|
|
+// }
|
|
|
+// return value;
|
|
|
+// }
|
|
|
+
|
|
|
@SuppressLint("PrivateApi")
|
|
|
- static String getProperty(String key, String defaultValue) {
|
|
|
+ public String getProperty(String key, String defaultValue) {
|
|
|
+ log("getProperty: " + key);
|
|
|
String value = defaultValue;
|
|
|
try {
|
|
|
- Class<?> c = Class.forName("android.os.SystemProperties");
|
|
|
- Method get = c.getMethod("get", String.class, String.class);
|
|
|
- value = (String) (get.invoke(c, key, defaultValue));
|
|
|
- if (TextUtils.isEmpty(value)) {
|
|
|
- value = defaultValue;
|
|
|
+ Context context = getContext();
|
|
|
+ File configFile = new File(context.getExternalFilesDir("config"), "config.json");
|
|
|
+ if (configFile.exists()) {
|
|
|
+
|
|
|
+ String jsonBase64 = FileUtils.readFileToString(configFile, StandardCharsets.UTF_8);
|
|
|
+ if (!TextUtils.isEmpty(jsonBase64)) {
|
|
|
+ JSONObject jsonObject = new JSONObject(new String(Base64.decode(jsonBase64, Base64.DEFAULT)));
|
|
|
+ if (jsonObject.has(key)) {
|
|
|
+ value = jsonObject.getString(key);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
+ log("getProperty: " + e.getMessage());
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
return value;
|
|
|
}
|
|
|
|
|
|
- static int getIntProperty(String key, int defaultValue) {
|
|
|
+ public int getIntProperty(String key, int defaultValue) {
|
|
|
int value = defaultValue;
|
|
|
try {
|
|
|
String prop = getProperty(key, String.valueOf(defaultValue));
|
|
|
@@ -56,4 +123,11 @@ public class BaseHook {
|
|
|
}
|
|
|
return value;
|
|
|
}
|
|
|
+
|
|
|
+ public Context getContext() {
|
|
|
+ Class<?> ActivityThread = XposedHelpers.findClass("android.app.ActivityThread", classLoader);
|
|
|
+ Object currentActivityThread = XposedHelpers.callStaticMethod(ActivityThread, "currentActivityThread");
|
|
|
+ Application application = (Application) XposedHelpers.callMethod(currentActivityThread, "getApplication");
|
|
|
+ return application.getApplicationContext();
|
|
|
+ }
|
|
|
}
|