Sndav/xfrm-ESP-LPE

GitHub: Sndav/xfrm-ESP-LPE

利用 Linux 内核 xfrm/ESP 子系统的页缓存写入漏洞,在非特权命名空间中实现本地提权至 root 的单文件 C 语言 PoC。

Stars: 2 | Forks: 0

# DirtyFrag ESP Lite 轻量级 Linux 本地提权工具,利用 xfrm/ESP 子系统的页缓存写入原语清除 `/etc/passwd` 中 root 的密码字段。 **特点:** - **极致轻量** — 单个 C 文件,约 220 行,零外部依赖 - **全架构通用** — 纯系统调用 + netlink,不依赖特定 CPU 架构,x86/ARM/MIPS/RISC-V 等均可运行 - **自包含** — 无需额外库,支持静态编译后直接投递到目标机器 - **非特权触发** — 通过 `CLONE_NEWUSER | CLONE_NEWNET` 在非特权用户命名空间中操作 ## 免责声明 本工具仅供教育和**已授权**的安全研究使用。未经系统所有者明确书面许可,对任何系统使用本工具均属违法行为。作者不对本程序的滥用或造成的任何损害承担责任。 ## 编译 ### 前提条件 - Linux 内核(受影响版本) - GCC 或任何兼容的 C 编译器 - 仅需标准 C 库头文件(glibc / musl 均可) ### 使用 Makefile # 动态链接编译(默认) make # 静态编译(适合跨环境投递) make static # 清理 make clean ### 手动编译 gcc -O2 -Wall -o exp exp_esp_lite.c ### 交叉编译示例 # ARM (aarch64) aarch64-linux-gnu-gcc -O2 -static -o exp exp_esp_lite.c # MIPS (大端) mips-linux-gnu-gcc -O2 -static -o exp exp_esp_lite.c # RISC-V 64 riscv64-linux-gnu-gcc -O2 -static -o exp exp_esp_lite.c ## 用法 ./exp # 自动检测 /etc/passwd 布局并执行 ./exp -v # 详细输出模式 成功后执行 `su root` 即可免密切换到 root。 ## 原理简述 1. 在非特权 user/net namespace 中创建 xfrm SA(ESP + ESN 模式) 2. 利用 `splice()` 将 `/etc/passwd` 的页缓存页拼入 ESP skb frag 3. ESP 认证校验前,内核已将 `seq_hi`(攻击者控制的 4 字节)写入该页缓存页 4. 校验失败、包被丢弃,但页缓存中的修改已持久化 5. 逐 4 字节重复上述过程,将密码字段清空 # DirtyFrag ESP Lite (English) Lightweight, self-contained Linux LPE exploit via the xfrm/ESP page-cache write primitive. Clears the root password field in `/etc/passwd`. **Highlights:** - **Minimal** — single C file, ~220 lines, zero external dependencies - **Cross-architecture** — pure syscalls + netlink; works on x86, ARM, MIPS, RISC-V, etc. - **Self-contained** — supports static linking for easy deployment - **Unprivileged trigger** — operates inside `CLONE_NEWUSER | CLONE_NEWNET` namespaces ## Disclaimer This tool is provided for educational and authorized security research purposes only. Using it against any system without explicit written permission from the owner is illegal. The author assumes no liability for misuse or any resulting damage. ## Build make # dynamic linking (default) make static # static binary for cross-environment deployment Or manually: gcc -O2 -Wall -o exp exp_esp_lite.c ## Usage ./exp # auto-detect /etc/passwd layout ./exp -v # verbose output After success, run `su root` — no password required. ## How It Works 1. Creates an xfrm SA (ESP + ESN) inside an unprivileged user/net namespace 2. Uses `splice()` to place a `/etc/passwd` page-cache page into an ESP skb frag 3. The kernel writes the attacker-controlled `seq_hi` (4 bytes) into the page-cache page **before** ESP authentication 4. Authentication fails and the packet is dropped, but the page-cache modification persists 5. Repeats in 4-byte chunks to clear the password field
标签:0day挖掘, CSV导出, CVE PoC, C 语言提权脚本, DirtyFrag, DirtyPipe 类似漏洞, DNS枚举, DNS 解析, /etc/passwd 提权, Linux 内核安全, Linux 提权 EXP, Linux 提权工具, Linux 本地提权, LPE 漏洞利用, Maven, netlink, splice 系统调用, user namespace, Web报告查看器, x86/ARM/MIPS/RISC-V, xfrm-ESP 漏洞, 内核安全, 内核漏洞利用, 子域名枚举, 安全渗透, 客户端加密, 本地权限提升, 漏洞验证, 系统安全, 网络安全, 网络安全工具, 跨架构漏洞利用, 隐私保护, 零依赖漏洞利用, 非特权提权, 页缓存写入原语, 项目管理