Strip logs if verbose log is disabled (#101)

When the `Disable verbose log` option is toggled, more logs are stripped to avoid detections based on log entries.
This commit is contained in:
JingMatrix 2024-11-25 22:28:34 +01:00 committed by GitHub
parent 85b8fa17fb
commit 466b3a4aee
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
14 changed files with 95 additions and 14 deletions

View File

@ -27,12 +27,12 @@ import android.content.Context;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.os.Environment; import android.os.Environment;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.util.Log;
import com.android.internal.util.XmlUtils; import com.android.internal.util.XmlUtils;
import org.lsposed.lspd.core.BuildConfig; import org.lsposed.lspd.core.BuildConfig;
import org.lsposed.lspd.util.MetaDataReader; import org.lsposed.lspd.util.MetaDataReader;
import org.lsposed.lspd.util.Utils.Log;
import org.xmlpull.v1.XmlPullParserException; import org.xmlpull.v1.XmlPullParserException;
import java.io.File; import java.io.File;

View File

@ -39,13 +39,13 @@ import android.os.Build;
import android.os.IBinder; import android.os.IBinder;
import android.os.Process; import android.os.Process;
import android.util.ArrayMap; import android.util.ArrayMap;
import android.util.Log;
import org.lsposed.lspd.impl.LSPosedContext; import org.lsposed.lspd.impl.LSPosedContext;
import org.lsposed.lspd.models.PreLoadedApk; import org.lsposed.lspd.models.PreLoadedApk;
import org.lsposed.lspd.nativebridge.NativeAPI; import org.lsposed.lspd.nativebridge.NativeAPI;
import org.lsposed.lspd.nativebridge.ResourcesHook; import org.lsposed.lspd.nativebridge.ResourcesHook;
import org.lsposed.lspd.util.LspModuleClassLoader; import org.lsposed.lspd.util.LspModuleClassLoader;
import org.lsposed.lspd.util.Utils.Log;
import java.io.File; import java.io.File;
import java.lang.ref.WeakReference; import java.lang.ref.WeakReference;

View File

@ -57,6 +57,15 @@ public class ApplicationServiceClient implements ILSPApplicationService, IBinder
} }
} }
@Override
public boolean isLogMuted() {
try {
return service.isLogMuted();
} catch (RemoteException | NullPointerException ignored) {
}
return false;
}
@Override @Override
public List<Module> getLegacyModulesList() { public List<Module> getLegacyModulesList() {
try { try {

View File

@ -1,8 +1,7 @@
package org.lsposed.lspd.hooker; package org.lsposed.lspd.hooker;
import android.util.Log;
import org.lsposed.lspd.impl.LSPosedBridge; import org.lsposed.lspd.impl.LSPosedBridge;
import org.lsposed.lspd.util.Utils.Log;
import io.github.libxposed.api.XposedInterface; import io.github.libxposed.api.XposedInterface;
import io.github.libxposed.api.annotations.BeforeInvocation; import io.github.libxposed.api.annotations.BeforeInvocation;

View File

@ -22,9 +22,9 @@ package org.lsposed.lspd.hooker;
import android.app.LoadedApk; import android.app.LoadedApk;
import android.content.res.XResources; import android.content.res.XResources;
import android.util.Log;
import org.lsposed.lspd.util.Hookers; import org.lsposed.lspd.util.Hookers;
import org.lsposed.lspd.util.Utils.Log;
import de.robv.android.xposed.XposedHelpers; import de.robv.android.xposed.XposedHelpers;
import de.robv.android.xposed.XposedInit; import de.robv.android.xposed.XposedInit;

View File

@ -1,10 +1,9 @@
package org.lsposed.lspd.impl; package org.lsposed.lspd.impl;
import android.util.Log;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import org.lsposed.lspd.nativebridge.HookBridge; import org.lsposed.lspd.nativebridge.HookBridge;
import org.lsposed.lspd.util.Utils.Log;
import java.lang.reflect.Executable; import java.lang.reflect.Executable;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;

View File

@ -8,7 +8,6 @@ import android.os.Build;
import android.os.ParcelFileDescriptor; import android.os.ParcelFileDescriptor;
import android.os.Process; import android.os.Process;
import android.os.RemoteException; import android.os.RemoteException;
import android.util.Log;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
@ -20,6 +19,7 @@ import org.lsposed.lspd.nativebridge.HookBridge;
import org.lsposed.lspd.nativebridge.NativeAPI; import org.lsposed.lspd.nativebridge.NativeAPI;
import org.lsposed.lspd.service.ILSPInjectedModuleService; import org.lsposed.lspd.service.ILSPInjectedModuleService;
import org.lsposed.lspd.util.LspModuleClassLoader; import org.lsposed.lspd.util.LspModuleClassLoader;
import org.lsposed.lspd.util.Utils.Log;
import java.io.File; import java.io.File;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;

View File

@ -7,7 +7,6 @@ import android.os.SharedMemory;
import android.system.ErrnoException; import android.system.ErrnoException;
import android.system.Os; import android.system.Os;
import android.system.OsConstants; import android.system.OsConstants;
import android.util.Log;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi; import androidx.annotation.RequiresApi;
@ -25,6 +24,8 @@ import java.util.Objects;
import java.util.jar.JarFile; import java.util.jar.JarFile;
import java.util.zip.ZipEntry; import java.util.zip.ZipEntry;
import org.lsposed.lspd.util.Utils.Log;
import hidden.ByteBufferDexClassLoader; import hidden.ByteBufferDexClassLoader;
import sun.misc.CompoundEnumeration; import sun.misc.CompoundEnumeration;

View File

@ -126,6 +126,11 @@ public class LSPApplicationService extends ILSPApplicationService.Stub {
return ConfigManager.getInstance().getModulesForProcess(processInfo.processName, processInfo.uid); return ConfigManager.getInstance().getModulesForProcess(processInfo.processName, processInfo.uid);
} }
@Override
public boolean isLogMuted() throws RemoteException {
return !ServiceManager.getManagerService().isVerboseLog();
}
@Override @Override
public List<Module> getLegacyModulesList() throws RemoteException { public List<Module> getLegacyModulesList() throws RemoteException {
return getAllModulesList().stream().filter(m -> m.file.legacy).collect(Collectors.toList()); return getAllModulesList().stream().filter(m -> m.file.legacy).collect(Collectors.toList());

View File

@ -19,6 +19,8 @@
package org.lsposed.lspd.core; package org.lsposed.lspd.core;
import static org.lsposed.lspd.core.ApplicationServiceClient.serviceClient;
import android.os.IBinder; import android.os.IBinder;
import android.os.Process; import android.os.Process;
@ -34,11 +36,20 @@ public class Main {
if (isSystem) { if (isSystem) {
ParasiticManagerSystemHooker.start(); ParasiticManagerSystemHooker.start();
} }
Startup.initXposed(isSystem, niceName, appDir, ILSPApplicationService.Stub.asInterface(binder)); Startup.initXposed(isSystem, niceName, appDir, ILSPApplicationService.Stub.asInterface(binder));
try {
Utils.Log.muted = serviceClient.isLogMuted();
} catch (Throwable t) {
Utils.logE("failed to configure logs", t);
}
if (niceName.equals(BuildConfig.DEFAULT_MANAGER_PACKAGE_NAME) && ParasiticManagerHooker.start()) { if (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;
} }
Utils.logI("Loading xposed for " + niceName + "/" + Process.myUid()); Utils.logI("Loading xposed for " + niceName + "/" + Process.myUid());
Startup.bootstrapXposed(); Startup.bootstrapXposed();
} }

View File

@ -29,12 +29,12 @@ import android.os.Binder;
import android.os.IBinder; import android.os.IBinder;
import android.os.Parcel; import android.os.Parcel;
import android.os.RemoteException; import android.os.RemoteException;
import android.util.Log;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import org.lsposed.lspd.BuildConfig; import org.lsposed.lspd.BuildConfig;
import org.lsposed.lspd.util.Utils.Log;
public class BridgeService { public class BridgeService {
private static final int TRANSACTION_CODE = ('_' << 24) | ('L' << 16) | ('S' << 8) | 'P'; private static final int TRANSACTION_CODE = ('_' << 24) | ('L' << 16) | ('S' << 8) | 'P';

View File

@ -5,16 +5,17 @@ import android.app.ProfilerInfo;
import android.content.Intent; import android.content.Intent;
import android.content.pm.ActivityInfo; import android.content.pm.ActivityInfo;
import android.content.pm.ResolveInfo; import android.content.pm.ResolveInfo;
import android.util.Log;
import org.lsposed.lspd.hooker.HandleSystemServerProcessHooker; import org.lsposed.lspd.hooker.HandleSystemServerProcessHooker;
import org.lsposed.lspd.impl.LSPosedHelper; import org.lsposed.lspd.impl.LSPosedHelper;
import org.lsposed.lspd.service.BridgeService; import org.lsposed.lspd.service.BridgeService;
import org.lsposed.lspd.util.Utils;
import io.github.libxposed.api.XposedInterface; import io.github.libxposed.api.XposedInterface;
import io.github.libxposed.api.annotations.AfterInvocation; import io.github.libxposed.api.annotations.AfterInvocation;
import io.github.libxposed.api.annotations.XposedHooker; import io.github.libxposed.api.annotations.XposedHooker;
public class ParasiticManagerSystemHooker implements HandleSystemServerProcessHooker.Callback { public class ParasiticManagerSystemHooker implements HandleSystemServerProcessHooker.Callback {
public static void start() { public static void start() {
HandleSystemServerProcessHooker.callback = new ParasiticManagerSystemHooker(); HandleSystemServerProcessHooker.callback = new ParasiticManagerSystemHooker();
@ -78,9 +79,9 @@ public class ParasiticManagerSystemHooker implements HandleSystemServerProcessHo
HookBridge.deoptimizeMethod(method); HookBridge.deoptimizeMethod(method);
} }
LSPosedHelper.hookAllMethods(Hooker2.class, Class.forName("com.android.server.wm.ActivityStarter", false, classLoader), "execute");*/ LSPosedHelper.hookAllMethods(Hooker2.class, Class.forName("com.android.server.wm.ActivityStarter", false, classLoader), "execute");*/
Log.d("LSPosed", "hooked activity starter"); Utils.logD("hooked activity starter");
} catch (Throwable e) { } catch (Throwable e) {
Log.e("LSPosed", "onSystemServerLoaded: ", e); Utils.logE("onSystemServerLoaded: ", e);
} }
} }
} }

View File

@ -3,6 +3,8 @@ package org.lsposed.lspd.service;
import org.lsposed.lspd.models.Module; import org.lsposed.lspd.models.Module;
interface ILSPApplicationService { interface ILSPApplicationService {
boolean isLogMuted();
List<Module> getLegacyModulesList(); List<Module> getLegacyModulesList();
List<Module> getModulesList(); List<Module> getModulesList();

View File

@ -22,7 +22,6 @@ package org.lsposed.lspd.util;
import android.os.SystemProperties; import android.os.SystemProperties;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log;
import java.time.ZoneId; import java.time.ZoneId;
import java.time.ZoneOffset; import java.time.ZoneOffset;
@ -34,6 +33,61 @@ public class Utils {
public static final boolean isMIUI = !TextUtils.isEmpty(SystemProperties.get("ro.miui.ui.version.name")); public static final boolean isMIUI = !TextUtils.isEmpty(SystemProperties.get("ro.miui.ui.version.name"));
public static final boolean isLENOVO = !TextUtils.isEmpty(SystemProperties.get("ro.lenovo.region")); public static final boolean isLENOVO = !TextUtils.isEmpty(SystemProperties.get("ro.lenovo.region"));
public class Log {
public static boolean muted = false;
public static String getStackTraceString(Throwable tr) {
return android.util.Log.getStackTraceString(tr);
}
public static void d(String tag, String msg) {
if (muted) return;
android.util.Log.d(tag, msg);
}
public static void d(String tag, String msg, Throwable tr) {
android.util.Log.d(tag, msg, tr);
}
public static void v(String tag, String msg) {
if (muted) return;
android.util.Log.v(tag, msg);
}
public static void v(String tag, String msg, Throwable tr) {
android.util.Log.v(tag, msg, tr);
}
public static void i(String tag, String msg) {
if (muted) return;
android.util.Log.i(tag, msg);
}
public static void i(String tag, String msg, Throwable tr) {
android.util.Log.i(tag, msg, tr);
}
public static void w(String tag, String msg) {
if (muted) return;
android.util.Log.w(tag, msg);
}
public static void w(String tag, String msg, Throwable tr) {
if (muted) return;
android.util.Log.w(tag, msg, tr);
}
public static void e(String tag, String msg) {
android.util.Log.e(tag, msg);
}
public static void e(String tag, String msg, Throwable tr) {
android.util.Log.e(tag, msg, tr);
}
}
public static void logD(Object msg) { public static void logD(Object msg) {
Log.d(LOG_TAG, msg.toString()); Log.d(LOG_TAG, msg.toString());
} }