Win Server 的 Firewall 运行方式让我很困惑。

220 天前
 MrLonely
最近买了个 Dedicated Server , 装了 Windows Server 2022.

设置了强密码,但是出于其他限制因素,并不能改端口或者改掉 Administrator 用户名。

所以在 Win Server 自带的 Firewall 里找到 RDP 相关的两个 inbound rule ,都加了 IP 白名单。但让我困惑的是,设置好了以后过一段时间就会发现 log 里有 ID 为 4625 的记录。 这些都是别人试图爆破的记录。

可是他们的来源 IP 明明没有在我的白名单里呀。为什么还会被记录下来呢?不是应该要在防火墙阶段直接被阻断吗?

Failure Reason: Unknown user name or bad password.

这个 Failure Reason 表明我的 Win Server 还认真匹配了一下用户名和密码。匹配不上才拒绝。但是从 RDP 登录请求发出的 IP 来算,对方和 3389 端口不应该有任何 TCP 或者 UDP 的连接。
2579 次点击
所在节点    Windows
15 条回复
Int100
220 天前
建议全阻断,用 vpn 连进去.
wtks1
220 天前
用 IP 安全策略试试
geelaw
220 天前
第一个思路是确认你看到的确实是 RDP 登录尝试。Logon Type 是 10 (RemoteInteractive) 吗? Source Port 是 3389 吗?
MrLonely
220 天前
@geelaw

好像并不是,Logon Type 是 3 。Source Port 也不是 3389. 但是这里的 Source Port 难道不是对方发起连接的 Port 吗?如何查看这个 event 本身发生的 port 呢?

Log Name: Security
Source: Microsoft-Windows-Security-Auditing
Date: 2/3/2025 5:15:20 AM
Event ID: 4625
Task Category: Logon
Level: Information
Keywords: Audit Failure
User: N/A
Computer: WIN-PJLJ74N60AR
Description:
An account failed to log on.

Subject:
Security ID: NULL SID
Account Name: -
Account Domain: -
Logon ID: 0x0

Logon Type: 3

Account For Which Logon Failed:
Security ID: NULL SID
Account Name: Administrator
Account Domain: WORKGROUP

Failure Information:
Failure Reason: Unknown user name or bad password.
Status: 0xC000006D
Sub Status: 0xC000006A

Process Information:
Caller Process ID: 0x0
Caller Process Name: -

Network Information:
Workstation Name: WIN-OOJO0024I1F
Source Network Address: 178.18.206.234
Source Port: 60831

Detailed Authentication Information:
Logon Process: NtLmSsp
Authentication Package: NTLM
Transited Services: -
Package Name (NTLM only): -
Key Length: 0

This event is generated when a logon request fails. It is generated on the computer where access was attempted.

The Subject fields indicate the account on the local system which requested the logon. This is most commonly a service such as the Server service, or a local process such as Winlogon.exe or Services.exe.

The Logon Type field indicates the kind of logon that was requested. The most common types are 2 (interactive) and 3 (network).

The Process Information fields indicate which account and process on the system requested the logon.

The Network Information fields indicate where a remote logon request originated. Workstation name is not always available and may be left blank in some cases.

The authentication information fields provide detailed information about this specific logon request.
- Transited services indicate which intermediate services have participated in this logon request.
- Package name indicates which sub-protocol was used among the NTLM protocols.
- Key length indicates the length of the generated session key. This will be 0 if no session key was requested.
Event Xml:
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
<System>
<Provider Name="Microsoft-Windows-Security-Auditing" Guid="{54849625-5478-4994-a5ba-3e3b0328c30d}" />
<EventID>4625</EventID>
<Version>0</Version>
<Level>0</Level>
<Task>12544</Task>
<Opcode>0</Opcode>
<Keywords>0x8010000000000000</Keywords>
<TimeCreated SystemTime="2025-02-03T10:15:20.1270526Z" />
<EventRecordID>134689</EventRecordID>
<Correlation ActivityID="{01d33ee7-74ab-0006-fc3e-d301ab74db01}" />
<Execution ProcessID="768" ThreadID="6240" />
<Channel>Security</Channel>
<Computer>WIN-PJLJ74N60AR</Computer>
<Security />
</System>
<EventData>
<Data Name="SubjectUserSid">S-1-0-0</Data>
<Data Name="SubjectUserName">-</Data>
<Data Name="SubjectDomainName">-</Data>
<Data Name="SubjectLogonId">0x0</Data>
<Data Name="TargetUserSid">S-1-0-0</Data>
<Data Name="TargetUserName">Administrator</Data>
<Data Name="TargetDomainName">WORKGROUP</Data>
<Data Name="Status">0xc000006d</Data>
<Data Name="FailureReason">%%2313</Data>
<Data Name="SubStatus">0xc000006a</Data>
<Data Name="LogonType">3</Data>
<Data Name="LogonProcessName">NtLmSsp </Data>
<Data Name="AuthenticationPackageName">NTLM</Data>
<Data Name="WorkstationName">WIN-OOJO0024I1F</Data>
<Data Name="TransmittedServices">-</Data>
<Data Name="LmPackageName">-</Data>
<Data Name="KeyLength">0</Data>
<Data Name="ProcessId">0x0</Data>
<Data Name="ProcessName">-</Data>
<Data Name="IpAddress">178.18.206.234</Data>
<Data Name="IpPort">60831</Data>
</EventData>
</Event>
geelaw
220 天前
@MrLonely #4 有没有一种非常简单的可能,就是这件事情和 RD 没有任何关系,并且你看到的 60831 端口就是尝试登录的端口,呢?

参考 https://learn.microsoft.com/en-us/windows-server/identity/securing-privileged-access/reference-tools-logon-types 发生 Logon Type = 3 (Network) 的情况很多
fuzzsh
220 天前
看下网卡是什么类型的网络,新建端口 3389 的策略勾上对应网络,缺省带来的貌似是分几个程序,不是端口
yinmin
220 天前
是 vps 吧? 你在云服务商的网站上看看有没有网络防火墙,用云服务商的防火墙做限制。windows 内置防火墙很容易出幺蛾子。实在要用 windows 内置防火墙,自己创建新的入站规则(例如:80 、443 、3389 等),然后把所有内置入站允许的规则都限制为“本地子网”(规则属性-作用域-远程 ip 地址-添加-预定义计算机集:本地子网)
realpg
220 天前
@MrLonely #4
都写的多明白了 NTLM 认证

跟 RDP 没有一分钱关系
你这是境外的 vps 吗?

国内的一级 ISP 保护的太好了,几乎丢掉了广域网下跨 BRAS 的全部常规使用 NTLM 验证的协议 所以很少人知道这些东西了
除非是 2004 年以前就在玩 hacker 技术的才熟悉这些
kk2syc
220 天前
看这张图你就明白了
MrLonely
220 天前
@geelaw 确实有这种可能。我一开始忽略了 Windows 还有其他的登录方式。我只考虑到了 Console ,SSH ,RDP 这些常见的方法。

@fuzzsh 缺省确实是要 3389 端口以及应用程序也对上了才会触发。不过目前来看,问题似乎不出在这里。之后确实要考虑改一下防火墙规则。

@realpg NTLM 是一个我完全没听说过的东西。我去好好研究一下。是法国的 OVH 的一个独立服务器。

@kk2syc 多谢各位的帮助。
MrLonely
220 天前
贴个解决方案吧。ChatGPT 给的答案试过了,不太准确。Claude 给的就测试有效。

Disable NTLM authentication if not needed:

Open Group Policy Editor (gpedit.msc)
Navigate to: Computer Configuration > Windows Settings > Security Settings > Local Policies > Security Options
Find "Network security: Restrict NTLM: Incoming NTLM traffic"
Set it to "Deny all account"


After this, force a policy update by running:
gpupdate /force
cnbatch
219 天前
NTLM 其实也不算罕见的,公司环境 Windows 活动目录的各种交互都会用到,比如用 Windows 账号免登录内网服务就有可能用到 NTLM 。

SMB 文件共享就更有可能使用着 NTLM 。
billccn
219 天前
NTLM 关掉无法登陆是因为强制 Network level authentication(NLA)还开着,但是你的服务器只有 NTLM 一种身份验证方式。你把 NLA 不再强制就可以用 RDP 交互登陆,不再需要 NTLM ,还可以把 SMB 和 RPC 相关的端口关掉。

交互登陆有一个弊端就是别人不需要密码就能连上登录的画面,如果你的 IP 白名单很宽,可能被 DDoS 或者 0day 。

建议自己搭一个 VPN 或者利用新版 Windows 自带的 SSH 服务做端口转发,然后把 RDP 相关端口都放到内网。( SSH 服务只开密钥认证,开放密码登录的话一样也会被扫。)
realpg
219 天前
@cnbatch #12
@MrLonely


公网的 NTLM 在国内就十分罕见了


因为 2002 年以前 各种弱口令泛滥,当时的 CNNIC 高瞻远瞩,要求国内的一级运营商,在区域 BRAS 层面以上就公网 drop 所有 SMB RPC 之类的协议 甚至很多主流运营商,不跨 BRAS 都不行

而本论坛的大部分群友 2002 年可能没出生或者还是个小学生
MrLonely
218 天前
@cnbatch 兄弟,还得是你啊。我后来把 NTLM 重新打开后,防火墙里关掉了 SMB 的 445 端口,就再没有新的 4625 log 出现了。

@billccn 这确实也是个方法,不过我的密码很长,交互登录还是相对不太方便。

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/1108761

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX