Article
Windows Event Log: Truy Vết Attacker Qua EVTX
Các Event ID quan trọng cần theo dõi khi điều tra xâm nhập — authentication, lateral movement, persistence, và process execution.
Windows Event Log là nguồn dữ liệu forensic phong phú nhất trên Windows, nhưng cũng là nơi nhiều analyst bị ngợp vì số lượng event quá lớn. Bài này tập trung vào các Event ID thực sự có giá trị trong điều tra xâm nhập.
Tổng quan các log quan trọng
| Log File | Đường dẫn | Nội dung |
|---|---|---|
| Security | System32\winevt\Logs\Security.evtx | Authentication, account management, object access |
| System | System32\winevt\Logs\System.evtx | System events, service changes |
| Application | System32\winevt\Logs\Application.evtx | Application errors |
| PowerShell | Microsoft-Windows-PowerShell%4Operational.evtx | PS execution |
| Sysmon | Microsoft-Windows-Sysmon%4Operational.evtx | Process, network, registry events |
Thu thập toàn bộ thư mục C:\Windows\System32\winevt\Logs\ trong quá trình IR.
Authentication Events
Logon (4624) và Logon Failure (4625)
Event 4624 ghi lại mọi lần đăng nhập thành công. Field quan trọng nhất là Logon Type:
| Logon Type | Mô tả | Ý nghĩa |
|---|---|---|
| 2 | Interactive | Đăng nhập trực tiếp tại console |
| 3 | Network | Truy cập qua network (SMB, named pipes) |
| 4 | Batch | Scheduled task |
| 5 | Service | Service startup |
| 7 | Unlock | Mở khóa workstation |
| 10 | RemoteInteractive | RDP |
| 11 | CachedInteractive | Logon với cached credentials |
Trong điều tra lateral movement, chú ý:
- Type 3 từ nhiều máy trong thời gian ngắn (SMB spray hoặc Pass-the-Hash)
- Type 10 (RDP) từ IP nội bộ lạ
- Type 2 ngoài giờ làm việc
EventID: 4624
Account Name: DOMAIN\username
Logon Type: 3
Source IP: 10.1.2.100
4625 (logon failure) + count cao từ một IP = brute force. Với Pass-the-Hash, thường thấy 4624 không có 4625 trước đó — vì hash hợp lệ.
Pass-the-Hash detection
Dấu hiệu trong event log:
- 4624 với Logon Type 3 +
NTLMauthentication +NullDomainNamehoặc tên máy thay vì domain - Nhiều 4624 liên tiếp từ cùng source trong vài giây
Lateral Movement
PsExec và SMB Execution (7045, 4697)
Khi attacker dùng PsExec hoặc công cụ tương tự:
Trên target machine:
- 7045 (System log): Service installed — PsExec tạo service tạm thời tên
PSEXESVC - 4697 (Security log): A service was installed in the system
EventID: 7045
Service Name: PSEXESVC
Service File Name: %SystemRoot%\PSEXESVC.exe
Service Type: user mode service
WMI Execution
- Microsoft-Windows-WMI-Activity/Operational: Event 5857, 5858, 5860, 5861
- Tìm WMI subscriptions mới (persistence qua WMI)
Remote Scheduled Tasks (106, 140, 141, 200, 201)
Log: Microsoft-Windows-TaskScheduler/Operational
- 106: Task registered
- 201: Task completed
Kết hợp với 4624 Type 3 từ cùng source IP để xác nhận remote task creation.
Process Execution
Process Creation (4688 và Sysmon 1)
Event 4688 (cần enable audit policy) và Sysmon Event 1 ghi lại quá trình tạo process.
# Enable process creation audit
auditpol /set /subcategory:"Process Creation" /success:enable /failure:enable
Những gì cần tìm:
cmd.exehoặcpowershell.exeđược spawn bởi process ứng dụng (IIS, Office, browser)- Process chạy từ
%TEMP%,%APPDATA%, hoặc path không thông thường - Encoded PowerShell:
-EncodedCommandhoặc-enc
ParentProcessName: C:\Program Files\Microsoft Office\Office16\WINWORD.EXE
NewProcessName: C:\Windows\System32\cmd.exe
CommandLine: cmd.exe /c powershell -enc JABj...
PowerShell Logging (4103, 4104)
Log: Microsoft-Windows-PowerShell/Operational
- 4103: Module logging — ghi lại pipeline execution
- 4104: Script block logging — ghi lại nội dung script trước khi execute
Script block logging (4104) là cực kỳ có giá trị — ngay cả khi script được obfuscate, PowerShell phải deobfuscate trước khi chạy và block logging ghi lại nội dung đã deobfuscate.
EventID: 4104
ScriptBlockText: Invoke-Mimikatz -DumpCreds
Để bật:
# Group Policy: Computer Configuration > Administrative Templates > Windows Components > Windows PowerShell
# Hoặc registry
New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging" -Force
Set-ItemProperty -Path "HKLM:\..." -Name "EnableScriptBlockLogging" -Value 1
Persistence
Registry Run Keys (4657 và Sysmon 13)
Event 4657 (Registry value modified) cần Object Access auditing cho registry key. Sysmon 13 thì đơn giản hơn — ghi lại mọi thay đổi registry.
Run key paths quan trọng:
HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon
HKLM\SYSTEM\CurrentControlSet\Services
Scheduled Task Creation (4698)
EventID: 4698
Task Name: \Microsoft\Windows\UpdateCheck
Task Content: <Actions><Exec><Command>C:\Users\user\AppData\Roaming\malware.exe</Command></Exec></Actions>
Attacker thường dùng tên task giả mạo hệ thống. Chú ý task chạy từ đường dẫn trong user profile.
Account Management
| Event ID | Mô tả |
|---|---|
| 4720 | User account created |
| 4722 | User account enabled |
| 4724 | Password reset attempted |
| 4728 | User added to global group |
| 4732 | User added to local group |
| 4756 | User added to universal group |
Trong điều tra, 4728 và 4732 với group “Administrators” là critical — attacker thêm account vào admin group.
Phân tích với công cụ
# Hayabusa — fast EVTX analysis, SIGMA rule support
hayabusa.exe csv-timeline -d C:\evtx -o timeline.csv
# Chainsaw
chainsaw hunt C:\evtx --sigma sigma_rules/ --mapping mapping.yml
# EvtxECmd (Eric Zimmerman)
EvtxECmd.exe -d C:\Windows\System32\winevt\Logs --csv output_dir
Timeline từ event log cộng với MFT timeline cho bức tranh toàn cảnh nhất về những gì đã xảy ra trên hệ thống.