Commit 17dc28fd authored by Tsaiilin's avatar Tsaiilin

fix TencentMap fake location

parent 157adb29
......@@ -55,5 +55,6 @@ dependencies {
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
compileOnly 'com.virjar:ratel-api:1.3.4'
compileOnly 'com.virjar:ratel-api:1.3.5'
implementation 'com.virjar:ratel-extersion:1.0.6'
}
......@@ -7,13 +7,18 @@ import android.os.Bundle;
import android.util.Log;
import com.virjar.ratel.api.RatelToolKit;
import com.virjar.ratel.api.extension.FileLogger;
import com.virjar.ratel.api.inspect.ClassLoadMonitor;
import com.virjar.ratel.api.inspect.ForceFiledViewer;
import com.virjar.ratel.api.rposed.IRposedHookLoadPackage;
import com.virjar.ratel.api.rposed.RC_MethodHook;
import com.virjar.ratel.api.rposed.RposedBridge;
import com.virjar.ratel.api.rposed.RposedHelpers;
import com.virjar.ratel.api.rposed.callbacks.RC_LoadPackage;
import org.json.JSONObject;
import java.io.File;
import java.io.IOException;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
......@@ -50,6 +55,8 @@ public class XPosedPlugin implements IRposedHookLoadPackage {
handleTencent();
handleOriginal();
Log.i(TAG, "virtual location component init success!!");
}
private static void handleOriginal() {
......@@ -112,10 +119,13 @@ public class XPosedPlugin implements IRposedHookLoadPackage {
private static void handleTencent() {
//com.tencent.map.geolocation.TencentLocationManager
//com.tencent.map.geolocation.TencentLocationListener
ClassLoadMonitor.addClassLoadMonitor("com.tencent.map.geolocation.TencentLocationManager", new ClassLoadMonitor.OnClassLoader() {
@Override
public void onClassLoad(Class<?> clazz) {
public void onClassLoad(final Class<?> clazz) {
Log.i(AppApplication.tag, "命中腾讯API:" + clazz);
// public final int requestLocationUpdates(TencentLocationRequest var1, TencentLocationListener var2) {
// public final int requestLocationUpdates(TencentLocationRequest var1, TencentLocationListener var2, Looper var3) {
......@@ -126,8 +136,8 @@ public class XPosedPlugin implements IRposedHookLoadPackage {
RC_MethodHook replaceLocationListenerHook = new RC_MethodHook() {
private Object produceTencentLocation(final Object tencentLocation) throws IOException {
Class<?> TencentLocationClass = tencentLocation.getClass();
private Object produceTencentLocation(final Object tencentLocation, Class<?> TencentLocationClass) throws IOException {
// Class<?> TencentLocationClass = tencentLocation.getClass();
InvocationHandler invocationHandler = new InvocationHandler() {
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
......@@ -138,7 +148,11 @@ public class XPosedPlugin implements IRposedHookLoadPackage {
} else if (method.getName().equals("getAddress")) {
return AppApplication.mockGPS.address;
}
return RposedHelpers.callMethod(tencentLocation, method.getName(), args);
if (args == null) {
return RposedHelpers.callMethod(tencentLocation, method.getName());
} else {
return RposedHelpers.callMethod(tencentLocation, method.getName(), args);
}
}
};
......@@ -160,10 +174,13 @@ public class XPosedPlugin implements IRposedHookLoadPackage {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
//com.tencent.map.geolocation.TencentLocationListener
for (int i = 0; i < param.args.length; i++) {
Class<?> TencentLocationListenerClass = param.args[i].getClass();
if (!TencentLocationListenerClass.getName().equals("com.tencent.map.geolocation.TencentLocationListener")) {
Class<?> tencentLocationListenerSubclass = param.args[i].getClass();
Class<?> TencentLocationListenerClass = RposedHelpers.findClass("com.tencent.map.geolocation.TencentLocationListener", clazz.getClassLoader());
if (!TencentLocationListenerClass.isAssignableFrom(tencentLocationListenerSubclass)) {
continue;
}
final Object originListener = param.args[i];
......@@ -174,18 +191,26 @@ public class XPosedPlugin implements IRposedHookLoadPackage {
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
// Debug.waitForDebugger();
if (method.getName().equals("onLocationChanged")) {
Class<?> TencentLocationClass = RposedHelpers.findClass("com.tencent.map.geolocation.TencentLocation", clazz.getClassLoader());
// void onLocationChanged(com.tencent.map.geolocation.TencentLocation var1);
for (int j = 0; j < args.length; j++) {
Object tencentLocation = args[j];
if (!(tencentLocation.getClass().getName().equals("com.tencent.map.geolocation.TencentLocation"))) {
if (!TencentLocationClass.isAssignableFrom(args[j].getClass())) {
continue;
}
//TODO
args[j] = produceTencentLocation(tencentLocation);
args[j] = produceTencentLocation(tencentLocation, TencentLocationClass);
break;
}
}
return RposedHelpers.callMethod(originListener, method.getName(), args);
if (args == null) {
return RposedHelpers.callMethod(originListener, method.getName());
} else {
return RposedHelpers.callMethod(originListener, method.getName(), args);
}
}
};
Object proxyListener;
......@@ -195,9 +220,9 @@ public class XPosedPlugin implements IRposedHookLoadPackage {
);
} else {
proxyListener = RatelToolKit.dexMakerProxyBuilderHelper
.forClass(TencentLocationListenerClass)
.parentClassLoader(TencentLocationListenerClass.getClassLoader())
.onlyMethods(TencentLocationListenerClass.getDeclaredMethods())
.forClass(tencentLocationListenerSubclass)
.parentClassLoader(tencentLocationListenerSubclass.getClassLoader())
.onlyMethods(tencentLocationListenerSubclass.getDeclaredMethods())
.handler(invocationHandler).build();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment