Skip to content
This repository has been archived by the owner on Sep 6, 2019. It is now read-only.

Commit

Permalink
Added restrictions Cast.getDeviceId/getIpAddress
Browse files Browse the repository at this point in the history
Fixes #2108
  • Loading branch information
M66B committed Jan 9, 2015
1 parent cd42fac commit c34231b
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Changelog

* Prevent accidental application name clicks ([issue](/../../issues/2109))
* Fixed restriction *USB.getSerialNumber*
* Added restriction *Cast.getDeviceId* and *Cast.getIpAddress* ([issue](/../../issues/2108))

[Open issues](https://github.com/M66B/XPrivacy/issues?state=open)

Expand Down
2 changes: 2 additions & 0 deletions res/values/functions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@
<string name="identification_USB_getDeviceName" translatable="false"><![CDATA[<a href="https://developer.android.com/reference/android/hardware/usb/UsbDevice.html#getDeviceName()">Google documentation</a>]]></string>
<string name="identification_USB_getSerialNumber" translatable="false"><![CDATA[<a href="https://developer.android.com/reference/android/hardware/usb/UsbDevice.html#getSerialNumber()">Google documentation</a>]]></string>
<string name="identification_Srv_Android_ID" translatable="false"><![CDATA[<a href="https://developer.android.com/reference/android/provider/Settings.Secure.html#ANDROID_ID">Google documentation</a>]]></string>
<string name="identification_Cast_getDeviceId" translatable="false"><![CDATA[<a href="http://developer.android.com/reference/com/google/android/gms/cast/CastDevice.html#getDeviceId()">Google documentation</a>]]></string>
<string name="identification_Cast_getIpAddress" translatable="false"><![CDATA[<a href="http://developer.android.com/reference/com/google/android/gms/cast/CastDevice.html#getIpAddress()">Google documentation</a>]]></string>

<!-- internet -->
<string name="internet_NetworkInterface_getByIndex" translatable="false"><![CDATA[<a href="https://developer.android.com/reference/java/net/NetworkInterface.html#getByIndex(int)">Google documentation</a>]]></string>
Expand Down
3 changes: 3 additions & 0 deletions src/biz/bokhorst/xprivacy/Meta.java
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,9 @@ public static List<Hook> get() {

mListHook.add(new Hook("identification", "Srv_Android_ID", "", 19, "2.99", "getString").AOSP(19));

mListHook.add(new Hook("identification", "Cast.getDeviceId", "", 1, "3.5.11", null).unsafe());
mListHook.add(new Hook("identification", "Cast.getIpAddress", "", 1, "3.5.11", null).unsafe());

// java.net.NetworkInterface
mListHook.add(new Hook("internet", "NetworkInterface.getByIndex", "INTERNET", 19, "2.2.2", null).unsafe());
mListHook.add(new Hook("internet", "NetworkInterface.getByInetAddress", "INTERNET", 1, "2.2.2", "getByInetAddress").unsafe());
Expand Down
3 changes: 3 additions & 0 deletions src/biz/bokhorst/xprivacy/PrivacyManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -1155,6 +1155,9 @@ public static Object getDefacedProp(int uid, String name) {
if (name.equals("BTName"))
return cDeface;

if (name.equals("CastID"))
return cDeface;

// Fallback
Util.log(null, Log.ERROR, "Fallback value name=" + name);
Util.logStack(null, Log.ERROR);
Expand Down
56 changes: 56 additions & 0 deletions src/biz/bokhorst/xprivacy/XCastDevice.java
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;

import android.os.Binder;
import biz.bokhorst.xprivacy.XHook;

public class XCastDevice extends XHook {
private Methods mMethod;

private XCastDevice(Methods method, String restrictionName) {
super(restrictionName, method.name(), "Cast." + method.name());
mMethod = method;
}

public String getClassName() {
return "com.google.android.gms.cast.CastDevice";
}

// public static getDeviceId()
// public Inet4Address getIpAddress()
// http://developer.android.com/reference/com/google/android/gms/cast/CastDevice.html

private enum Methods {
getDeviceId, getIpAddress
};

public static List<XHook> getInstances() {
List<XHook> listHook = new ArrayList<XHook>();
listHook.add(new XCastDevice(Methods.getDeviceId, PrivacyManager.cIdentification));
listHook.add(new XCastDevice(Methods.getIpAddress, PrivacyManager.cIdentification));
return listHook;
}

@Override
protected void before(XParam param) throws Throwable {
// Do nothing
}

@Override
protected void after(XParam param) throws Throwable {
// Do nothing
switch (mMethod) {
case getDeviceId:
if (param.getResult() != null && isRestricted(param))
param.setResult(PrivacyManager.getDefacedProp(Binder.getCallingUid(), "CastID"));
break;

case getIpAddress:
if (param.getResult() != null && isRestricted(param))
param.setResult(PrivacyManager.getDefacedProp(Binder.getCallingUid(), "InetAddress"));
break;
}
}
}
7 changes: 7 additions & 0 deletions src/biz/bokhorst/xprivacy/XPrivacy.java
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,13 @@ private static void handleLoadPackage(String packageName, ClassLoader classLoade
} catch (Throwable ignored) {
}

// Cast device
try {
Class.forName("com.google.android.gms.cast.CastDevice", false, classLoader);
hookAll(XCastDevice.getInstances(), classLoader, secret);
} catch (Throwable ignored) {
}

// Google auth
try {
Class.forName("com.google.android.gms.auth.GoogleAuthUtil", false, classLoader);
Expand Down

0 comments on commit c34231b

Please sign in to comment.