Skip to content

Commit

Permalink
loadLibrary for N
Browse files Browse the repository at this point in the history
  • Loading branch information
Unpublished committed Oct 26, 2017
1 parent 6a9ffdd commit f947637
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 14 deletions.
4 changes: 2 additions & 2 deletions app/src/main/java/biz/bokhorst/xprivacy/Meta.java
Original file line number Diff line number Diff line change
Expand Up @@ -441,8 +441,8 @@ public static List<Hook> 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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
24 changes: 15 additions & 9 deletions app/src/main/java/biz/bokhorst/xprivacy/XRuntime.java
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -36,19 +36,23 @@ 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<XHook> getInstances() {
List<XHook> listHook = new ArrayList<>();
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;
}

Expand All @@ -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;
}
Expand Down
6 changes: 4 additions & 2 deletions app/src/main/res/values/functions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -369,8 +369,10 @@
<string name="shell_sh" translatable="false"><![CDATA[Will restrict access to a Linux shell]]></string>
<string name="shell_su" translatable="false"><![CDATA[Will restrict access to a root Linux shell]]></string>
<string name="shell_exec" translatable="false"><![CDATA[<a href="https://developer.android.com/reference/java/lang/Runtime.html#exec(java.lang.String[],%20java.lang.String[])">Google documentation</a>]]></string>
<string name="shell_load" translatable="false"><![CDATA[<a href="https://developer.android.com/reference/java/lang/Runtime.html#load(java.lang.String)">Google documentation</a>]]></string>
<string name="shell_loadLibrary" translatable="false"><![CDATA[<a href="https://developer.android.com/reference/java/lang/Runtime.html#loadLibrary(java.lang.String)">Google documentation</a>]]></string>
<string name="shell_load0"
translatable="false"><![CDATA[<a href="https://developer.android.com/reference/java/lang/Runtime.html#load(java.lang.String)">Google documentation</a>]]></string>
<string name="shell_loadLibrary0"
translatable="false"><![CDATA[<a href="https://developer.android.com/reference/java/lang/Runtime.html#loadLibrary(java.lang.String)">Google documentation</a>]]></string>
<string name="shell_start" translatable="false"><![CDATA[<a href="https://developer.android.com/reference/java/lang/ProcessBuilder.html#start()">Google documentation</a>]]></string>

<!-- storage -->
Expand Down

0 comments on commit f947637

Please sign in to comment.