Skip to content
KitploitKITPLOIT
工具博客
提交
工具博客
提交

黑客、渗透测试和网络安全工具,武装您的安全武器库!

Kitploit 是一个黑客、网络安全和渗透测试工具的目录。发现最新的项目更新,查找漏洞、分析系统、自动化测试并加强你的安全。

··订阅源·联系·隐私·© 2026 Kitploit

工具目录

分类

查看所有分类
Loading categories
Copyfail-sh — copyfail (CVE-2026-31431) 的 Bash 实现 | Kitploit
工具/GitHubGitHub/nonameuserosint-hue/copyfail-sh
权限提升漏洞分析漏洞利用Shellcode渗透测试红队二进制利用
GitHubnonameuserosint-hue/copyfail-sh

Copyfail-sh

copyfail (CVE-2026-31431) 的 Bash 实现

查看仓库
33个月前尚未审核

最受欢迎

查看全部 →

发现我们社区最常用的工具。

探索所有工具

浏览我们的工具集合

查看所有工具 →
分享

copyfail-sh

无竞态条件。无偏移量。无需盲目信任的预编译二进制文件。

一个针对 CVE-2026-31431(复制失败漏洞)的 Bash 实现。该脚本在运行时会内联编译一个最小的 C 辅助程序。Bash 层负责架构检测、载荷解压和目标选择;C 层负责实际的与内核的交互(AF_ALG 套接字、splice、sendmsg),这些是 Bash 本身无法触及的。

完整的技术细节请参见 copy.fail。

工作原理(长话短说)

该漏洞位于 algif_aead 中,即内核的 AF_ALG AEAD 套接字接口。2017 年的一项原地优化使得页面缓存页面可能出现在 authencesn 解密操作的可写目标散列表中。通过 splice() 提供正确的输入,你就能获得一个确定性的 4 字节写入,写入到任何可读文件的页面缓存中,包括你不拥有的 setuid 二进制文件。

每次用 shellcode 覆盖 /usr/bin/su 4 个字节,运行它,获得 root shell。无需竞争窗口,无需内核特定符号,无需重试。

使用方法

root@kitploit:~
chmod +x copyfail.sh

# Check if the system is vulnerable before doing anything
./copyfail.sh -c

# Run the exploit (must be non-root)
./copyfail.sh

# Specify a different setuid target
./copyfail.sh -t /usr/bin/passwd

# List all setuid-root candidates on the system
./copyfail.sh -s

获取 shell 后恢复 su

该漏洞仅覆盖内存中的页面缓存,磁盘上的文件不受影响。重启即可恢复一切。如果想立即清理:

root@kitploit:~
# Inside your root shell
/usr/bin/su --version   # still works from disk if page cache is evicted
# Or just reboot

如果你使用 -t 指定了 su 以外的内容,也同样适用。仅影响页面缓存,磁盘是干净的。

要求

  • Linux(内核 4.11 至 7.0,见下文)
  • gcc 用于编译内联 C 辅助程序
  • python3 用于解压 shellcode 载荷(单行命令,无需额外包)
  • 内核模块:algif_aead、authencesn、hmac、cbc

如果算法不可用:

root@kitploit:~
sudo modprobe algif_aead authencesn hmac cbc

某些发行版在 /etc/modprobe.d/ 中放置了一个阻止模块作为临时解决方案。如果存在则删除:

root@kitploit:~
sudo rm /etc/modprobe.d/disable-algif{_,-}aead.conf 2>/dev/null

受影响的内核

root@kitploit:~
floor:    torvalds/linux 72548b093ee3   August 2017, v4.14
                                        (AF_ALG iov_iter rework that introduced
                                         the file-page write primitive via splice
                                         into the AEAD scatterlist)

ceiling:  torvalds/linux a664bf3d603d   April 2026, mainline
                                        (reverts the 2017 in-place optimization;
                                         source and destination scatterlists are
                                         now separate, page-cache pages can no
                                         longer end up as writable crypto output)

在这两个提交之间的版本:所有未向后移植修复的主要发行版。Ubuntu、RHEL、SUSE、Amazon Linux、Debian 在披露时均被确认存在漏洞。发行版的后向移植大约从 2026-04-29 开始。要检查特定内核,请在变更日志中查找 a664bf3d603d(或其发行版后向移植)。

支持的架构

架构状态
x86_64✓
aarch64✓
i386 / i686✓
armv7l✓

缓解措施

永久性: 更新你的内核。

临时解决方案(阻止 AF_ALG 套接字;不影响直接使用内核加密 API 的 IPsec/XFRM):

root@kitploit:~
echo "install algif_aead /bin/false" | sudo tee /etc/modprobe.d/disable-algif-aead.conf
sudo rmmod algif_aead 2>/dev/null

容器: 添加一个 seccomp 配置文件来阻止 AF_ALG 套接字创建,并在你的 Pod 安全上下文中设置 allowPrivilegeEscalation: false。这会启用 no_new_privs,从而阻止内核在 execve() 时遵循 setuid 位。

与其他实现的对比

Bash 版本在依赖方面不占优势,但它是一个单一脚本,你可以在运行前从头到尾阅读。C 辅助程序在运行时从一个 heredoc 生成并编译,没有需要单独审计的二进制 blob。

参考

  • copy.fail - 官方网站及技术文章
  • Xint.io 博客 - 技术深入分析
  • 内核修复 - a664bf3d603d
  • CVE-2026-31431 - NVD
  • oss-security 披露
  • badsectorlabs/copyfail-go - Go 实现(shellcode 载荷来源于此)
  • xeloxa/copyfail-exploit - Python 实现

致谢

  • Taeyang Lee & Theori / Xint Code - 漏洞发现与原始 PoC

免责声明

仅供授权安全测试和研究使用。请勿在没有所有权或明确书面许可的系统上运行。

下载工具
PythonGoBash
依赖python3无(静态二进制)gcc + python3
预编译二进制文件否是否
单文件是否是
编译步骤否否是(内联,自动)