Files
.pouch/skills/host-sec-check/references/access.md
T
2026-09-04 11:54:07 +08:00

49 lines
1.4 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 取证入口(无 sudo 时)
目标用户常见情况:`sudo` 要密码,但在 `docker` 组。Docker 组等价于 root。
## 读宿主机(绕过 preload)
容器用自己的 libc,**不会**加载宿主机 `/etc/ld.so.preload`。
```bash
docker run --rm -i --privileged --pid=host --net=host -v /:/host alpine:latest \
cat /host/etc/ld.so.preload
hexdump -C /host/etc/ld.so.preload # 在容器内
```
列隐藏进程:
```bash
docker run --rm --privileged --pid=host alpine:latest sh -c \
'for d in /proc/[0-9]*; do
pid=${d#/proc/}
cmd=$(tr "\0" " " < "$d/cmdline" 2>/dev/null) || continue
[ -n "$cmd" ] && echo "$pid $cmd"
done'
```
## 改宿主机(systemctl / chattr)
`chroot /host /usr/bin/chattr` 会加载宿主机 preload,可能 **stat 不到** 被藏文件。
用发行版自带 chattr 操作 `/host/...`:
```bash
docker run --rm -i --privileged --pid=host --net=host -v /:/host ubuntu:latest bash -s <<'SH'
chattr -i /host/etc/ld.so.preload
: > /host/etc/ld.so.preload
chattr +i /host/etc/ld.so.preload
lsattr /host/etc/ld.so.preload
SH
```
systemctl / reboot:
```bash
docker run --rm --privileged --pid=host --net=host alpine:latest \
nsenter -t 1 -m -u -i -n -- systemctl disable --now UNIT
```
不要用业务容器当跳板;用 `alpine`/`ubuntu` 临时 `--rm`。查到一半时 `docker ps` 里出现的随机名容器就是这个跳板。