是工具篇ヾ (≧▽≦*) o!!

前不久在逆向某个应用时设备被风控了,为此只能使用改机工具来绕过风控,这次就来分享一下是如何隐藏我的设备环境吧!

首先推荐这个工具,非常方便,一键隐藏~~而且同时也会下载很多之后需要用到的工具,不需要我们自己再下载了。

根据官网的使用教程,运行完脚本并重启设备后,可以发现多了几个应用:

Applist Detector

是用来检测应用列表,检查是否有可疑应用的,至于如何隐藏应用列表,则需要使用下面这个工具

HMA

分为黑白名单模式,具体使用方法可以看模块帮助文档 。默认是黑名单,只需要在应用管理中启用需要隐藏的设备即可。

接下来是两个检测器:

momo

一个基础检测器,可以检测当前手机的风险环境,可以用来自查环境是否隐藏好了。

Hunter

更高级的检测器,检测项目更多更细致。

刚刚 momo 没有发现的问题 hunter 就检测出来了。检测到的是匹配 magisk 的 SELinux 策略。改用 kernelSU 可以解决。

此处已更正,看文章末尾

隐藏好自己的设备环境之后,接下来就是改机工具

device_faker

这里需要适合自己的机型模板,因为我的真机是 Pixel 4,所以使用了下面几个模板。

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
[templates.pixel_7]
manufacturer = "Google"
brand = "google"
model = "GVU6C"
device = "panther"
product = "panther"
name = "panther"
marketname = "Pixel 7"
fingerprint = "google/panther/panther:13/TQ3A.230805.001/10316531:user/release-keys"
build_id = "TQ3A.230805.001"
security_patch = "2023-08-05"
android_version = "13"
sdk_int = 33
author = "you"

[templates.pixel_6a]
manufacturer = "Google"
brand = "google"
model = "GX7AS"
device = "bluejay"
product = "bluejay"
name = "bluejay"
marketname = "Pixel 6a"
fingerprint = "google/bluejay/bluejay:13/TQ3A.230805.001/10316531:user/release-keys"
build_id = "TQ3A.230805.001"
security_patch = "2023-08-05"
android_version = "13"
sdk_int = 33
author = "you"

[templates.pixel_6_pro]
manufacturer = "Google"
brand = "google"
model = "GE2AE"
device = "raven"
product = "raven"
name = "raven"
marketname = "Pixel 6 Pro"
fingerprint = "google/raven/raven:13/TQ3A.230805.001/10316531:user/release-keys"
build_id = "TQ3A.230805.001"
security_patch = "2023-08-05"
android_version = "13"
sdk_int = 33
author = "you"

这里的 fingerprint 可以随机。除此之外,还需要配合另外一个 LSPosed 模块使用。

guise

同样是改机工具,不同的是可以设置选项更加多样,比如 wifi、电量、ssaid 等等

隐藏 wifi mac 地址还是很必要的,这是一个常见的设备指纹标识。

把这些全部配置好,再清除之前的应用缓存,就发现设备已经不再风控啦!

一点碎碎念

略略略水的一篇,想着好久没有发博客了,趁周末写了一下哈哈,毕竟最近在做的事情周期都很长,还没做到可以分享的程度。只能继续加油加油,干巴爹╰(°▽°)╯

更正

此检测方法具体可看 LSPosed/DirtySepolicy。

如果 root 注入方案想让自己的进场跑起来,几乎必然要修改 SELinux 策略。

  • 加域: magisk 、 ksu 、 su 、 adbroot 、 lsposed …
  • 加文件类型: magisk_file 、 ksu_file 、 lsposed_file 、 xposed_file …
  • 加 allow 规则: system_server 的 execmem 、 zygote 读 /data/adb 、 kernel 读 adb_data_file …

这些改动存在于内核,但是普通 app 查不到。DirtySepolicy 找了一个普通 app 能创建但 SELinux 权限足够的进程,让他提 app 去查询内核。

app zygote 是应用专属 zygote,专门为声明了 isolatedProcess 的服务 fork 隔离进程;App 可以在 preload 阶段为自己的隔离服务预加载代码和资源, doPreload 就在这里执行。而它在 fork 隔离进程前,必须自己校验目标 context 合法,必要时计算访问向量,所以它有权限 check_context 和 compute_av

1
2
3
4
5
6
system zygote
└─ fork → app zygote(域 u:r:app_zygote:s0,UID = 应用 UID)
├─ 加载该 App 的 APK(apk_data_file)
├─ 反射实例化 manifest 里 android:zygotePreloadName 指定的类
├─ 调用 ZygotePreload.doPreload(appInfo) ← 只调一次
└─ 之后循环 accept 请求,fork 出 isolated_app 子进程

检测方法就在 ZygotePreload.doPreload(appInfo) 中。 doPreload 在 app zygote 中,所以所以检测代码拥有 check_context / compute_av 权限。

1
2
3
4
5
6
7
# Check validity of SELinux context before use.
selinux_check_context(app_zygote) # → allow app_zygote kernel:security check_context
# Check SELinux permissions.
selinux_check_access(app_zygote) # → allow app_zygote security:security compute_av

allow app_zygote self:process setcurrent;
allow app_zygote isolated_app:process dyntransition;

即查询 SELinux 策略的权限。

selinux_check_access 定义类似如下

1
SELinux.checkSELinuxAccess(source, target, clazz, perm)

四个参数为源上下文 目标上下文 对象类别 权限。

如果出现下面这几条规则,则策略可能被修改。

1
2
3
4
5
6
7
8
9
u:r:system_server:s0 -> u:r:system_server:s0 process execmem
u:r:fsck_untrusted:s0 -> u:r:fsck_untrusted:s0 capability sys_admin
u:r:shell:s0 -> u:r:su:s0 process transition
u:r:adbd:s0 -> u:r:adbroot:s0 binder call
u:r:untrusted_app:s0 -> u:r:magisk:s0 binder call
u:r:untrusted_app:s0 -> u:object_r:ksu_file:s0 file read
u:r:untrusted_app:s0 -> u:object_r:lsposed_file:s0 file read
u:r:untrusted_app:s0 -> u:object_r:xposed_data:s0 file read
u:r:zygote:s0 -> u:object_r:adb_data_file:s0 dir search

Hunter 检测器正是利用了这个原理。

如果想绕过,则需要在内核态 Hook 相应函数。文章提到了一种绕过方法,可以作为参考。