IntermedioWindowsSysmonthreat huntingconfiguracióndetecciónSIEM

Sysmon: Configuración Avanzada para Threat Hunting y Detección de Malware

Guía práctica de Sysmon para detección de malware. Configuración optimizada por Event ID, filtros para reducir ruido, integración con SIEM, reglas de detección para las técnicas más comunes y workflows de threat hunting con Sysmon.

MalwareIntel Research··9 min lectura
Serie: Malware en Windows — Parte 12

Sysmon: visibilidad sin presupuesto de EDR

Si solo puedes instalar una herramienta de seguridad en tus endpoints Windows, esa herramienta debería ser Sysmon. Es gratuita, ligera, y proporciona telemetría que Windows no genera por defecto: command lines completas, hashes de procesos, conexiones de red por proceso, accesos cross-process, y modificaciones de registro con detalle.

La mayoría de las reglas Sigma asumen que Sysmon está instalado. Los análisis de The DFIR Report usan Sysmon como fuente primaria. Los threat hunters consideran Sysmon como herramienta básica.

Event IDs de Sysmon: referencia completa

Event IDs por prioridad de seguridad

IDEventoPrioridadUso para malware
1Process CreationCriticaCommand lines, parent/child, hashes
3Network ConnectionAltaC2, exfiltración, movimiento lateral
7Image LoadedAltaDLL injection, side-loading, LOLBins
8CreateRemoteThreadCriticaCode injection (DLL, shellcode)
10ProcessAccessCriticaCredential dumping (LSASS), injection
11FileCreateMediaDropper, payload escrito en disco
12/13/14Registry EventsAltaPersistencia (Run keys, services)
15FileCreateStreamHashMediaAlternate Data Streams (evasión)
17/18Pipe Created/ConnectedMediaCobalt Strike named pipes, PsExec
19/20/21WMI EventsAltaWMI persistence (subscriptions)
22DNS QueryMediaC2 domains, DGA, tunneling
23FileDeleteMediaRansomware cleanup, artifact removal
25ProcessTamperingAltaProcess ghosting, herpaderping
26FileDeleteDetectedMediaFile deletion logging
27FileBlockExecutableAltaBloqueo de ejecutables en paths monitorizados
28FileBlockShreddingAltaBloqueo de shredding de archivos
29FileExecutableDetectedAltaNuevo ejecutable creado en disco

Event ID 1: Process Creation (el más importante)

Campos clave:

CampoUso en análisis
ImagePath del ejecutable (¿legítimo? ¿ubicación inusual?)
CommandLineArgumentos completos (¿sospechosos? ¿encoded?)
ParentImageProceso padre (¿cadena normal? ¿padre inusual?)
ParentCommandLineArgumentos del padre
UserUsuario que ejecuta (¿SYSTEM? ¿usuario normal?)
HashesMD5/SHA256 del binario
ProcessGuidGUID único para correlación entre eventos
IntegrityLevelNivel de integridad (High = admin, System = SYSTEM)
CurrentDirectoryDirectorio de trabajo

Detecciones con Event ID 1:

# Ransomware: shadow copy deletion
Image ends with "vssadmin.exe" AND CommandLine contains "delete shadows"

# PowerShell encoded command
Image ends with "powershell.exe" AND CommandLine contains "-enc"

# PsExec lateral movement
Image ends with "psexec.exe" OR ParentImage ends with "PSEXESVC.exe"

# Suspicious parent-child
ParentImage ends with "winword.exe" AND Image ends with "cmd.exe"
(Word spawning cmd = macro maliciosa)

# LOLBin certutil download
Image ends with "certutil.exe" AND CommandLine contains "-urlcache"

Event ID 8: CreateRemoteThread

Se genera cuando un proceso crea un hilo en otro proceso. Es el indicador más directo de code injection.

Alta confianza para malware cuando:

  • SourceImage (proceso que crea el hilo) y TargetImage (proceso donde se crea) son diferentes
  • TargetImage es un proceso del sistema (svchost, explorer, lsass)
  • SourceImage es un proceso desconocido o de ubicación inusual

Falsos positivos comunes: algunos programas legítimos crean threads remotos (debuggers, herramientas de accesibilidad, algunos antivirus). Mantener una allowlist de pares source-target legítimos.

Event ID 10: ProcessAccess

Se genera cuando un proceso abre otro proceso con ciertos derechos de acceso. Crítico para detectar credential dumping.

Detección de LSASS dump:

TargetImage ends with "lsass.exe"
AND GrantedAccess contains "0x1010" or "0x1FFFFF"
AND SourceImage NOT IN allowlist

GrantedAccess valores sospechosos:

  • 0x1010 = PROCESS_QUERY_LIMITED_INFORMATION + PROCESS_VM_READ
  • 0x1FFFFF = PROCESS_ALL_ACCESS
  • 0x1410 = usado por Mimikatz

Event ID 17/18: Named Pipes

Named pipes son usados por Cobalt Strike y PsExec para comunicación:

Pipe nameHerramienta
\MSSE-*Cobalt Strike (default, configurable)
\postex_*Cobalt Strike post-ex
\status_*Cobalt Strike SMB beacon
\msagent_*Cobalt Strike (otro default)
\PSEXESVCPsExec
\srvsvcPsExec/SMB
\winsockMeterpreter

Configuraciones de referencia

SwiftOnSecurity Sysmon Config

La configuración más popular y mantenida:

URL: github.com/SwiftOnSecurity/sysmon-config

Características:

  • Balance entre cobertura y ruido
  • Exclusiones para software común (Chrome, Office, Windows Update)
  • Buena cobertura de Event IDs 1, 3, 7, 8, 10, 11, 12/13
  • Comunidad activa que contribuye mejoras

Olaf Hartong Sysmon Modular

Configuración modular que permite activar/desactivar bloques:

URL: github.com/olafhartong/sysmon-modular

Características:

  • Módulos por técnica ATT&CK
  • Fácil de personalizar
  • Mejor para organizaciones que quieren granularidad

Instalación y actualización

# Instalar Sysmon con configuracion
sysmon64.exe -accepteula -i sysmonconfig.xml

# Actualizar configuracion sin reinstalar
sysmon64.exe -c sysmonconfig.xml

# Verificar configuracion actual
sysmon64.exe -c

# Desinstalar
sysmon64.exe -u

Configuración optimizada para malware detection

Filtros para Event ID 1 (Process Creation)

<RuleGroup name="ProcessCreate" groupRelation="or">
  <ProcessCreate onmatch="include">
    <!-- Ransomware indicators -->
    <CommandLine condition="contains">vssadmin</CommandLine>
    <CommandLine condition="contains">shadowcopy</CommandLine>
    <CommandLine condition="contains">bcdedit</CommandLine>
    <CommandLine condition="contains">wbadmin</CommandLine>
    
    <!-- PowerShell suspicious -->
    <CommandLine condition="contains">-enc</CommandLine>
    <CommandLine condition="contains">-ep bypass</CommandLine>
    <CommandLine condition="contains">-w hidden</CommandLine>
    <CommandLine condition="contains">DownloadString</CommandLine>
    <CommandLine condition="contains">IEX</CommandLine>
    
    <!-- LOLBins -->
    <Image condition="end with">certutil.exe</Image>
    <Image condition="end with">mshta.exe</Image>
    <Image condition="end with">regsvr32.exe</Image>
    <Image condition="end with">cmstp.exe</Image>
    <Image condition="end with">msbuild.exe</Image>
    
    <!-- Lateral movement -->
    <ParentImage condition="end with">PSEXESVC.exe</ParentImage>
    <ParentImage condition="end with">WmiPrvSE.exe</ParentImage>
    
    <!-- Suspicious parent-child -->
    <ParentImage condition="end with">winword.exe</ParentImage>
    <ParentImage condition="end with">excel.exe</ParentImage>
    <ParentImage condition="end with">outlook.exe</ParentImage>
  </ProcessCreate>
