[parasitic] Also parasitic into default manager (#1154)
This commit is contained in:
parent
fe05768189
commit
9afa34932e
|
|
@ -5,8 +5,6 @@ import org.lsposed.lspd.models.Module;
|
||||||
interface ILSPApplicationService {
|
interface ILSPApplicationService {
|
||||||
IBinder requestModuleBinder(String name);
|
IBinder requestModuleBinder(String name);
|
||||||
|
|
||||||
boolean requestManagerBinder(String packageName, String path, out List<IBinder> binder);
|
|
||||||
|
|
||||||
boolean isResourcesHookEnabled();
|
boolean isResourcesHookEnabled();
|
||||||
|
|
||||||
List<Module> getModulesList(String processName);
|
List<Module> getModulesList(String processName);
|
||||||
|
|
|
||||||
|
|
@ -15,9 +15,6 @@ abstract public class ApplicationServiceClient implements ILSPApplicationService
|
||||||
@Override
|
@Override
|
||||||
abstract public IBinder requestModuleBinder(String name);
|
abstract public IBinder requestModuleBinder(String name);
|
||||||
|
|
||||||
@Override
|
|
||||||
abstract public boolean requestManagerBinder(String packageName, String path, List<IBinder> binder);
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
abstract public boolean isResourcesHookEnabled();
|
abstract public boolean isResourcesHookEnabled();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -69,15 +69,6 @@ public class LSPApplicationServiceClient extends ApplicationServiceClient {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean requestManagerBinder(String packageName, String path, List<IBinder> binder) {
|
|
||||||
try {
|
|
||||||
return service.requestManagerBinder(packageName, path, binder);
|
|
||||||
} catch (RemoteException | NullPointerException ignored) {
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isResourcesHookEnabled() {
|
public boolean isResourcesHookEnabled() {
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
|
|
@ -81,7 +81,8 @@ public class Main {
|
||||||
XposedBridge.initXResources();
|
XposedBridge.initXResources();
|
||||||
XposedInit.startsSystemServer = isSystem;
|
XposedInit.startsSystemServer = isSystem;
|
||||||
PrebuiltMethodsDeopter.deoptBootMethods(); // do it once for secondary zygote
|
PrebuiltMethodsDeopter.deoptBootMethods(); // do it once for secondary zygote
|
||||||
if (niceName.equals(BuildConfig.MANAGER_INJECTED_PKG_NAME) && ParasiticManagerHooker.start()) {
|
if ((niceName.equals(BuildConfig.MANAGER_INJECTED_PKG_NAME) || niceName.equals(BuildConfig.DEFAULT_MANAGER_PACKAGE_NAME))
|
||||||
|
&& ParasiticManagerHooker.start()) {
|
||||||
Utils.logI("Loaded manager, skipping next steps");
|
Utils.logI("Loaded manager, skipping next steps");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -91,24 +91,7 @@ public class LoadedApkGetCLHooker extends XC_MethodHook {
|
||||||
hookNewXSP(lpparam);
|
hookNewXSP(lpparam);
|
||||||
}
|
}
|
||||||
|
|
||||||
var binder = new ArrayList<IBinder>(1);
|
|
||||||
var blocked = false;
|
|
||||||
var info = loadedApk.getApplicationInfo();
|
|
||||||
if (info != null) {
|
|
||||||
var packageName = info.packageName;
|
|
||||||
var path = info.sourceDir;
|
|
||||||
blocked = serviceClient.requestManagerBinder(packageName, path, binder);
|
|
||||||
}
|
|
||||||
if (binder.size() != 0 && binder.get(0) != null) {
|
|
||||||
var ret = InstallerVerifier.sendBinderToManager(lpparam.classLoader, binder.get(0));
|
|
||||||
if (!ret) InstallerVerifier.hookBadManager(classLoader);
|
|
||||||
Utils.logI("manager trusted, ret=" + ret);
|
|
||||||
} else if (blocked) {
|
|
||||||
InstallerVerifier.hookBadManager(classLoader);
|
|
||||||
Utils.logI("manager blocked, packageName=" + packageName);
|
|
||||||
} else {
|
|
||||||
XC_LoadPackage.callAll(lpparam);
|
XC_LoadPackage.callAll(lpparam);
|
||||||
}
|
|
||||||
|
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
Hookers.logE("error when hooking LoadedApk#getClassLoader", t);
|
Hookers.logE("error when hooking LoadedApk#getClassLoader", t);
|
||||||
|
|
|
||||||
|
|
@ -106,29 +106,13 @@ public class LSPApplicationService extends ILSPApplicationService.Stub {
|
||||||
} else return null;
|
} else return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean requestManagerBinder(String packageName, String path, List<IBinder> binder) throws RemoteException {
|
|
||||||
ensureRegistered();
|
|
||||||
var pid = getCallingPid();
|
|
||||||
var uid = getCallingUid();
|
|
||||||
if (ConfigManager.getInstance().isManager(uid) &&
|
|
||||||
ConfigManager.getInstance().isManager(packageName) &&
|
|
||||||
InstallerVerifier.verifyInstallerSignature(path)) {
|
|
||||||
var heartbeat = handles.getOrDefault(pid, null);
|
|
||||||
if (heartbeat != null) {
|
|
||||||
binder.add(ServiceManager.getManagerService().obtainManagerBinder(heartbeat, pid, uid));
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return ConfigManager.getInstance().isManager(packageName);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ParcelFileDescriptor requestInjectedManagerBinder(List<IBinder> binder) throws RemoteException {
|
public ParcelFileDescriptor requestInjectedManagerBinder(List<IBinder> binder) throws RemoteException {
|
||||||
ensureRegistered();
|
ensureRegistered();
|
||||||
var pid = getCallingPid();
|
var pid = getCallingPid();
|
||||||
var uid = getCallingUid();
|
var uid = getCallingUid();
|
||||||
if (ServiceManager.getManagerService().postStartManager(pid, uid)) {
|
if (ServiceManager.getManagerService().postStartManager(pid, uid) ||
|
||||||
|
ConfigManager.getInstance().isManager(uid)) {
|
||||||
var heartbeat = handles.get(pid);
|
var heartbeat = handles.get(pid);
|
||||||
if (heartbeat != null) {
|
if (heartbeat != null) {
|
||||||
binder.add(ServiceManager.getManagerService().obtainManagerBinder(heartbeat, pid, uid));
|
binder.add(ServiceManager.getManagerService().obtainManagerBinder(heartbeat, pid, uid));
|
||||||
|
|
|
||||||
|
|
@ -109,6 +109,8 @@ public class ParasiticManagerHooker {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (Process.myUid() != BuildConfig.MANAGER_INJECTED_UID) return;
|
||||||
|
|
||||||
XposedBridge.hookAllMethods(ActivityThread.class, "handleReceiver", new XC_MethodReplacement() {
|
XposedBridge.hookAllMethods(ActivityThread.class, "handleReceiver", new XC_MethodReplacement() {
|
||||||
@Override
|
@Override
|
||||||
protected Object replaceHookedMethod(MethodHookParam param) {
|
protected Object replaceHookedMethod(MethodHookParam param) {
|
||||||
|
|
@ -194,6 +196,7 @@ public class ParasiticManagerHooker {
|
||||||
|
|
||||||
private static void checkIntent(ILSPManagerService managerService, Intent intent) {
|
private static void checkIntent(ILSPManagerService managerService, Intent intent) {
|
||||||
if (managerService == null) return;
|
if (managerService == null) return;
|
||||||
|
if (Process.myUid() != BuildConfig.MANAGER_INJECTED_UID) return;
|
||||||
if (intent.getCategories() == null || !intent.getCategories().contains("org.lsposed.manager.LAUNCH_MANAGER")) {
|
if (intent.getCategories() == null || !intent.getCategories().contains("org.lsposed.manager.LAUNCH_MANAGER")) {
|
||||||
Hookers.logD("Launching the original app, restarting");
|
Hookers.logD("Launching the original app, restarting");
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue