APatch_s_build
رفتن به کانال در Telegram
3 912
مشترکین
اطلاعاتی وجود ندارد24 ساعت
+247 روز
+19030 روز
آرشیو پست ها
3 916
e78e7b3
fix(app): fix package config change crash and harden config handling (#1648)
* fix(app): fix package config change crash and harden config handling
Follow-up fixes for the package config rework in #1592:
- app: open the config lock only after Natives.su(); the lock lives in
root-only /data/adb/ap, so opening it before elevation always failed
with EACCES and crashed changeConfig; degrade to unlocked on failure
- app: abort changeConfig when su fails instead of silently doing nothing
- app: match the CSV header field-by-field; a data row whose package name
is literally "pkg" was swallowed by a startsWith("pkg,") check
- apd: treat 0-byte/blank package_config as a legitimately empty config
(touch-created on install, writers are atomic, kernel reads 0 bytes as
"no entries") instead of a torn read, which stalled every uid event by
5-10s on fresh installs
* fix(apd): harden pack
3 916
d3ea0f7
feat: improve package config handling and resource management (#1592)
* feat: improve package config handling and resource management
- apd/package: header-aware CSV parsing (detect header on raw record,
BOM-safe, headerless-compatible); distinguish valid-empty config
(header-only, user revoked all) from torn reads with fail-open sync
that refuses to persist against empty snapshots.
- apd/supercall: fuse refresh only on torn reads so explicit revoke-all
proceeds; poison-tolerant refresh lock; skip allow-list query when
zero grants; truncate kernel uid buffer to actual count.
- app/PkgConfig: atomic writes via app-specific tmp file (UTF-8 + fsync
+ rename), stale tmp cleanup on failure; quiet header skip and BOM
strip on read.
- app/WebUI: release root shell held by SuFilePathHandler on destroy
(idempotent, thread-safe close); withNewRootShell for WebView exec
paths
3 916
5260036
kp: bump to 0.13.9
Fallback to regular systemcall on unsupported kernels,Shadow Call Stack https://github.com/bmax121/KernelPatch/commit/b51197aaba8f2272dd8a3e30c85698a29aa928c9
3 916
KernelPatch最终的systemcall引用了KernelHook中更底层的hook,直接hook在所有路径都会经过更底层的el0_svc_common,失败则回退。这几乎可以把所有时延检测都降低在无法观测的数值内。这是相较于KernelSu方案提出不同的解法,欢迎讨论pr并完善方案。
3 916
99fbd65
manager: fix empty line dropped after clear command (#1614)
clear emits 1B 5B 48 1B 5B 4A — 6 bytes ending 0x4A, no 0x0A. libsu
reads stdout via readLine(), which consumes the trailing 0x0A, so the
escape arrives merged with the next line: for `echo "1"` the callback is
1B 5B 48 1B 5B 4A 31, i.e. "\u001B[H\u001B[J1", newline-free.
The old branch did `text = it.substring(6)`, keeping only the 31 and
never restoring that newline, so the empty line after `clear` disappears.
The newline was lost since 23e473ad (it substring-ed the raw line, not
`"$it\n"` as KernelSU does), but checked the wrong escape so it never ran;
5add26f8 fixed the escape and re-enabled it, surfacing the bug and
dropping the merged line from the log.
Fold clear into appendLog(): strip the sequence, reset only the displayed
text (a clear erases the viewport, not the scrollback), and pass the
remainder through ap
3 916
最近社区公开了我们两年前的检测,虽然在Apatch next中已经修复,但是官方的kernelpatch没有做出任何动作,因为superkey这个要求众多开发者觉得方便,所以一直没有移除,使用官方仓库不使用密钥其实是没有问题的,两年前的文章大家可以看看。
继我们在 6 月公开了一个针对 APatch 的侧信道攻击方法后,今天再公开一个 page access 检测。
在 Peekaboo 1.5.5 发布后,我们注意到一些用户反馈 DBS Paylah! 银行无法打开。由于 DBS 银行我们在 8 月份就做过对抗,(没想到国内居然也能看到 DBS),对于 zDefend 具有一定的经验,在 c malloc 内存中定位到 internalName,dump 后发现是触发了 kernel_hooking 组中的检测,继续追下去发现这个组包含 apatch_page_access_check 和 apatch_cpu_cycle_check。由于涉及到内存相关,猜测不可能是单纯的读取 self 下的信息,肯定要经过系统调用,于是拿出系统调用 dump 神器 stackplz 开抓。因为银行应用本身就需要加载很多数据到内存中,打开应用的一瞬间日志即可达到 70 MB,经过我们的分析找到了关键的检测线程,在几十万次的侧信道检测后执行了一个奇怪的调用: execveat(dirfd=-100, pathname=0x7a3e778718(/system/bin/truncate), argv=0x7e2b417ff8[], envp=0xffffffffffffffff[], flags=4352)
紧接着就会通过 read 调用读取自身的 smaps。和团队成员交流后,我们一致认为是这个调用出于某种原因导致了安装 KernelPatch 的设备触发了缺页机制,于是开始重新阅读 KernelPatch 的源码,直接定位到 execve 相关的有效 hook,直接定位到 truncate 判断的调用中[1]。二分法测试后得知 handle_supercmd 函数被调用后就会无法进入 DBS。观察上文所述的奇怪的调用中,envp 有符号正好是 -1,但 argv 的地址却不在 data 段中,而是自己 mmap 的一块内存。根据 argv 的地址找到 mmap 的过程:
mmap(addr=0x0, length=12288, prot=0x3(PROT_READ|PROT_WRITE), flags=0x21(MAP_SHARED|MAP_ANONYMOUS), fd=-1, offset=0, ret=0x7e2b417000)
观察这个 mmap,长度是 12288,眼尖的读者可能会一眼认出这是 4096 * 3,由于目前安卓没有强制 16k PageSize,mmap 的长度正好是 3 个页,同时设置为可读写的共享匿名内存。根据常识,当软件试图访问已映射在虚拟地址空间中但并未被加载在物理内存中的一个分页时,会触发缺页异常。而这段内存被 mmap 之后截止到目前为止,并没有人去读写,因此在 smaps 这段内存的 Rss 应该等于 0。回到奇怪的调用,pathname 是 truncate,argv 指向的是这段内存的地址,flags 是 4352 换算为十六进制是 0x1100。查看 execveat 系统调用的代码[2],getname_uflags(filename, flags) 会先被执行,追下去发现 flags 是 AT_EMPTY_PATH + AT_SYMLINK_NOFOLLOW 组合,而这个组合反而会让 LOOKUP_EMPTY 判断成立,使 getname_uflags 返回一个空指针。当空指针作为 struct *filename 被传递下去后,do_execveat_common 会立刻 return 来防止空指针导致设备 panic,这也就是说正常情况下这段代码中的 argv 永远不会被拷贝,不会触发缺页。然而搭载了 KP 的设备执行这段调用后由于不加判断地拷贝 argv,触发了缺页机制,进而导致了 Rss 变化,证明设备包含了 KP。
再次感叹 zDefend 的安全研究人员是真的技术到位和基础知识的牢固,在此给各位读者留下两个思考: 1. KernelSU 同样也有类似的代码,为什么没有触发缺页中断?KP 又该如何修复? 2. mmap 的为什么是三个页大小,而 argv 的地址却是第二个页前后?
[1] https://github.com/bmax121/KernelPatch/blob/dev/kernel/patch/common/sucompat.c#L250 [2] https://elixir.bootlin.com/linux/v5.15.166/source/fs/exec.c#L2108
3 916
警告,Fake Location在程序中隐藏了一个内置可接受的命令执行后门。这作为一个root应用来说显然是不能接受的。请使用这款应用的用户注意安全。超级用户日志在之前我还觉得不是那么重要,现在后门日益增多,越来越觉得这个功能还是比较重要了。后续可能会加入提权了哪些应用以及命令加入环形日志区。
3 916
KernelPatch内部解析器已由kallsyms_lookup_name_by_suffix 实现,越来越多的设备使用LTO优化内核,导致符号要么内联导致hook无效,要么有一些奇怪的后缀,kpm可以直接调用这个方法无需再次实现解析器。原始方法仍然保留为导出函数。
3 916
我看现在好多人说kernelpatch 是用ai写的,其实不完全正确,当你真正用ai的时候会发现,接近用户态的代码会很轻松搞定,但是一旦涉及到寄存器内核态转换,ai 就会完全抓瞎,在已经发布的版本中我已经尽力让ai不要往那个方向尝试,写到最后ai自己偷偷改回来了,给出codex.md是想让更多的人自己来调试自己的内核。这种项目开发维护难免有考虑不周导致设备不开机的情况,遇到这种情况只能麻烦有设备的人进行调试了。目前处于有能力的开发者没时间或者因为无收益而不继续的,维护这种项目希望大家有更多的包容,感谢各位
3 916
5add26f
manager: fix clear command broken by log refactor (#1577)
23e473a broke the clear command: ExecuteAPMAction.kt checked
"\u001B[H\u001B[2J" (7 chars) while apm emits "\u001B[H\u001B[J" (6
chars), and Install.kt checked "[H[J" with the ESC bytes missing —
neither matched, so the escape bytes leaked into the log text.
Restore "\u001B[H\u001B[J" with substring(6) at all three call
sites, written as visible \u001B escapes so diffs cannot corrupt it
again.
3 916
9d0b69e
fix(kpm): keep install and unload state consistent (#1562)
Co-authored-by: matsuzaka-yuki <matsuzaka-yuki@users.noreply.github.com>
3 916
selinux hide将不会再兼容4.19以下内核,因为低于4.19内核没有稳定的符号以及方法,并且伴随大量魔改以及backport,如果你仍然需要,请嵌入kpm进行尝试,作者精力有限,不会再处理4.19以下内核的问题。除非你在以前的某个版本能用,更新到某个版本以后不能用的情况。
3 916
3ebc587
fix: restore boot-completed event and guard package config
fix: preserve headerless package configs
restore boot-completed event and guard package config