</RuleGroup>

Filtros para Event ID 10 (ProcessAccess to LSASS)

<RuleGroup name="ProcessAccess" groupRelation="or">
  <ProcessAccess onmatch="include">
    <TargetImage condition="end with">lsass.exe</TargetImage>
  </ProcessAccess>
  <ProcessAccess onmatch="exclude">
    <!-- Exclude legitimate LSASS accessors -->
    <SourceImage condition="is">C:\Windows\System32\svchost.exe</SourceImage>
    <SourceImage condition="is">C:\Windows\System32\lsm.exe</SourceImage>
    <SourceImage condition="end with">MsMpEng.exe</SourceImage>
    <SourceImage condition="end with">CrowdStrike\CSFalconService.exe</SourceImage>
  </ProcessAccess>
</RuleGroup>

Filtros para Event ID 3 (Network Connection)

<RuleGroup name="NetworkConnect" groupRelation="or">
  <NetworkConnect onmatch="include">
    <!-- Tor connections -->
    <DestinationPort condition="is">9001</DestinationPort>
    <DestinationPort condition="is">9030</DestinationPort>
    
    <!-- Suspicious processes making connections -->
    <Image condition="end with">powershell.exe</Image>
    <Image condition="end with">cmd.exe</Image>
    <Image condition="end with">certutil.exe</Image>
    <Image condition="end with">mshta.exe</Image>
    <Image condition="end with">regsvr32.exe</Image>
    <Image condition="end with">rundll32.exe</Image>
    <Image condition="end with">wscript.exe</Image>
    <Image condition="end with">cscript.exe</Image>
    
    <!-- Rclone exfiltration -->
    <Image condition="end with">rclone.exe</Image>
  </NetworkConnect>
</RuleGroup>

Integración con SIEM

Forwarding de eventos

Sysmon escribe eventos en el Event Log de Windows:

Log: Microsoft-Windows-Sysmon/Operational

Para enviar a un SIEM:

MétodoHerramientaComplejidad
Windows Event Forwarding (WEF)Built-in WindowsMedia
Winlogbeat (Elastic)Elastic AgentBaja
NXLogCommunity/EnterpriseBaja
Splunk Universal ForwarderSplunkBaja
Fluentd/Fluent BitOpen sourceMedia
CriblLog routingMedia

Queries de ejemplo en Splunk

# Procesos sospechosos (shadow copy deletion)
index=sysmon EventCode=1 
  (CommandLine="*vssadmin*delete*shadows*" OR CommandLine="*wmic*shadowcopy*delete*")
| table _time, Computer, User, ParentImage, Image, CommandLine

# LSASS access
index=sysmon EventCode=10 TargetImage="*lsass.exe"
  NOT SourceImage IN ("*svchost.exe", "*MsMpEng.exe", "*csfalcon*")
| table _time, Computer, SourceImage, GrantedAccess

# Remote thread creation
index=sysmon EventCode=8
| where SourceImage!=TargetImage
| table _time, Computer, SourceImage, TargetImage, StartFunction

Queries de ejemplo en Elastic/KQL

# PowerShell encoded commands
event.code: "1" AND process.name: "powershell.exe" AND process.command_line: *-enc*

# Named pipes (Cobalt Strike)
event.code: "17" AND file.name: (*MSSE* OR *postex* OR *status_*)

# DLL loaded from user directory
event.code: "7" AND file.path: *Users* AND NOT file.path: *Program*

Workflows de threat hunting con Sysmon

Hunt 1: procesos hijos de Office anómalos

Office (Word, Excel, PowerPoint) no debería generar procesos como cmd.exe, PowerShell o wscript. Si lo hace, hay una macro maliciosa activa.

Event ID 1 WHERE ParentImage IN (winword.exe, excel.exe, powerpnt.exe)
  AND Image IN (cmd.exe, powershell.exe, wscript.exe, cscript.exe, mshta.exe)

Hunt 2: LSASS access anómalo

Listar todos los procesos que acceden a LSASS y comparar con baseline. Cualquier proceso nuevo es sospechoso.

Event ID 10 WHERE TargetImage = lsass.exe
| stats count by SourceImage
| sort - count

Hunt 3: conexiones de red de procesos que no deberían conectarse

Event ID 3 WHERE Image IN (notepad.exe, calc.exe, mspaint.exe)
  AND DestinationIsIpv4 = true AND NOT DestinationIp startswith "10."

Hunt 4: ejecución desde directorios temporales

Event ID 1 WHERE Image contains "Temp" OR Image contains "AppData\Local\Temp"
  AND Image endswith ".exe"

Hunt 5: named pipes de C2

Event ID 17 WHERE PipeName matches regex "\\\\(MSSE|postex|status_|msagent_|winsock).*"

Tuning: reducir ruido sin perder visibilidad

Proceso de tuning

  1. Instalar con configuración base (SwiftOnSecurity)
  2. Monitorizar volumen durante 1 semana
  3. Identificar top 10 fuentes de ruido (procesos que generan más eventos)
  4. Añadir exclusiones para procesos legítimos ruidosos
  5. Verificar cobertura ejecutando un test de simulación (Atomic Red Team)
  6. Iterar mensualmente

Exclusiones seguras (no añadir sin verificar en tu entorno)

<!-- Ejemplo: excluir Chrome de network connections (muy ruidoso) -->
<NetworkConnect onmatch="exclude">
  <Image condition="end with">chrome.exe</Image>
  <Image condition="end with">msedge.exe</Image>
  <Image condition="end with">firefox.exe</Image>
</NetworkConnect>

<!-- Excluir Windows Update de file creation -->
<FileCreate onmatch="exclude">
  <Image condition="is">C:\Windows\System32\svchost.exe</Image>
  <TargetFilename condition="begin with">C:\Windows\SoftwareDistribution</TargetFilename>
</FileCreate>

Regla de oro: nunca excluir procesos de las detecciones de Event ID 8 (CreateRemoteThread) ni Event ID 10 (ProcessAccess a LSASS). Estos tienen baja tasa de falsos positivos y alta criticidad.

Validación: Atomic Red Team

Atomic Red Team (Red Canary) proporciona tests automatizados para validar que Sysmon detecta las técnicas ATT&CK:

# Instalar
Install-Module -Name invoke-atomicredteam
Install-AtomicRedTeam

# Ejecutar test de shadow copy deletion (T1490)
Invoke-AtomicTest T1490

# Ejecutar test de LSASS dump (T1003.001)  
Invoke-AtomicTest T1003.001

# Verificar que Sysmon generó los eventos esperados
Get-WinEvent -LogName "Microsoft-Windows-Sysmon/Operational" -MaxEvents 20

Mapeo MITRE ATT&CK por Event ID

Event IDTécnicas ATT&CK detectables
1T1059 (Scripting), T1218 (LOLBins), T1490 (Recovery inhibit)
3T1071 (C2), T1048 (Exfiltration), T1021 (Remote Services)
7T1574 (DLL hijacking), T1055 (Injection via DLL)
8T1055 (Process Injection)
10T1003 (Credential Dumping)
11T1105 (Ingress Tool Transfer)
12/13T1547 (Persistence), T1546 (Event Triggered)
17/18T1570 (Lateral Tool Transfer), C2 via named pipes
19/20/21T1546.003 (WMI Event Subscription)
22T1071.004 (DNS), T1568 (DGA)
25T1055.012 (Process Hollowing), Ghosting

Fuentes y referencias

Preguntas frecuentes

Artículos relacionados

Este contenido tiene fines exclusivamente educativos y de investigación en ciberseguridad defensiva. No se proporcionan binarios maliciosos ni payloads ejecutables. El uso indebido de esta información es responsabilidad exclusiva del usuario. Leer disclaimer completo.