From bc8498d3b340a74b75388c049c5e0713a2a2fa57 Mon Sep 17 00:00:00 2001 From: M66B Date: Mon, 15 Dec 2014 10:16:25 +0100 Subject: [PATCH] Added restriction IpPrefix.getRawAddress Refs #1757 --- CHANGELOG.md | 1 + res/values/functions.xml | 1 + src/biz/bokhorst/xprivacy/Meta.java | 3 ++ src/biz/bokhorst/xprivacy/XIpPrefix.java | 50 ++++++++++++++++++++++++ src/biz/bokhorst/xprivacy/XPrivacy.java | 3 ++ 5 files changed, 58 insertions(+) create mode 100644 src/biz/bokhorst/xprivacy/XIpPrefix.java diff --git a/CHANGELOG.md b/CHANGELOG.md index a6f07ba1f..a5ab0080f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 restriction *IpPrefix.getRawAddress* ([issue](/../../issues/1757)) [Open issues](https://github.com/M66B/XPrivacy/issues?state=open) diff --git a/res/values/functions.xml b/res/values/functions.xml index 221a71d12..a20e789e3 100644 --- a/res/values/functions.xml +++ b/res/values/functions.xml @@ -234,6 +234,7 @@ Google documentation]]> + Google documentation]]> NfcAdapter]]> diff --git a/src/biz/bokhorst/xprivacy/Meta.java b/src/biz/bokhorst/xprivacy/Meta.java index 17b2b33b2..9ee27e548 100644 --- a/src/biz/bokhorst/xprivacy/Meta.java +++ b/src/biz/bokhorst/xprivacy/Meta.java @@ -310,6 +310,9 @@ public static List get() { // android.net.NetworkInfo mListHook.add(new Hook("network", "NetworkInfo.getExtraInfo", null, 1, "2.2.2", "internet/getExtraInfo").unsafe()); + // android.net.IpPrefix + mListHook.add(new Hook("network", "IpPrefix.getRawAddress", null, 21, "3.5.6", null).unsafe()); + mListHook.add(new Hook("nfc", "getNfcAdapter", "NFC", 14, null, null).unsafe()); mListHook.add(new Hook("nfc", "getDefaultAdapter", "NFC", 10, null, null).unsafe()); diff --git a/src/biz/bokhorst/xprivacy/XIpPrefix.java b/src/biz/bokhorst/xprivacy/XIpPrefix.java new file mode 100644 index 000000000..aee1b3761 --- /dev/null +++ b/src/biz/bokhorst/xprivacy/XIpPrefix.java @@ -0,0 +1,50 @@ +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 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 { + getRawAddress + }; + + public static List getInstances() { + List listHook = new ArrayList(); + listHook.add(new XIpPrefix(Methods.getRawAddress, PrivacyManager.cStorage)); + return listHook; + } + + @Override + protected void before(XParam param) throws Throwable { + // Do nothing + } + + @Override + protected void after(XParam param) throws Throwable { + switch (mMethod) { + case getRawAddress: + if (param.getResult() != null) + if (isRestricted(param)) + param.setResult(PrivacyManager.getDefacedProp(Binder.getCallingUid(), "IPInt")); + break; + } + } +} diff --git a/src/biz/bokhorst/xprivacy/XPrivacy.java b/src/biz/bokhorst/xprivacy/XPrivacy.java index 77426fe51..be29733ab 100644 --- a/src/biz/bokhorst/xprivacy/XPrivacy.java +++ b/src/biz/bokhorst/xprivacy/XPrivacy.java @@ -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);