From 774e88c815b72be86bc3c48c6086cf96ee0af396 Mon Sep 17 00:00:00 2001 From: M66B Date: Sun, 29 Jun 2014 11:52:59 +0200 Subject: [PATCH] Added restriction for LinkAddress (Android "L") Refs #1757 --- CHANGELOG.md | 1 + src/biz/bokhorst/xprivacy/Meta.java | 3 ++ src/biz/bokhorst/xprivacy/XLinkAddress.java | 47 +++++++++++++++++++++ src/biz/bokhorst/xprivacy/XPrivacy.java | 3 ++ 4 files changed, 54 insertions(+) create mode 100644 src/biz/bokhorst/xprivacy/XLinkAddress.java diff --git a/CHANGELOG.md b/CHANGELOG.md index 37997f4f1..746e84b8b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,7 @@ Changelog * Fixed all problems reported through the support info * Thanks for sending all the support info! * Removed restrictions for NEW_PICTURE and ACTION_NEW_VIDEO broadcasts (not needed) +* Added restriction for *LinkAddress.toString* (Android "L") ([issue](/../../issues/1757)) [Open issues](https://github.com/M66B/XPrivacy/issues?state=open) diff --git a/src/biz/bokhorst/xprivacy/Meta.java b/src/biz/bokhorst/xprivacy/Meta.java index deab292f5..2dd55eec4 100644 --- a/src/biz/bokhorst/xprivacy/Meta.java +++ b/src/biz/bokhorst/xprivacy/Meta.java @@ -118,6 +118,7 @@ public static List get() { mListHook.add(new Hook("internet", "inet_bw", "READ_NETWORK_USAGE_HISTORY,MODIFY_NETWORK_ACCOUNTING", 1, "2.1.1", null).dangerous().restart().noUsageData()); mListHook.add(new Hook("internet", "inet_vpn", "NET_TUNNELING", 1, "2.1.1", null).dangerous().restart().noUsageData()); mListHook.add(new Hook("internet", "inet_mesh", "LOOP_RADIO", 1, "2.1.1", null).dangerous().restart().noUsageData()); + mListHook.add(new Hook("internet", "getActiveNetworkInfo", null, 1, null, null).dangerous()); mListHook.add(new Hook("internet", "getAllNetworkInfo", null, 1, null, null)); mListHook.add(new Hook("internet", "getNetworkInfo", null, 1, null, null).dangerous()); @@ -132,6 +133,8 @@ public static List get() { mListHook.add(new Hook("internet", "connect", null, 1, "1.99.45", null).dangerous().whitelist(cTypeIPAddress)); + mListHook.add(new Hook("internet", "LinkAddress.toString", null, 20, "2.1.17", null)); + mListHook.add(new Hook("ipc", "IAccountManager", "", 1, "2.1.7", null).dangerous()); mListHook.add(new Hook("ipc", "IActivityManager", "", 1, "2.1.7", null).dangerous()); mListHook.add(new Hook("ipc", "IClipboard", "", 1, "2.1.7", null).dangerous()); diff --git a/src/biz/bokhorst/xprivacy/XLinkAddress.java b/src/biz/bokhorst/xprivacy/XLinkAddress.java new file mode 100644 index 000000000..86b05ab50 --- /dev/null +++ b/src/biz/bokhorst/xprivacy/XLinkAddress.java @@ -0,0 +1,47 @@ +package biz.bokhorst.xprivacy; + +import java.util.ArrayList; +import java.util.List; + +import android.util.Log; + +public class XLinkAddress extends XHook { + private Methods mMethod; + + private XLinkAddress(Methods method, String restrictionName) { + super(restrictionName, method.name(), "LinkAddress." + method.name()); + mMethod = method; + } + + public String getClassName() { + return "android.net.LinkAddress"; + } + + // public String toString () + // http://developer.android.com/reference/android/net/LinkAddress.html + + private enum Methods { + toString + }; + + public static List getInstances() { + List listHook = new ArrayList(); + listHook.add(new XLinkAddress(Methods.toString, PrivacyManager.cInternet)); + return listHook; + } + + @Override + protected void before(XParam param) throws Throwable { + // Do nothing + } + + @Override + protected void after(XParam param) throws Throwable { + if (mMethod == Methods.toString) { + if (param.getResult() != null && isRestricted(param)) + param.setResult("127.0.1.1/24"); + + } else + Util.log(this, Log.WARN, "Unknown method=" + param.method.getName()); + } +} diff --git a/src/biz/bokhorst/xprivacy/XPrivacy.java b/src/biz/bokhorst/xprivacy/XPrivacy.java index 46fda60ce..ded6833b5 100644 --- a/src/biz/bokhorst/xprivacy/XPrivacy.java +++ b/src/biz/bokhorst/xprivacy/XPrivacy.java @@ -224,6 +224,9 @@ protected void beforeHookedMethod(MethodHookParam param) throws Throwable { // IO bridge hookAll(XIoBridge.getInstances(), null, mSecret); + // Link address + hookAll(XLinkAddress.getInstances(), null, mSecret); + // Location manager hookAll(XLocationManager.getInstances(null), null, mSecret);