Skip to content

Conversation

@yujincheng08
Copy link
Contributor

@yujincheng08 yujincheng08 commented Nov 15, 2020

Motivation

Many apps now detect Xposed's classes for security issues. EdXposed now provides an app list function to prevent hooking undesired apps. However, the classloader persists even if the app is blacklisted. The reason is that EdXposed load its java bridge and do some preliminary hooks in the zygote process and all subprocesses inherit them! Since both YAHFA and SandHook do not support unhooking, all the java bridge will be preserved in the process memory even if we remove all global references (SandHook and YAHFA hold some handling global references). Apps, therefore, can detect Xposed by checking the classloaders and the Xposed Bridge. To prevent such detection, one way is to load the Java bridge in the target process instead of the zygote process if the app is whitelisted.

Implementation

To finish this mission, we should do as least things as possible in the zygote process, and do most of the jobs after forking. In the zygote process, we should not load any Java codes and do things purely in c++. Things that must be done in the zygote process are those that require special permission: reading the java bridge from the filesystem and loading configs. I, therefore, initialize the config manager in the zygote function and load dex files into byte arrays (but not loading them in ART).
After forking, if the target process is not blacklisted, load the dex files into ART by using InMemoryDexClassloader and load all the modules from the preloaded list by absolute Apk paths. Otherwise, release all the memories in the c++ part inherit from the zygote process.

Side effect

  • Hooks are loaded later, some modules that require zygote permission will no longer work.
  • InitZygote's are called on every process. This behavior exists in EdXposed but is not desired by the original Xposed.
  • The one plus workaround hook is removed. One Plus devices might not work.
  • Slower launch if the app is hooked.

Testing

Tested YAHFA in Mi10 AndroidQ MIUI and in x86 AndoirdR emulator. Tested and passed Xposed Detector. Some apps detecting Xposed like Deemo, China Mobile, and BOCHK are working.
More tests are requried.

@MlgmXyysd MlgmXyysd requested a review from solohsu November 15, 2020 15:34
@MlgmXyysd MlgmXyysd added the enhancement New feature or request label Nov 15, 2020
@yujincheng08
Copy link
Contributor Author

yujincheng08 commented Nov 17, 2020

CI is not compatible with my PR. So I created my own GitHub action in my fork: https://github.com/yujincheng08/EdXposed/actions. You can try out the artifacts. DO AT YOUR OWN RISK.

Updates:

  • 0.5.0.8: Fix blacklist.
  • 0.5.0.9: Fix build
  • 0.5.1.0: Introduce module scope. (Need manager supports. Or you can manually add scopes.)
  • 0.5.1.1: Catch std::filesystem::filesystem_error
  • 0.5.1.2: Fix empty line and installation from scratch
  • 0.5.1.3: Fix class conflict by R8. QN should work now.
  • 0.5.1.4: Remove some useless hooks, avoid [BUG] 4568 crash webview make miui stuck at bootanimation #643

For module scope, plz use this manger instead (need core patch): https://github.com/NekoInverter/EdXposedManagerR/releases/tag/v4.5.8

@loveedxposed
Copy link

loveedxposed commented Jan 13, 2021

Since edxposed version 0.5, cannot hook isolated processes at initZygote's.Please help me
Version 0.4 working fine.
isolated processes can detect Magisk and Edxposed very simple.

@kotori2
Copy link
Contributor

kotori2 commented Jan 13, 2021

cannot hook isolated processes at initZygote

Intended behavior.

@loveedxposed
Copy link

cannot hook isolated processes at initZygote

Intended behavior.

Yes, intended behavior. But some app can detect edxposed install.
https://darvincitech.wordpress.com/2019/11/04/detecting-magisk-hide/
i tried this project and detect path EdXposed in isolated processes, version 0.4 if "App List Mode" not enable, initZygote can hook isolated processes, but version 0.5 , cannot hook isolated processes ? Can you help me ?

@yujincheng08
Copy link
Contributor Author

@loveedxposed never ever hook isolated process. it will lead to crashing (like chromium)

@loveedxposed
Copy link

@loveedxposed never ever hook isolated process. it will lead to crashing (like chromium)

Yes, i'm know, but version edxposed 0.4 can hook function in isolated process and bypass it.
If app detect edxposed in isolated process, how to bypass in version 0.5 ?
"Xposed Hide" above cannot bypass. Would you like me to send source code detect edxposed in isolated processes ?

@yujincheng08
Copy link
Contributor Author

I think that's because Magisk hide doesn't work on isolated processes and is none of EdXposed's business.

@loveedxposed
Copy link

loveedxposed commented Jan 15, 2021

I think that's because Magisk hide doesn't work on isolated processes and is none of EdXposed's business.

Thanks you, have a nice day

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants