Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
R
ratelvirtuallocation
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ratel-modules
ratelvirtuallocation
Commits
17dc28fd
Commit
17dc28fd
authored
Nov 03, 2020
by
Tsaiilin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix TencentMap fake location
parent
157adb29
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
14 deletions
+40
-14
build.gradle
app/build.gradle
+2
-1
XPosedPlugin.java
...ain/java/top/littlerich/virtuallocation/XPosedPlugin.java
+38
-13
No files found.
app/build.gradle
View file @
17dc28fd
...
...
@@ -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'
}
app/src/main/java/top/littlerich/virtuallocation/XPosedPlugin.java
View file @
17dc28fd
...
...
@@ -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
(
TencentLocationListenerC
lass
)
.
parentClassLoader
(
TencentLocationListenerC
lass
.
getClassLoader
())
.
onlyMethods
(
TencentLocationListenerC
lass
.
getDeclaredMethods
())
.
forClass
(
tencentLocationListenerSubc
lass
)
.
parentClassLoader
(
tencentLocationListenerSubc
lass
.
getClassLoader
())
.
onlyMethods
(
tencentLocationListenerSubc
lass
.
getDeclaredMethods
())
.
handler
(
invocationHandler
).
build
();
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment