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

Commit

Permalink
Added restriction IpPrefix.getAddress/getRawAddress
Browse files Browse the repository at this point in the history
Refs #1757
  • Loading branch information
M66B committed Dec 15, 2014
1 parent 8757d12 commit 071f482
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Changelog
* Allow white listing / show parameter of *getExternalStorageState* ([issue](/../../issues/1757))
* 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))

[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 @@ -120,6 +120,8 @@
<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_connect" translatable="false"><![CDATA[Will restrict access to the internet]]></string>

<!-- ipc -->
Expand Down
4 changes: 4 additions & 0 deletions src/biz/bokhorst/xprivacy/Meta.java
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,10 @@ public static List<Hook> get() {
mListHook.add(new Hook("internet", "InetAddress.getByAddress", "INTERNET", 1, null, null).unsafe().dangerous().whitelist(cTypeIPAddress));
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", "connect", null, 1, "1.99.45", null).unsafe().dangerous().whitelist(cTypeIPAddress));

mListHook.add(new Hook("ipc", "Binder", "", 1, "2.1.21", null).notAOSP(19).dangerous().whitelist(cTypeTransaction));
Expand Down
57 changes: 57 additions & 0 deletions src/biz/bokhorst/xprivacy/XIpPrefix.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package biz.bokhorst.xprivacy;

import java.util.ArrayList;
import java.util.List;

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

public class XIpPrefix extends XHook {
private Methods mMethod;

private XIpPrefix(Methods method, String restrictionName) {
super(restrictionName, "IpPrefix." + method.name(), null);
mMethod = method;
}

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

// public InetAddress getAddress()
// public byte[] getRawAddress()
// https://developer.android.com/reference/android/net/IpPrefix.html
// http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/5.0.0_r1/android/net/IpPrefix.java

private enum Methods {
getAddress, getRawAddress
};

public static List<XHook> getInstances() {
List<XHook> listHook = new ArrayList<XHook>();
listHook.add(new XIpPrefix(Methods.getAddress, PrivacyManager.cInternet));
listHook.add(new XIpPrefix(Methods.getRawAddress, PrivacyManager.cInternet));
return listHook;
}

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

@Override
protected void after(XParam param) throws Throwable {
switch (mMethod) {
case getAddress:
if (isRestricted(param))
param.setResult(PrivacyManager.getDefacedProp(Binder.getCallingUid(), "InetAddress"));
break;

case getRawAddress:
if (param.getResult() != null)
if (isRestricted(param))
param.setResult(PrivacyManager.getDefacedProp(Binder.getCallingUid(), "IPInt"));
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 @@ -278,6 +278,9 @@ protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
// IO bridge
hookAll(XIoBridge.getInstances(), null, mSecret);

// IP prefix
hookAll(XIpPrefix.getInstances(), null, mSecret);

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

Expand Down

0 comments on commit 071f482

Please sign in to comment.