Commit Graph

128 Commits

Author SHA1 Message Date
topjohnwu
af060b3132 General QoL changes 2019-12-13 00:37:06 -05:00
Alvin Wong
474d65207e Fix MagiskHide unmounting paths under /product
Fixes #2107
2019-12-03 05:42:10 -05:00
topjohnwu
493068c073 Attempt to rescan zygote multiple times
Close #1654
2019-11-01 02:12:28 -04:00
topjohnwu
34c65e13bc Fix strings
Close #2012
2019-10-31 12:39:54 -04:00
topjohnwu
947dae4900 Rename classes and small adjustments 2019-09-25 23:55:39 -04:00
topjohnwu
4cd4bfa1d7 Add ':' to allowed characters for magiskhide process name 2019-09-22 16:17:51 -04:00
topjohnwu
baaaf7d5de Fully match zygote/usap process names 2019-09-17 01:50:45 -04:00
topjohnwu
cfad7dd317 Sanitize magiskhide targets
Fix #1785
2019-09-01 14:16:12 +08:00
topjohnwu
ff3710de66 Minor code changes across all sources 2019-06-30 19:09:31 -07:00
topjohnwu
b0e49a4cc8 Kill blastula pool when magiskhide init 2019-06-27 00:49:27 -07:00
topjohnwu
1e94517a72 MagiskHide is coming back strong 2019-06-27 00:28:34 -07:00
topjohnwu
4cc7aced15 Add new util function 2019-06-23 03:53:41 -07:00
topjohnwu
c1602d2554 Support execute commands in magiskhide env
Credits to #1454
2019-06-04 22:27:19 -07:00
topjohnwu
4fcdcd9a8a Detect UID from data directories 2019-06-03 23:32:49 -07:00
topjohnwu
a3a1aed723 Don't check zygote in busy loop 2019-05-27 16:27:19 -07:00
topjohnwu
6a54672b13 Cleanup unnecessary functions 2019-05-26 03:05:23 -07:00
topjohnwu
3d9a15df44 Remove unnecessary '--' in magiskhide 2019-05-26 02:59:38 -07:00
topjohnwu
449c7fda2f Enable proc_monitor test in debug mode only 2019-05-26 02:53:28 -07:00
topjohnwu
8b7b05da68 Separate hide policies 2019-05-26 02:47:57 -07:00
topjohnwu
92400ebcab Process monitor minor tweaks 2019-05-26 02:35:12 -07:00
topjohnwu
23d3e56967 Add new util function 2019-05-25 21:42:51 -07:00
topjohnwu
6785dc4967 Disable verbose ptrace logging 2019-05-25 21:42:24 -07:00
topjohnwu
dad20f6a2d Update zygote namespace
Close #1492
2019-05-25 18:30:43 -07:00
topjohnwu
bb15671046 Sleep when there is nothing to wait 2019-05-25 18:17:25 -07:00
topjohnwu
21984fac8b Add API for running independent proc_monitor test 2019-05-25 16:08:53 -07:00
topjohnwu
515f346dcc Monitor app_process
Some stupid Samsung ROMs will spawn multiple zygote daemons. Since we
switched to ptrace based process monitoring, we have to know all zygote
processes to trace. This is an attempt to fix this issue.

Close #1272
2019-04-22 16:36:23 -04:00
topjohnwu
4e7dafb0e4 Use bitset instead of vector 2019-04-13 02:43:43 -04:00
topjohnwu
dab32e1599 Use our own device nodes for mirrors 2019-04-08 01:40:04 -04:00
topjohnwu
befe1a83b5 Use real system_root mirror 2019-04-07 14:22:45 -04:00
topjohnwu
df4161ffcc Reboot to recovery when running as recovery 2019-03-30 06:49:29 -04:00
topjohnwu
d08b1a6639 Remove com.google.android.gms from default list
It seems that even adding this to the list doesn't 100% works on all
devices out there, and some even reported crashes on several Google
services. Disable it for now and do further investigations in the future.
2019-03-27 21:33:04 -04:00
topjohnwu
f5f7fd9132 Add com.android.google gms to default hide list
Close #1235
2019-03-23 04:39:34 -04:00
topjohnwu
f0240b1f06 Support Android Q new split sepolicy setup 2019-03-15 06:17:37 -04:00
topjohnwu
f2f4649ab0 Don't crash when encounter unexpected XML input 2019-03-12 17:19:29 -04:00
topjohnwu
dce0b6c05a Always detach all child threads before leaving 2019-03-12 16:48:01 -04:00
topjohnwu
a4a661bf34 Small code restructuring 2019-03-11 12:44:50 -04:00
topjohnwu
5111086637 Don't care if child threads were unknown 2019-03-10 01:46:32 -05:00
topjohnwu
20f204810e Use RAII to detach PIDs 2019-03-10 01:14:41 -05:00
topjohnwu
4581354e7a Allow zygote to execve
Allow zygote to execute other programs (such as dex2oat).
This fixes the bug that cause ART framework boot images failed to load
and result to extremely serious performance degradation.

Fix #1195
2019-03-09 22:58:05 -05:00
topjohnwu
faf4d76388 Use large vector<bool> instead of set<pid>
vector<bool> uses bitsets, so we actually only use 12k memory to
store all 3 possible PID info tables. PID checkup will be now become
O(1) instead of O(logn).

P.S. The reason why we don't use unordered_map is because including it
will result in significant binary size increase (might be due to the
complex hash table STL implementation? I really don't know).
2019-03-09 22:28:43 -05:00
topjohnwu
f24a5dfd45 More efficient xml parsing 2019-03-09 04:27:04 -05:00
topjohnwu
081074ad9d Better zygote process detection 2019-03-08 23:53:53 -05:00
topjohnwu
0204d05316 Remove Zygote notifier
Temporary trigger process scan on packages.xml updates, will find better methods
2019-03-08 03:35:17 -05:00
topjohnwu
d2cb638fcd Use our own function to parse int 2019-03-07 20:31:35 -05:00
topjohnwu
82c864d57e Make zygote notifier more reliable 2019-03-06 18:22:04 -05:00
topjohnwu
370015a853 Modernize database code (again) 2019-03-06 08:16:12 -05:00
topjohnwu
6597b7adc0 Add MicroG DroidGuardHelper as target
MicroG uses a different package to handle DroidGuard service (SafetyNet),
but still uses the same com.google.android.gms.unstable process name.
Thanks to the changes in 4e53ebfe, we can target both official GMS
and MicroG SafetyNet services at the same time.
2019-03-06 05:43:52 -05:00
topjohnwu
4e53ebfe44 Use both package name and process name as key
Different packages could potentially use the same process name,
and they shouldn't conflict with each other.
2019-03-06 05:40:52 -05:00
topjohnwu
04ef1e6405 Make parse prop file a util function 2019-03-05 20:27:09 -05:00
topjohnwu
b278d07b05 Switch to Zygote ptrace-ing
No matter if we use the old, buggy, error prone am_proc_start monitoring,
or the new APK inotify method, both methods rely on MagiskHide 'reacting'
fast enough to hijack the process before any detection has been done.

However, this is not reliable and practical. There are apps that utilize
native libraries to start detects and register SIGCONT signal handlers
to mitigate all existing MagiskHide process monitoring mechanism. So
our only solution is to hijack an app BEFORE it is started.

All Android apps' process is forked from zygote, so it is easily the
target to be monitored. All forks will be notified, and subsequent
thread spawning (Android apps are heaviliy multithreaded) from children
are also closely monitored to find the earliest possible point to
identify what the process will eventually be (before am_proc_bound).

ptrace is extremely complicated and very difficult to get right. The
current code is heaviliy tested on a stock Android 9.0 Pixel system,
so in theory it should work fine on most devices, but more tests and
potentially fixes are expected to follow this commit.
2019-03-05 20:23:27 -05:00