MDstable
NoteSnippetChecklistPlaybook

Event Logs Windows

Analyser les journaux d'événements Windows pour le diagnostic et la sécurité

snippetintermediate 2025-05-10 4 min read
windowseventlogsecurityauditwevtutilpowershell

Event IDs critiques à surveiller

Authentification et accès

| Event ID | Canal | Description | |----------|----------|------------------------------------------| | 4624 | Security | Connexion réussie | | 4625 | Security | Échec de connexion | | 4634 | Security | Déconnexion | | 4648 | Security | Connexion avec credentials explicites | | 4672 | Security | Connexion avec privilèges spéciaux | | 4768 | Security | Demande ticket Kerberos (TGT) | | 4769 | Security | Demande ticket de service Kerberos | | 4776 | Security | Validation credentials NTLM |

Comptes et groupes

| Event ID | Description | |----------|--------------------------------------------------| | 4720 | Compte utilisateur créé | | 4722 | Compte activé | | 4723 | Tentative de changement de mot de passe | | 4724 | Mot de passe réinitialisé par admin | | 4725 | Compte désactivé | | 4726 | Compte supprimé | | 4732 | Membre ajouté à un groupe local | | 4756 | Membre ajouté à un groupe universel |

Système et services

| Event ID | Canal | Description | |----------|---------|-------------------------------------------| | 7034 | System | Service s'est arrêté de façon inattendue | | 7036 | System | Service démarré/arrêté | | 7045 | System | Nouveau service installé | | 1102 | Security| Journal de sécurité effacé (ALERTE) | | 4698 | Security| Tâche planifiée créée | | 4702 | Security| Tâche planifiée modifiée |

Requêtes PowerShell

powershell
# Échecs de connexion des dernières 24h
Get-WinEvent -FilterHashtable @{
LogName = 'Security'
Id = 4625
StartTime = (Get-Date).AddHours(-24)
} | Select-Object TimeCreated,
@{N='User'; E={$_.Properties[5].Value}},
@{N='Source IP';E={$_.Properties[19].Value}},
@{N='Reason'; E={$_.Properties[8].Value}}
# Connexions réussies (hors comptes machine $)
Get-WinEvent -FilterHashtable @{LogName='Security'; Id=4624} -MaxEvents 100 |
Where-Object { $_.Properties[5].Value -notlike '*$' } |
Select-Object TimeCreated,
@{N='User'; E={$_.Properties[5].Value}},
@{N='LogonType';E={$_.Properties[8].Value}},
@{N='Source IP';E={$_.Properties[18].Value}}
# Services installés (potentiel malware)
Get-WinEvent -FilterHashtable @{LogName='System'; Id=7045} |
Select-Object TimeCreated,
@{N='ServiceName';E={$_.Properties[0].Value}},
@{N='ImagePath'; E={$_.Properties[1].Value}}
# Journal effacé — alerte critique
Get-WinEvent -FilterHashtable @{LogName='Security'; Id=1102} |
Select-Object TimeCreated, Message

wevtutil — CLI

powershell
# Lister les journaux disponibles
wevtutil el | Select-String "Security|System|Application"
# Infos sur un journal
wevtutil gl Security
# Requête simple
wevtutil qe Security /q:"*[System[EventID=4625]]" /f:text /c:10
# Requête XPath avec filtre date
wevtutil qe Security /q:"*[System[EventID=4625 and TimeCreated[@SystemTime>='2025-05-01T00:00:00']]]" /f:text
# Exporter un journal
wevtutil epl Security C:\Logs\security-backup.evtx
# Effacer un journal (admin requis)
wevtutil cl Application

Requêtes XPath dans l'Event Viewer

xml
<!-- Tous les échecs de connexion sur les 7 derniers jours -->
<QueryList>
<Query Id="0" Path="Security">
<Select Path="Security">
*[System[EventID=4625 and TimeCreated[timediff(@SystemTime) &lt;= 604800000]]]
</Select>
</Query>
</QueryList>
<!-- Services créés ou modifiés -->
<QueryList>
<Query Id="0" Path="System">
<Select Path="System">*[System[EventID=7045 or EventID=7040]]</Select>
</Query>
</QueryList>

Logon Types

| Type | Nom | Description | |------|--------------|------------------------------------------------| | 2 | Interactive | Connexion console locale | | 3 | Network | Accès réseau (partage, RPC...) | | 4 | Batch | Tâche planifiée | | 5 | Service | Service Windows | | 7 | Unlock | Déverrouillage de session | | 8 | NetworkClear | Réseau avec mot de passe en clair (WDigest) | | 10 | RemoteInteractive | Bureau à distance (RDP) | | 11 | CachedInteractive | Connexion locale avec cache de creds |

Centralisation des logs

powershell
# Windows Event Forwarding (WEF) — configurer un collector
winrm quickconfig -q
# Sur les sources, configurer la subscription
# (via GPO ou wecutil)
wecutil cs subscription.xml
# Vérifier les subscriptions actives
wecutil es
wecutil gs "Nom-Subscription"
💡 Tip —

L'Event ID 1102 (journal de sécurité effacé) est un indicateur de compromission majeur. Le monitorer en temps réel via un SIEM. Sur un DC, également surveiller 4756 (ajout à un groupe privilégié) et 4768/4769 (Kerberoasting).

OPS·BRAIN v1.09 notes · SysAdminlocal