Skip to content

Repository files navigation

UsbDetectionBypass

简体中文

UsbDetectionBypass is an LSPosed/Xposed module focused only on bypassing USB connection and USB debugging detection inside scoped Android apps. It masks common Java/framework and native signals so the target process sees a disconnected, non-debuggable USB state.

Use it only for authorized testing and research on devices and apps you are allowed to inspect.

Features

  • Masks adb_enabled and development_settings_enabled.
  • Masks android.os.SystemProperties and native __system_property_get.
  • Sanitizes USB_STATE and ACTION_BATTERY_CHANGED broadcasts.
  • Hooks Intent extra reads for USB and battery state.
  • Hooks common UsbManager APIs so scoped apps see no attached USB devices or enabled USB functions.
  • Rewrites selected command checks including getprop, settings, dumpsys usb, dumpsys battery, and common sysfs reads.
  • Hooks native open, openat, and fopen for USB-related sysfs paths such as /sys/class/power_supply/*usb*, /sys/class/android_usb/*, and /config/usb_gadget/*.
  • Logs module loading and hook hits through LSPosed logs, logcat, and a per-app diagnostic file.

Project Layout

  • app/src/main/java/io/github/ryttermohn/usbdetectionbypass/HookEntry.kt
    Main LSPosed Java entry point. Installs Java/framework hooks and diagnostic logging.

  • app/src/main/java/io/github/ryttermohn/usbdetectionbypass/LogUtil.kt
    Bridges native logs into LSPosed and logcat.

  • app/src/main/cpp/usb_detection_bypass.cpp
    LSPosed native entry point. Installs native USB property and file-read hooks.

  • app/src/main/assets/xposed_init
    Xposed module entry declaration.

  • app/src/main/assets/native_init
    LSPosed native module declaration.

Build

Use JDK 17 or newer. Android Studio's bundled JBR also works.

.\gradlew.bat assembleDebug

The debug APK is generated at:

app/build/outputs/apk/debug/app-debug.apk

Usage

  1. Install the APK on a rooted device with LSPosed enabled.
  2. Enable the module in LSPosed.
  3. Select your authorized target app in the module scope.
  4. Reboot the device, or fully stop and restart the target app after changing scope.
  5. Check logs with:
adb logcat -s UsbBypass UsbBypassNative UsbDetectionBypassNative

The module also writes UsbDetectionBypass.log under the target app's external files directory when Application.attach() is reached.

Notes

  • The module package is io.github.ryttermohn.usbdetectionbypass.
  • The default LSPosed scope resource is intentionally empty. Select target apps from LSPosed or add package names to app/src/main/res/values/arrays.xml.
  • If no UsbBypass log appears, the module has not entered the target process. Recheck LSPosed scope, module enablement, package/process name, and whether the target app was restarted after module changes.

About

隐藏 Android 应用内 USB 连接与 USB 调试检测信号的 LSPosed/Xposed 模块。

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages