V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
MrLonely
V2EX  ›  Windows

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

  •  
  •   MrLonely · 18 天前 · 2085 次点击
    最近买了个 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 的连接。
    第 1 条附言  ·  18 天前
    确实是 NTLM 这个比较小众的登录方式导致的问题。 经过几次对话成功解决了问题。

    如果以后有网友受困扰于 Administrator Locked Out ,那可以考虑一下这个原因。

    贴个解决方案吧。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
    第 2 条附言  ·  17 天前
    问题依然没有解决,根据上面的方法修改过后确实很长时间没有新的 log 显示登录失败了。但是这段时间我自己是沿用了之前的登录状态。但我忘记去检查我还能不能重新登录了。 后来发现我自己登录不了了。

    通过 VNC 窗口 Undo 了最后的操作后重新可以登录了。但与此同时我自己特意输错了一次密码,想看看我自己的错误登录会是什么样子的提示。结果显示同样是 Logon Type 3. NTLM

    我自己用非白名单 IP 尝试登陆 RDP 是无法触发 Log 的,因为都到不了验证用户名和密码的步骤。所以我觉得 Firewall 应该是有正常工作的。NTLM 需要通过其他的办法来阻断。

    但是单纯看待 Logon Type 3 和 NTLM 并无法证明接受爆破的不是 3389.
    第 3 条附言  ·  9 天前
    继续需要求助大家,3389 开启了 IP 白名单,445 端口也彻底 Block 了。Block 之后消停了一段时间。最近突然又开始反复出现 Event ID 4625 。 我还需要屏蔽些什么端口呢?或者有什么办法去检查一下这个 Event ID 4625 具体从哪个端口或者程序触发的嘛?
    15 条回复    2025-02-05 14:05:04 +08:00
    Int100
        1
    Int100  
       18 天前 via iPhone
    建议全阻断,用 vpn 连进去.
    wtks1
        2
    wtks1  
       18 天前
    用 IP 安全策略试试
    geelaw
        3
    geelaw  
       18 天前
    第一个思路是确认你看到的确实是 RDP 登录尝试。Logon Type 是 10 (RemoteInteractive) 吗? Source Port 是 3389 吗?
    MrLonely
        4
    MrLonely  
    OP
       18 天前
    @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
        5
    geelaw  
       18 天前
    @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
        6
    fuzzsh  
       18 天前 via Android
    看下网卡是什么类型的网络,新建端口 3389 的策略勾上对应网络,缺省带来的貌似是分几个程序,不是端口
    yinmin
        7
    yinmin  
       18 天前 via iPhone
    是 vps 吧? 你在云服务商的网站上看看有没有网络防火墙,用云服务商的防火墙做限制。windows 内置防火墙很容易出幺蛾子。实在要用 windows 内置防火墙,自己创建新的入站规则(例如:80 、443 、3389 等),然后把所有内置入站允许的规则都限制为“本地子网”(规则属性-作用域-远程 ip 地址-添加-预定义计算机集:本地子网)
    realpg
        8
    realpg  
       18 天前
    @MrLonely #4
    都写的多明白了 NTLM 认证

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

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

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

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

    @kk2syc 多谢各位的帮助。
    MrLonely
        11
    MrLonely  
    OP
       18 天前
    贴个解决方案吧。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
        12
    cnbatch  
       17 天前
    NTLM 其实也不算罕见的,公司环境 Windows 活动目录的各种交互都会用到,比如用 Windows 账号免登录内网服务就有可能用到 NTLM 。

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

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

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


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


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

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

    @billccn 这确实也是个方法,不过我的密码很长,交互登录还是相对不太方便。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   2781 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 22ms · UTC 05:43 · PVG 13:43 · LAX 21:43 · JFK 00:43
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.