残页的小博客

残页的小博客

马上订阅 残页的小博客 RSS 更新: https://blog.canyie.top/atom.xml

检测Magisk与Xposed

2021年5月1日 13:23

不久前,开发者Rikka & vvb2060上架了一款环境检测应用Momo,把大家一直以来信任的各种反检测手段击得粉碎。下面我会通过部分已公开的源码,分析这个可能是史上最强的环境检测应用。

检测 Magisk

这一部分只分析有趣的东西,关于MagiskDetector的其他一些具体实现细节请直接查看 https://github.com/vvb2060/MagiskDetector/blob/master/README_ZH.md

反Magisk Hide

首先分析Magisk Hide的原理:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
static void new_zygote(int pid) {
struct stat st;
if (read_ns(pid, &st))
return;

auto it = zygote_map.find(pid);
if (it != zygote_map.end()) {
// Update namespace info
it->second = st;
return;
}

LOGD("proc_monitor: ptrace zygote PID=[%d]\n", pid);
zygote_map[pid] = st;

xptrace(PTRACE_ATTACH, pid);

waitpid(pid, nullptr, __WALL | __WNOTHREAD);
xptrace(PTRACE_SETOPTIONS, pid, nullptr,
PTRACE_O_TRACEFORK | PTRACE_O_TRACEVFORK | PTRACE_O_TRACEEXIT);
xptrace(PTRACE_CONT, pid);
}

void proc_monitor() {
// 省略...

// First try find existing zygotes
check_zygote();

for (int status;;) {
const int pid = waitpid(-1, &status, __WALL | __WNOTHREAD);
if (pid < 0) {
// 省略...
}

if (!WIFSTOPPED(status) /* Ignore...

剩余内容已隐藏

查看完整文章以阅读更多