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

Commit

Permalink
Added restrictions for LinkProperties
Browse files Browse the repository at this point in the history
  • Loading branch information
M66B committed Dec 15, 2014
1 parent 071f482 commit 5378bbd
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 10 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Changelog
* Added quirk *nousage* to disable usage data for specific applications ([issue](/../../issues/2085))
* Added restrictions for [UsageStatsManager](https://developer.android.com/reference/android/app/usage/UsageStatsManager.html) ([issue](/../../issues/1757))
* Added restrictions *IpPrefix.getAddress* and *IpPrefix.getRawAddress* ([issue](/../../issues/1757))
* Added restrictions for [LinkProperties](http://developer.android.com/reference/android/net/LinkProperties.html)

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

Expand Down
21 changes: 13 additions & 8 deletions res/values/functions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
<string name="identification_InputDevice_getName" translatable="false"><![CDATA[<a href="https://developer.android.com/reference/android/view/InputDevice.html#getName()">Google documentation</a>]]></string>
<string name="identification_USB_getDeviceId" translatable="false"><![CDATA[<a href="https://developer.android.com/reference/android/hardware/usb/UsbDevice.html#getDeviceId(java.lang.String)">Google documentation</a>]]></string>
<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="http://developer.android.com/reference/android/hardware/usb/UsbDevice.html#getSerialNumber()">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>

<!-- internet -->
Expand All @@ -115,13 +115,18 @@
<string name="internet_NetworkInfo_getState" translatable="false"><![CDATA[<a href="https://developer.android.com/reference/android/net/NetworkInfo.html#getState()">Google documentation</a>]]></string>
<string name="internet_NetworkInfo_isConnected" translatable="false"><![CDATA[<a href="https://developer.android.com/reference/android/net/NetworkInfo.html#isConnected()">Google documentation</a>]]></string>
<string name="internet_NetworkInfo_isConnectedOrConnecting" translatable="false"><![CDATA[<a href="https://developer.android.com/reference/android/net/NetworkInfo.html#isConnectedOrConnecting()">Google documentation</a>]]></string>
<string name="internet_WiFi_getConnectionInfo" translatable="false"><![CDATA[<a href="http://developer.android.com/reference/android/net/wifi/SupplicantState.html">Google documentation</a>]]></string>
<string name="internet_WiFi_Srv_getConnectionInfo" translatable="false"><![CDATA[<a href="http://developer.android.com/reference/android/net/wifi/SupplicantState.html">Google documentation</a>]]></string>
<string name="internet_WiFi_getConnectionInfo" translatable="false"><![CDATA[<a href="https://developer.android.com/reference/android/net/wifi/SupplicantState.html">Google documentation</a>]]></string>
<string name="internet_WiFi_Srv_getConnectionInfo" translatable="false"><![CDATA[<a href="https://developer.android.com/reference/android/net/wifi/SupplicantState.html">Google documentation</a>]]></string>
<string name="internet_InetAddress_getAllByName" translatable="false"><![CDATA[<a href="https://developer.android.com/reference/java/net/InetAddress.html#getAllByName(java.lang.String)">Google documentation</a>]]></string>
<string name="internet_InetAddress_getByAddress" translatable="false"><![CDATA[<a href="https://developer.android.com/reference/java/net/InetAddress.html#getByAddress(java.lang.String,%20byte[])">Google documentation</a>]]></string>
<string name="internet_InetAddress_getByName" translatable="false"><![CDATA[<a href="https://developer.android.com/reference/java/net/InetAddress.html#getByName(java.lang.String)">Google documentation</a>]]></string>
<string name="internet_IpPrefix_getAddress" translatable="false"><![CDATA[<a href="https://developer.android.com/reference/android/net/IpPrefix.html#getAddress()">Google documentation</a>]]></string>
<string name="internet_IpPrefix_getRawAddress" translatable="false"><![CDATA[<a href="https://developer.android.com/reference/android/net/IpPrefix.html#getRawAddress()">Google documentation</a>]]></string>
<string name="internet_LinkProperties_getAddresses" translatable="false"><![CDATA[<a href="https://developer.android.com/reference/android/net/LinkProperties.html#getLinkAddresses()">Google documentation</a>]]></string>
<string name="internet_LinkProperties_getAllAddresses" translatable="false"><![CDATA[<a href="https://developer.android.com/reference/android/net/LinkProperties.html#getLinkAddresses()">Google documentation</a>]]></string>
<string name="internet_LinkProperties_getAllLinkAddresses" translatable="false"><![CDATA[<a href=https://developer.android.com/reference/android/net/LinkProperties.html#getLinkAddresses()">Google documentation</a>]]></string>
<string name="internet_LinkProperties_getLinkAddresses" translatable="false"><![CDATA[<a href="https://developer.android.com/reference/android/net/LinkProperties.html#getLinkAddresses()">Google documentation</a>]]></string>
<string name="internet_LinkProperties_getStackedLinks" translatable="false"><![CDATA[<a href="https://developer.android.com/reference/android/net/LinkProperties.html#getLinkAddresses()">Google documentation</a>]]></string>
<string name="internet_connect" translatable="false"><![CDATA[Will restrict access to the internet]]></string>

<!-- ipc -->
Expand Down Expand Up @@ -188,10 +193,10 @@
<string name="media_Camera_setOneShotPreviewCallback" translatable="false"><![CDATA[<a href="https://developer.android.com/reference/android/hardware/Camera.html#setOneShotPreviewCallback(android.hardware.Camera.PreviewCallback)">Google documentation</a>]]></string>
<string name="media_Camera_startPreview" translatable="false"><![CDATA[<a href="https://developer.android.com/reference/android/hardware/Camera.html#startPreview()">Google documentation</a>]]></string>
<string name="media_Camera_takePicture" translatable="false"><![CDATA[<a href="https://developer.android.com/reference/android/hardware/Camera.html#takePicture(android.hardware.Camera.ShutterCallback,%20android.hardware.Camera.PictureCallback,%20android.hardware.Camera.PictureCallback)">Google documentation</a>]]></string>
<string name="media_Camera2_capture" translatable="false"><![CDATA[<a href="http://developer.android.com/reference/android/hardware/camera2/CameraCaptureSession.html#capture(android.hardware.camera2.CaptureRequest,%20android.hardware.camera2.CameraCaptureSession.CaptureCallback,%20android.os.Handler)">Google documentation</a>]]></string>
<string name="media_Camera2_captureBurst" translatable="false"><![CDATA[<a href="http://developer.android.com/reference/android/hardware/camera2/CameraCaptureSession.html#captureBurst(java.util.List<android.hardware.camera2.CaptureRequest>,%20android.hardware.camera2.CameraCaptureSession.CaptureCallback,%20android.os.Handler)">Google documentation</a>]]></string>
<string name="media_Camera2_setRepeatingBurst" translatable="false"><![CDATA[<a href="http://developer.android.com/reference/android/hardware/camera2/CameraCaptureSession.html#setRepeatingBurst(java.util.List<android.hardware.camera2.CaptureRequest>,%20android.hardware.camera2.CameraCaptureSession.CaptureCallback,%20android.os.Handler)">Google documentation</a>]]></string>
<string name="media_Camera2_setRepeatingRequest" translatable="false"><![CDATA[<a href="http://developer.android.com/reference/android/hardware/camera2/CameraCaptureSession.html#setRepeatingRequest(android.hardware.camera2.CaptureRequest,%20android.hardware.camera2.CameraCaptureSession.CaptureCallback,%20android.os.Handler)">Google documentation</a>]]></string>
<string name="media_Camera2_capture" translatable="false"><![CDATA[<a href="https://developer.android.com/reference/android/hardware/camera2/CameraCaptureSession.html#capture(android.hardware.camera2.CaptureRequest,%20android.hardware.camera2.CameraCaptureSession.CaptureCallback,%20android.os.Handler)">Google documentation</a>]]></string>
<string name="media_Camera2_captureBurst" translatable="false"><![CDATA[<a href="https://developer.android.com/reference/android/hardware/camera2/CameraCaptureSession.html#captureBurst(java.util.List<android.hardware.camera2.CaptureRequest>,%20android.hardware.camera2.CameraCaptureSession.CaptureCallback,%20android.os.Handler)">Google documentation</a>]]></string>
<string name="media_Camera2_setRepeatingBurst" translatable="false"><![CDATA[<a href="https://developer.android.com/reference/android/hardware/camera2/CameraCaptureSession.html#setRepeatingBurst(java.util.List<android.hardware.camera2.CaptureRequest>,%20android.hardware.camera2.CameraCaptureSession.CaptureCallback,%20android.os.Handler)">Google documentation</a>]]></string>
<string name="media_Camera2_setRepeatingRequest" translatable="false"><![CDATA[<a href="https://developer.android.com/reference/android/hardware/camera2/CameraCaptureSession.html#setRepeatingRequest(android.hardware.camera2.CaptureRequest,%20android.hardware.camera2.CameraCaptureSession.CaptureCallback,%20android.os.Handler)">Google documentation</a>]]></string>
<string name="media_MediaRecorder_setOutputFile" translatable="false"><![CDATA[<a href="https://developer.android.com/reference/android/media/MediaRecorder.html#setOutputFile(java.io.FileDescriptor)">Google documentation</a>]]></string>
<string name="media_MediaRecorder_start" translatable="false"><![CDATA[<a href="https://developer.android.com/reference/android/media/MediaRecorder.html#start()">Google documentation</a>]]></string>
<string name="media_android_media_action_IMAGE_CAPTURE" translatable="false"><![CDATA[<a href="https://developer.android.com/reference/android/provider/MediaStore.html#ACTION_IMAGE_CAPTURE">Google documentation</a>]]></string>
Expand Down Expand Up @@ -306,7 +311,7 @@
<!-- sensors -->
<string name="sensors_getDefaultSensor" translatable="false"><![CDATA[<a href="https://developer.android.com/reference/android/hardware/SensorManager.html#getDefaultSensor(int)">Google documentation</a>]]></string>
<string name="sensors_getSensorList" translatable="false"><![CDATA[<a href="https://developer.android.com/reference/android/hardware/SensorManager.html#getSensorList(int)">Google documentation</a>]]></string>
<string name="sensors_registerListener" translatable="false"><![CDATA[Will limit the rate of the gyroscope to 100 Hz to prevent eavesdropping<br /><br /><a href="http://developer.android.com/reference/android/hardware/SensorManager.html#registerListener(android.hardware.SensorEventListener,%20android.hardware.Sensor, int)">Google documentation</a>]]></string>
<string name="sensors_registerListener" translatable="false"><![CDATA[Will limit the rate of the gyroscope to 100 Hz to prevent eavesdropping<br /><br /><a href="https://developer.android.com/reference/android/hardware/SensorManager.html#registerListener(android.hardware.SensorEventListener,%20android.hardware.Sensor, int)">Google documentation</a>]]></string>
<string name="sensors_acceleration" translatable="false"><![CDATA[<a href="https://developer.android.com/reference/android/hardware/Sensor.html">Google documentation</a>]]></string>
<string name="sensors_gravity" translatable="false"><![CDATA[<a href="https://developer.android.com/reference/android/hardware/Sensor.html">Google documentation</a>]]></string>
<string name="sensors_humidity" translatable="false"><![CDATA[<a href="https://developer.android.com/reference/android/hardware/Sensor.html">Google documentation</a>]]></string>
Expand Down
11 changes: 9 additions & 2 deletions src/biz/bokhorst/xprivacy/Meta.java
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,15 @@ public static List<Hook> get() {
mListHook.add(new Hook("internet", "InetAddress.getByName", "INTERNET", 1, null, null).unsafe().dangerous().whitelist(cTypeIPAddress));

// android.net.IpPrefix
mListHook.add(new Hook("internet", "IpPrefix.getAddress", null, 21, "3.5.6", null).unsafe());
mListHook.add(new Hook("internet", "IpPrefix.getRawAddress", null, 21, "3.5.6", null).unsafe());
mListHook.add(new Hook("internet", "IpPrefix.getAddress", null, 21, "3.5.6", null).dangerous().unsafe());
mListHook.add(new Hook("internet", "IpPrefix.getRawAddress", null, 21, "3.5.6", null).dangerous().unsafe());

// android.net.LinkProperties
mListHook.add(new Hook("internet", "LinkProperties.getAddresses", null, 19, "3.5.6", null).dangerous().unsafe());
mListHook.add(new Hook("internet", "LinkProperties.getAllAddresses", null, 19, "3.5.6", null).dangerous().unsafe());
mListHook.add(new Hook("internet", "LinkProperties.getAllLinkAddresses", null, 19, "3.5.6", null).dangerous().unsafe());
mListHook.add(new Hook("internet", "LinkProperties.getLinkAddresses", null, 19, "3.5.6", null).dangerous().unsafe());
mListHook.add(new Hook("internet", "LinkProperties.getStackedLinks", null, 19, "3.5.6", null).dangerous().unsafe());

mListHook.add(new Hook("internet", "connect", null, 1, "1.99.45", null).unsafe().dangerous().whitelist(cTypeIPAddress));

Expand Down
70 changes: 70 additions & 0 deletions src/biz/bokhorst/xprivacy/XLinkProperties.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
package biz.bokhorst.xprivacy;

import java.net.InetAddress;
import java.util.ArrayList;
import java.util.List;

import android.net.LinkAddress;
import android.net.LinkProperties;

public class XLinkProperties extends XHook {
private Methods mMethod;

private XLinkProperties(Methods method, String restrictionName, String specifier) {
super(restrictionName, method.name(), "LinkProperties." + method.name());
mMethod = method;
}

public String getClassName() {
return "android.net.LinkProperties";
}

// public List<InetAddress> getAddresses()
// public List<InetAddress> getAllAddresses()
// public List<LinkAddress> getAllLinkAddresses()
// public List<LinkAddress> getLinkAddresses()
// public @NonNull List<LinkProperties> getStackedLinks()
// http://developer.android.com/reference/android/net/LinkProperties.html
// http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/5.0.0_r1/android/net/LinkProperties.java

private enum Methods {
getAddresses, getAllAddresses, getAllLinkAddresses, getLinkAddresses, getStackedLinks
};

public static List<XHook> getInstances() {
List<XHook> listHook = new ArrayList<XHook>();
for (Methods addr : Methods.values())
listHook.add(new XLinkProperties(addr, PrivacyManager.cInternet, null));
return listHook;
}

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

@Override
protected void after(XParam param) throws Throwable {
switch (mMethod) {
case getAddresses:
case getAllAddresses:
if (param.getResult() != null)
if (isRestricted(param))
param.setResult(new ArrayList<InetAddress>());
break;

case getAllLinkAddresses:
case getLinkAddresses:
if (param.getResult() != null)
if (isRestricted(param))
param.setResult(new ArrayList<LinkAddress>());
break;

case getStackedLinks:
if (param.getResult() != null)
if (isRestricted(param))
param.setResult(new ArrayList<LinkProperties>());
break;
}
}
}
3 changes: 3 additions & 0 deletions src/biz/bokhorst/xprivacy/XPrivacy.java
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,9 @@ protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
// IP prefix
hookAll(XIpPrefix.getInstances(), null, mSecret);

// Link properties
hookAll(XLinkProperties.getInstances(), null, mSecret);

// Location manager
hookAll(XLocationManager.getInstances(null), null, mSecret);

Expand Down

0 comments on commit 5378bbd

Please sign in to comment.