diff --git a/CHANGELOG.md b/CHANGELOG.md index a6f07ba1f..850c048ef 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 restrictions *IpPrefix.getAddress* and *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..3a57d57b5 100644 --- a/res/values/functions.xml +++ b/res/values/functions.xml @@ -120,6 +120,8 @@ Google documentation]]> Google documentation]]> Google documentation]]> + Google documentation]]> + Google documentation]]> diff --git a/src/biz/bokhorst/xprivacy/Meta.java b/src/biz/bokhorst/xprivacy/Meta.java index 17b2b33b2..304bebee5 100644 --- a/src/biz/bokhorst/xprivacy/Meta.java +++ b/src/biz/bokhorst/xprivacy/Meta.java @@ -180,6 +180,10 @@ public static List 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)); diff --git a/src/biz/bokhorst/xprivacy/XIpPrefix.java b/src/biz/bokhorst/xprivacy/XIpPrefix.java new file mode 100644 index 000000000..e1f0d26ed --- /dev/null +++ b/src/biz/bokhorst/xprivacy/XIpPrefix.java @@ -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 getInstances() { + List listHook = new ArrayList(); + 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; + } + } +} 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);