This repository has been archived by the owner on Sep 6, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 527
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Play services 5.0 restrictions - proof of concept
- Loading branch information
Showing
5 changed files
with
169 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package biz.bokhorst.xprivacy; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import android.os.Binder; | ||
import android.util.Log; | ||
|
||
public class XConnectionCallbacks extends XHook { | ||
private Methods mMethod; | ||
private String mClassName; | ||
|
||
private XConnectionCallbacks(Methods method, String restrictionName, String className) { | ||
super(restrictionName, method.name(), "GAC." + method.name()); | ||
mMethod = method; | ||
mClassName = className; | ||
} | ||
|
||
public String getClassName() { | ||
return mClassName; | ||
} | ||
|
||
// @formatter:off | ||
|
||
// abstract void onConnected(Bundle connectionHint) | ||
// https://developer.android.com/reference/com/google/android/gms/common/api/GoogleApiClient.ConnectionCallbacks.html | ||
|
||
// @formatter:on | ||
|
||
private enum Methods { | ||
onConnected | ||
}; | ||
|
||
public static List<XHook> getInstances(Object instance) { | ||
String className = instance.getClass().getName(); | ||
Util.log(null, Log.INFO, "Hooking class=" + className + " uid=" + Binder.getCallingUid()); | ||
|
||
List<XHook> listHook = new ArrayList<XHook>(); | ||
listHook.add(new XConnectionCallbacks(Methods.onConnected, null, className)); | ||
return listHook; | ||
} | ||
|
||
@Override | ||
protected void before(XParam param) throws Throwable { | ||
switch (mMethod) { | ||
case onConnected: | ||
ClassLoader loader = param.thisObject.getClass().getClassLoader(); | ||
Class<?> cLoc = Class.forName("com.google.android.gms.location.LocationServices", false, loader); | ||
Object fusedLocationApi = cLoc.getDeclaredField("FusedLocationApi").get(null); | ||
Util.log(this, Log.WARN, "FusedLocationApi class=" + fusedLocationApi.getClass()); | ||
|
||
Class<?> cRec = Class.forName("com.google.android.gms.location.ActivityRecognition", false, loader); | ||
Object activityRecognitionApi = cRec.getDeclaredField("ActivityRecognitionApi").get(null); | ||
Util.log(this, Log.WARN, "ActivityRecognitionApi class=" + activityRecognitionApi.getClass()); | ||
|
||
break; | ||
} | ||
} | ||
|
||
@Override | ||
protected void after(XParam param) throws Throwable { | ||
// Do nothing | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package biz.bokhorst.xprivacy; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class XGoogleApiClient extends XHook { | ||
private Methods mMethod; | ||
|
||
private XGoogleApiClient(Methods method, String restrictionName) { | ||
super(restrictionName, method.name(), "GAC." + method.name()); | ||
mMethod = method; | ||
} | ||
|
||
public String getClassName() { | ||
return "com.google.android.gms.common.api.GoogleApiClient$Builder"; | ||
} | ||
|
||
// @formatter:off | ||
|
||
// GoogleApiClient.Builder addConnectionCallbacks(GoogleApiClient.ConnectionCallbacks listener) | ||
// https://developer.android.com/reference/com/google/android/gms/common/api/GoogleApiClient.Builder.html | ||
|
||
// @formatter:on | ||
|
||
private enum Methods { | ||
addConnectionCallbacks | ||
}; | ||
|
||
public static List<XHook> getInstances() { | ||
Util.log(null, android.util.Log.WARN, "Loaded GAC"); | ||
List<XHook> listHook = new ArrayList<XHook>(); | ||
listHook.add(new XGoogleApiClient(Methods.addConnectionCallbacks, null)); | ||
return listHook; | ||
} | ||
|
||
@Override | ||
protected void before(XParam param) throws Throwable { | ||
switch (mMethod) { | ||
case addConnectionCallbacks: | ||
if (param.args.length > 0 && param.args[0] != null) { | ||
Class<?> clazz = param.args[0].getClass(); | ||
if (PrivacyManager.getTransient(clazz.getName(), null) == null) { | ||
PrivacyManager.setTransient(clazz.getName(), Boolean.toString(true)); | ||
XPrivacy.hookAll(XConnectionCallbacks.getInstances(param.args[0]), clazz.getClassLoader(), | ||
getSecret()); | ||
} | ||
} | ||
break; | ||
} | ||
} | ||
|
||
@Override | ||
protected void after(XParam param) throws Throwable { | ||
// Do nothing | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters