From f947637d6ea6ca974371e6b953914070208e4174 Mon Sep 17 00:00:00 2001 From: Unpublished Date: Thu, 26 Oct 2017 22:43:32 +0200 Subject: [PATCH] loadLibrary for N --- .../main/java/biz/bokhorst/xprivacy/Meta.java | 4 ++-- .../biz/bokhorst/xprivacy/PrivacyManager.java | 2 +- .../java/biz/bokhorst/xprivacy/XRuntime.java | 24 ++++++++++++------- app/src/main/res/values/functions.xml | 6 +++-- 4 files changed, 22 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/biz/bokhorst/xprivacy/Meta.java b/app/src/main/java/biz/bokhorst/xprivacy/Meta.java index 8d6d6d69d..3b2c971de 100644 --- a/app/src/main/java/biz/bokhorst/xprivacy/Meta.java +++ b/app/src/main/java/biz/bokhorst/xprivacy/Meta.java @@ -441,8 +441,8 @@ public static List get() { mListHook.add(new Hook("shell", "sh", "", 10, null, null).unsafe().dangerous().whitelist(cTypeCommand)); mListHook.add(new Hook("shell", "su", "", 10, null, null).unsafe().dangerous().whitelist(cTypeCommand)); mListHook.add(new Hook("shell", "exec", "", 10, null, null).unsafe().dangerous().whitelist(cTypeCommand)); - mListHook.add(new Hook("shell", "load", "", 10, null, null).unsafe().dangerous().restart().whitelist(cTypeLibrary)); - mListHook.add(new Hook("shell", "loadLibrary", "", 10, null, null).unsafe().dangerous().restart().whitelist(cTypeLibrary)); + mListHook.add(new Hook("shell", "load0", "", 10, null, null).unsafe().dangerous().restart().whitelist(cTypeLibrary)); + mListHook.add(new Hook("shell", "loadLibrary0", "", 10, null, null).unsafe().dangerous().restart().whitelist(cTypeLibrary)); mListHook.add(new Hook("shell", "start", "", 10, null, null).unsafe().dangerous().whitelist(cTypeCommand)); mListHook.add(new Hook("storage", "media", "WRITE_MEDIA_STORAGE", 10, null, null).dangerous().restart().noUsageData()); diff --git a/app/src/main/java/biz/bokhorst/xprivacy/PrivacyManager.java b/app/src/main/java/biz/bokhorst/xprivacy/PrivacyManager.java index 31d0fa49a..4fca33bba 100644 --- a/app/src/main/java/biz/bokhorst/xprivacy/PrivacyManager.java +++ b/app/src/main/java/biz/bokhorst/xprivacy/PrivacyManager.java @@ -465,7 +465,7 @@ public static boolean canRestrict(int uid, int xuid, String restrictionName, Str if (_uid == Process.SYSTEM_UID) { if (PrivacyManager.cIdentification.equals(restrictionName)) return false; - if (PrivacyManager.cShell.equals(restrictionName) && "loadLibrary".equals(methodName)) + if (PrivacyManager.cShell.equals(restrictionName) && "loadLibrary0".equals(methodName)) return false; } diff --git a/app/src/main/java/biz/bokhorst/xprivacy/XRuntime.java b/app/src/main/java/biz/bokhorst/xprivacy/XRuntime.java index 460aa0ced..12984a17c 100644 --- a/app/src/main/java/biz/bokhorst/xprivacy/XRuntime.java +++ b/app/src/main/java/biz/bokhorst/xprivacy/XRuntime.java @@ -24,7 +24,7 @@ public String getClassName() { @Override public boolean isVisible() { - return !(mMethod == Methods.load || mMethod == Methods.loadLibrary); + return !(mMethod == Methods.load0 || mMethod == Methods.loadLibrary0); } // public Process exec(String[] progArray) @@ -36,10 +36,14 @@ public boolean isVisible() { // public void load(String pathName) // public void loadLibrary(String libName) // libcore/luni/src/main/java/java/lang/Runtime.java + // N+ + // void load0(Class fromClass, String filename) + // void loadLibrary0(ClassLoader loader, String libname) + // libcore/ojluni/src/main/java/java/lang/Runtime.java // http://developer.android.com/reference/java/lang/Runtime.html private enum Methods { - exec, load, loadLibrary + exec, load0, loadLibrary0 } public static List getInstances() { @@ -47,8 +51,8 @@ public static List getInstances() { listHook.add(new XRuntime(Methods.exec, PrivacyManager.cShell, "sh")); listHook.add(new XRuntime(Methods.exec, PrivacyManager.cShell, "su")); listHook.add(new XRuntime(Methods.exec, PrivacyManager.cShell, null)); - listHook.add(new XRuntime(Methods.load, PrivacyManager.cShell, null)); - listHook.add(new XRuntime(Methods.loadLibrary, PrivacyManager.cShell, null)); + listHook.add(new XRuntime(Methods.load0, PrivacyManager.cShell, null)); + listHook.add(new XRuntime(Methods.loadLibrary0, PrivacyManager.cShell, null)); return listHook; } @@ -72,14 +76,16 @@ protected void before(XParam param) throws Throwable { } break; - case load: - case loadLibrary: - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP || Process.myUid() != Process.SYSTEM_UID) - if (param.args.length > 0) { - String libName = (String) param.args[0]; + case load0: + case loadLibrary0: + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP || Process.myUid() != + Process.SYSTEM_UID) { + if (param.args.length > 1) { + String libName = (String) param.args[1]; if (isRestrictedExtra(param, libName)) param.setThrowable(new UnsatisfiedLinkError("XPrivacy")); } + } break; } diff --git a/app/src/main/res/values/functions.xml b/app/src/main/res/values/functions.xml index c06401fea..902c865f3 100644 --- a/app/src/main/res/values/functions.xml +++ b/app/src/main/res/values/functions.xml @@ -369,8 +369,10 @@ Google documentation]]> - Google documentation]]> - Google documentation]]> + Google documentation]]> + Google documentation]]> Google documentation]]>