|
@@ -1,5 +1,9 @@
|
|
|
package com.example.modifiermodule;
|
|
package com.example.modifiermodule;
|
|
|
|
|
|
|
|
|
|
+import android.content.AttributionSource;
|
|
|
|
|
+import android.net.ConnectivityManager;
|
|
|
|
|
+import android.net.NetworkInfo;
|
|
|
|
|
+
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
|
|
|
import de.robv.android.xposed.XC_MethodHook;
|
|
import de.robv.android.xposed.XC_MethodHook;
|
|
@@ -52,7 +56,7 @@ public class HookSystem extends BaseHook {
|
|
|
@Override
|
|
@Override
|
|
|
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
|
|
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
|
|
|
String[] old = (String[]) param.getResult();
|
|
String[] old = (String[]) param.getResult();
|
|
|
- String[] macs = new String[]{getProperty(PROP_MAC, "")};
|
|
|
|
|
|
|
+ String[] macs = new String[]{getProperty(PROP_WIFI_MAC, "")};
|
|
|
if (old == null) {
|
|
if (old == null) {
|
|
|
log(String.format("getFactoryMacAddresses(): null -> %s", param.getResult(), macs[0]));
|
|
log(String.format("getFactoryMacAddresses(): null -> %s", param.getResult(), macs[0]));
|
|
|
} else {
|
|
} else {
|
|
@@ -65,7 +69,7 @@ public class HookSystem extends BaseHook {
|
|
|
XposedHelpers.findAndHookMethod(WifiServiceImpl, "getConnectionInfo", String.class, String.class, new XC_MethodHook() {
|
|
XposedHelpers.findAndHookMethod(WifiServiceImpl, "getConnectionInfo", String.class, String.class, new XC_MethodHook() {
|
|
|
@Override
|
|
@Override
|
|
|
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
|
|
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
|
|
|
- String mac = getProperty(PROP_MAC, "");
|
|
|
|
|
|
|
+ String mac = getProperty(PROP_WIFI_MAC, "");
|
|
|
String bssid = getProperty(PROP_BSSID, "");
|
|
String bssid = getProperty(PROP_BSSID, "");
|
|
|
log(String.format("getConnectionInfo(%s, %s)", param.args[0], param.args[1]));
|
|
log(String.format("getConnectionInfo(%s, %s)", param.args[0], param.args[1]));
|
|
|
log(String.format(" mac: %s -> %s", XposedHelpers.getObjectField(param.getResult(), "mMacAddress"), mac));
|
|
log(String.format(" mac: %s -> %s", XposedHelpers.getObjectField(param.getResult(), "mMacAddress"), mac));
|
|
@@ -74,6 +78,36 @@ public class HookSystem extends BaseHook {
|
|
|
XposedHelpers.setObjectField(param.getResult(), "mBSSID", bssid);
|
|
XposedHelpers.setObjectField(param.getResult(), "mBSSID", bssid);
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
|
|
+ } else if (name.equals("com.android.server.bluetooth.BluetoothService")) {
|
|
|
|
|
+ ClassLoader classLoader = (ClassLoader) param.args[1];
|
|
|
|
|
+ Class<?> BluetoothManagerService = XposedHelpers.findClass("com.android.server.bluetooth.BluetoothManagerService", classLoader);
|
|
|
|
|
+ XposedHelpers.findAndHookMethod(BluetoothManagerService, "getAddress", new XC_MethodHook() {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
|
|
|
|
|
+ AttributionSource attributionSource = (AttributionSource) param.args[0];
|
|
|
|
|
+ String packageName = attributionSource.getPackageName();
|
|
|
|
|
+ String mac = getProperty(PROP_BT_MAC, (String) param.getResult());
|
|
|
|
|
+ log(String.format("getAddress(%s): %s -> %s", packageName, param.getResult(), mac));
|
|
|
|
|
+ param.setResult(mac);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ } else if (name.equals("com.android.server.ConnectivityServiceInitializer")) {
|
|
|
|
|
+ ClassLoader classLoader = (ClassLoader) param.args[1];
|
|
|
|
|
+ Class<?> ConnectivityService = XposedHelpers.findClass("com.android.server.ConnectivityService", classLoader);
|
|
|
|
|
+ XposedHelpers.findAndHookMethod(ConnectivityService, "getNetworkInfo", int.class, new XC_MethodHook() {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
|
|
|
|
|
+ int networkType = (int) param.args[0];
|
|
|
|
|
+ log(String.format("getNetworkInfo(%d)", networkType));
|
|
|
|
|
+ if (networkType == ConnectivityManager.TYPE_ETHERNET && param.getResult() != null) {
|
|
|
|
|
+ NetworkInfo networkInfo = (NetworkInfo) param.getResult();
|
|
|
|
|
+ String mac = getProperty(PROP_ETH_MAC, networkInfo.getExtraInfo());
|
|
|
|
|
+ log(String.format(" .extra: %s -> %s", networkType, networkInfo.getExtraInfo(), mac));
|
|
|
|
|
+ XposedHelpers.setObjectField(networkInfo, "mExtraInfo", mac);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|