TDCTF Academy Logo TDCTF ACADEMY

Log Forensics

Pengantar

Log Forensics adalah cabang forensika digital yang berfokus pada pengumpulan, analisis, dan interpretasi data log dari berbagai sumber - sistem operasi, aplikasi, perangkat jaringan, dan platform keamanan - untuk merekonstruksi aktivitas insiden keamanan siber. Log menyediakan jejak digital (digital breadcrumbs) yang memungkinkan analis melacak langkah demi langkah aksi attacker, dari awal intrusi hingga dampak akhir.

Log forensics adalah komponen vital dalam setiap investigasi karena beberapa alasan:

  • Persisten dan terstruktur - log biasanya disimpan dalam format terstandarisasi (syslog, EVTX, JSON).
  • Kronologis - setiap log memiliki timestamp yang memungkinkan rekonstruksi timeline.
  • Multi-sumber - korelasi dari berbagai sumber log memberikan gambaran utuh insiden.
  • Legal admissibility - log yang diatur dengan baik (immutable, timestamped) dapat menjadi bukti hukum yang kuat.

Sumber Log Utama

1. Windows Event Log

Windows Event Log adalah sumber log utama untuk sistem Windows. Tersimpan di C:\Windows\System32\winevt\Logs\.

Channel utama:

Channel Lokasi Fungsi
Security Security.evtx Logon/logoff, privilege use, object access
System System.evtx Driver, service start/stop, system errors
Application Application.evtx Aplikasi user-mode (crash, errors)
PowerShell PowerShell-Operational.evtx PowerShell command execution dan script blocks
Task Scheduler Microsoft-Windows-TaskScheduler/Operational.evtx Tugas terjadwal
Sysmon Microsoft-Windows-Sysmon/Operational.evtx Monitoring aktivitas sistem detail

Event ID Penting untuk Forensik:

Event ID Sumber Deskripsi
4624 Security Logon berhasil
4625 Security Logon gagal (indikasi brute force)
4634 Security Logoff
4648 Security Logon dengan explicit credentials
4672 Security Admin logon (privilege assigned)
4688 Security Proses baru dibuat (Process Creation)
4689 Security Proses exit
4698 Security Scheduled task dibuat
4702 Security Scheduled task diupdate
4720 Security User account dibuat
4724 Security Password reset
4732 Security User ditambahkan ke group
5140 Security File share diakses
5156 Security WFP connection allowed
5157 Security WFP connection blocked
7045 System Service baru terinstal
1001 Application Windows Error Reporting (crash)
4103 PowerShell Module logging (command invocation)
4104 PowerShell Script block logging
1 Sysmon Process creation
3 Sysmon Network connection
7 Sysmon Image loaded
8 Sysmon CreateRemoteThread (deteksi injection)
11 Sysmon FileCreate
13 Sysmon Registry value set
15 Sysmon FileCreateStreamHash (Zone Identifier)
22 Sysmon DNSEvent (query DNS)

Contoh analisis - Mencari brute force RDP:

-- Query LogParser untuk brute force RDP
SELECT TimeGenerated, EXTRACT_TOKEN(Strings, 5, '|') AS UserName,
EXTRACT_TOKEN(Strings, 8, '|') AS SourceIP,
COUNT(*) AS Attempts
FROM 'C:\Windows\System32\winevt\Logs\Security.evtx'
WHERE EventID = 4625 AND LogonType = 10
GROUP BY SourceIP, UserName
HAVING Attempts > 5
ORDER BY Attempts DESC

2. Syslog (Linux/Unix)

Syslog adalah standar logging untuk sistem Linux/Unix. Format syslog tradisional:

<Priority>[Timestamp] [Hostname] [Process[PID]]: Message

Contoh syslog:

Jul 22 02:15:01 web01 sshd[12345]: Failed password for root from 203.0.113.5 port 54321 ssh2
Jul 22 02:15:02 web01 sshd[12345]: Failed password for root from 203.0.113.5 port 54322 ssh2
Jul 22 02:15:05 web01 sshd[12345]: Accepted password for admin from 203.0.113.5 port 54325 ssh2

Lokasi log Linux:

File Konten
/var/log/syslog System log umum
/var/log/auth.log Authentication log (login, sudo, SSH)
/var/log/kern.log Kernel log
/var/log/messages Informational messages
/var/log/apache2/access.log Apache HTTP access log
/var/log/apache2/error.log Apache HTTP error log
/var/log/nginx/access.log Nginx HTTP access log
/var/log/nginx/error.log Nginx HTTP error log
/var/log/firewall.log Firewall log (iptables/ufw/nftables)
/var/log/faillog Record failed login attempts

3. Apache/Nginx Access Log

Web server log adalah sumber penting untuk mendeteksi serangan web.

Format Apache Combined:

192.168.1.1 - - [22/Jul/2026:02:15:01 +0700] "GET /wp-admin/admin-ajax.php HTTP/1.1" 200 543 "https://target.com/wp-admin/" "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)"

Deteksi SQL Injection:

cat /var/log/apache2/access.log | grep -E "(\%27|select|union|drop|--|'|\")" | head -20

Deteksi Directory Traversal:

cat /var/log/apache2/access.log | grep -E "\.\.\/|%2e%2e%2f|%2e%2e/" | head -20

4. Firewall Log

Firewall log mencatat koneksi jaringan yang diizinkan dan diblokir.

Contoh iptables log (via rsyslog):

Jul 22 03:00:01 fw01 kernel: [12345.678901] DROP IN=eth0 OUT= MAC=... SRC=185.234.xx.xx DST=10.0.0.1 LEN=40 TOS=0x00 PREC=0x00 TTL=110 ID=54321 PROTO=TCP SPT=4000 DPT=3389

Contoh firewall log pfSense/OPNsense:

2026-07-22T03:00:01 10.0.0.1 pass in on wan: 185.234.xx.xx:4000 -> 10.0.0.1:3389 (RDP scan)

5. IDS/IPS Log

Intrusion Detection/Prevention System seperti Snort atau Suricata mencatat alert deteksi serangan.

Contoh alert Snort:

[**] [1:2010937:3] ET TROJAN Win32/Emotet Checkin [**]
[Classification: A Network Trojan was detected] [Priority: 1]
07/22-03:00:01.123456 185.234.xx.xx:4000 -> 10.0.0.1:443
TCP TTL:110 TOS:0x0 ID:54321 IpLen:20 DgmLen:500

Contoh alert Suricata dalam format JSON (EVE):

{
"timestamp": "2026-07-22T03:00:01.123456+0700",
"event_type": "alert",
"src_ip": "185.234.xx.xx",
"src_port": 4000,
"dest_ip": "10.0.0.1",
"dest_port": 443,
"alert": {
"action": "allowed",
"signature_id": 2010937,
"signature": "ET TROJAN Win32/Emotet Checkin",
"category": "A Network Trojan was detected",
"severity": 1
}
}

Tools Analisis Log

1. LogParser (Microsoft)

LogParser adalah tool command-line untuk query log menggunakan SQL-like syntax. Sangat powerfull untuk Windows Event Log, IIS Log, CSV, dan berbagai format lainnya.

Query dasar:

LogParser.exe -i:EVT "SELECT TimeGenerated, EventID, Message FROM Security WHERE EventID=4625"

Analisis brute force - ringkas per IP:

LogParser.exe -i:EVT "SELECT EXTRACT_TOKEN(Strings, 8, '|') AS SourceIP, COUNT(*) AS FailedAttempts FROM Security WHERE EventID=4625 GROUP BY SourceIP ORDER BY FailedAttempts DESC"

Export ke CSV:

LogParser.exe -i:EVT "SELECT TimeGenerated, EventID, Message FROM Security WHERE EventID=4688" -o:CSV > processes.csv

2. KQL (Kusto Query Language)

KQL digunakan di Azure Sentinel dan Microsoft 365 Defender. Contoh query untuk investigasi:

// Cari proses PowerShell yang mencurigakan
SecurityEvent
| where EventID == 4688
| where ProcessName contains "powershell"
| where CommandLine contains "-enc" or CommandLine contains "hidden"
| project TimeGenerated, Account, ProcessName, CommandLine, Computer
| order by TimeGenerated desc
// Deteksi brute force logon
SecurityEvent
| where EventID == 4625
| summarize FailedAttempts = count() by TargetAccount, IpAddress = IpAddress
| where FailedAttempts > 10
| order by FailedAttempts desc

3. ELK Stack (Elasticsearch, Logstash, Kibana)

ELK Stack adalah solusi open-source yang sangat populer untuk log management dan analisis.

Workflow:

  1. Beats/Logstash - mengumpulkan dan memproses log.
  2. Elasticsearch - menyimpan dan mengindeks log.
  3. Kibana - visualisasi dan analisis interaktif.

Contoh Logstash configuration:

input {
beats {
port => 5044
}
}

filter {
if [event_id] == 4625 {
mutate {
add_tag => ["brute_force_candidate"]
}
}
date {
match => ["timestamp", "ISO8601"]
target => "@timestamp"
}
geoip {
source => "[source][ip]"
target => "[source][geo]"
}
}

output {
elasticsearch {
hosts => ["http://localhost:9200"]
index => "wazuh-alerts-%{+YYYY.MM.dd}"
}
}

Kibana Query Language (KQL) untuk threat hunting:

event_id: 4688 AND process.name: ("powershell.exe" OR "cmd.exe" OR "wscript.exe" OR "cscript.exe")
AND process.command_line: ("-enc*" OR "IEX*" OR "Invoke-*" OR "DownloadString*")

4. Wazuh (SIEM Open-Source)

Wazuh adalah Security Information and Event Management (SIEM) open-source yang berbasis pada Elastic Stack dan OSSEC. Wazuh menyediakan:

  • Log collection - dari Windows, Linux, macOS, dan perangkat jaringan.
  • File Integrity Monitoring (FIM) - mendeteksi perubahan file kritis.
  • Vulnerability detection - scan kerentanan.
  • Active response - otomatis merespons ancaman.
  • Compliance monitoring - PCI DSS, GDPR, HIPAA.

Decoders Wazuh untuk analisis log:

<decoder name="windows-security-4625">
<parent>windows</parent>
<type>windows</type>
<id>4625</id>
<regex>An account failed to log on\.\s+Subject:\s+Security ID:\s+(\S+)\s+Account Name:\s+(\S+)\s+Account Domain:\s+(\S+)</regex>
<order>subject_security_id, subject_account_name, subject_account_domain</order>
</decoder>

Alert Wazuh untuk deteksi brute force:

** Alert 1654321.12345 - windows - security
2026 Jul 22 03:00:01 win-server->Security
Rule: 60105 (level 10) -> 'Windows Security Event 4625 - Account failed to log on'
{
"win": {
"system": {
"event_id": 4625,
"source_name": "Microsoft-Windows-Security-Auditing"
},
"eventdata": {
"targetUserName": "Administrator",
"targetDomainName": "CORP",
"ipAddress": "203.0.113.5",
"logonType": "10"
}
}
}

Timeline Reconstruction

Timeline reconstruction dari log adalah proses menyusun urutan kejadian secara kronologis berdasarkan timestamp dari berbagai sumber log.

Format timestamp umum:

Format Contoh
ISO 8601 2026-07-22T02:15:01+07:00
RFC 3164 (syslog BSD) Jul 22 02:15:01
RFC 5424 (syslog) 2026-07-22T02:15:01.123456Z
Windows Event Log 22/07/2026 02:15:01
Apache Combined Format 22/Jul/2026:02:15:01 +0700

Normalisasi timestamp adalah langkah penting - semua timestamp harus dikonversi ke format umum (misalnya ISO 8601 UTC) sebelum korelasi.

Contoh normalisasi dengan Python:

from datetime import datetime
import pytz

# Apache log timestamp
apache_ts = "22/Jul/2026:02:15:01 +0700"
dt = datetime.strptime(apache_ts, "%d/%b/%Y:%H:%M:%S %z")

# Konversi ke UTC
utc_dt = dt.astimezone(pytz.UTC)
print(utc_dt.isoformat()) # 2026-07-21T19:15:01+00:00

Membuat unified timeline (CSV):

Timestamp (UTC) Source Event
2026-07-21T19:10:00Z Firewall Port scan dari 185.234.xx.xx ke 10.0.0.1:443
2026-07-21T19:12:00Z Web Server POST /login.php dengan parameter SQL injection
2026-07-21T19:12:30Z WAF SQL Injection blocked - alert severity high
2026-07-21T19:15:00Z Windows Sec Event 4625 - 50 failed logon sebagai admin
2026-07-21T19:16:00Z Windows Sec Event 4624 - logon berhasil dari 185.234.xx.xx
2026-07-21T19:16:05Z Sysmon Process creation: cmd.exe /c whoami
2026-07-21T19:16:30Z Web Server POST /upload.php - file upload suspicious
2026-07-21T19:17:00Z Sysmon Network connection: evil.exe -> 185.234.xx.xx:8443

Log Correlation

Korelasi log adalah proses menghubungkan event dari sumber yang berbeda untuk mengidentifikasi pola serangan.

Teknik Korelasi

1. Time-Based Correlation

Menghubungkan event berdasarkan waktu yang berdekatan.

Contoh: Brute force web login (Apache log) + sukses login (Windows Event Log) + koneksi C2 (firewall log).

2. IP-Based Correlation

Mengelompokkan event dari sumber IP yang sama.

Contoh query:

SELECT * FROM (
SELECT source_ip, 'firewall' AS source, count(*) AS events
FROM firewall_logs WHERE timestamp BETWEEN '2026-07-22 00:00' AND '2026-07-22 04:00'
GROUP BY source_ip, source
UNION ALL
SELECT ip_address, 'windows' AS source, count(*) AS events
FROM security_logs WHERE event_id=4625 AND timestamp BETWEEN '2026-07-22 00:00' AND '2026-07-22 04:00'
GROUP BY ip_address, source
)
WHERE events > 10
ORDER BY events DESC

3. Attack Chain Correlation

Menghubungkan event sesuai dengan fase cyber kill chain:

Fase Log Source Indikator
Reconnaissance Firewall, WAF, IDS Port scan, directory scan
Weaponization Email Gateway Attachment mencurigakan, link phishing
Delivery Proxy, Email, Firewall File download dari IP asing
Exploitation Web Server, Application Log SQL injection, RCE attempt, buffer overflow
Installation Sysmon, Windows Event Log File creation, service install, scheduled task
C2 Firewall, DNS, Proxy Beaconing ke IP asing, domain generation algorithm
Actions on Objective Windows Event Log, File Server File access, data exfiltration, privilege escalation

Deteksi Pattern Serangan via Log

1. Brute Force Attack

Indikator:

  • Multiple failed logon (Event ID 4625) dari IP yang sama dalam waktu singkat.
  • Logon type yang bervariasi (2=interactive, 3=network, 10=remote).
  • Username yang tidak dikenal atau username umum (admin, root, administrator).

Deteksi KQL:

SecurityEvent
| where EventID == 4625
| summarize FailedAttempts = count(), DistinctUsers = dcount(TargetAccount)
by IpAddress, bin(TimeGenerated, 5m)
| where FailedAttempts > 20
| project TimeGenerated, IpAddress, FailedAttempts, DistinctUsers

Deteksi via Apache log:

cat /var/log/apache2/access.log | grep "401" | awk '{print $1}' | sort | uniq -c | sort -nr | head -10

Contoh output:

150 203.0.113.5
45 198.51.100.20
12 192.0.2.15

2. Data Exfiltration

Indikator:

  • Transfer data besar ke IP eksternal (firewall/proxy log).
  • Upload traffic di luar jam kerja.
  • Kompresi file besar sebelum transfer.
  • DNS queries dengan subdomain panjang (DNS tunneling).
  • Koneksi ke cloud storage (Dropbox, Google Drive, OneDrive) dari internal server.

Deteksi ELK KQL:

source: "firewall" AND bytes_out > 100000000
AND NOT destination.ip: (10.0.0.0/8 OR 172.16.0.0/12 OR 192.168.0.0/16)
AND NOT destination.domain: ("*.microsoft.com" OR "*.windowsupdate.com")

Deteksi DNS tunneling:

cat /var/log/syslog | grep "query:" | awk '{print $NF}' | sort | uniq -c | sort -nr | head -20
# Cari domain dengan subdomain panjang (lebih dari 40 karakter)

3. Privilege Escalation

Indikator:

  • Event ID 4672 (Special privileges assigned) setelah logon user biasa.
  • Event ID 4732 (User added to security group) - user ditambahkan ke Administrators.
  • Event ID 4724 (Password reset) oleh user non-admin.
  • Scheduled task baru (Event ID 4698) dengan konteks SYSTEM.
  • Service baru (Event ID 7045) dengan SERVICE_WIN32_OWN_PROCESS.

Deteksi KQL:

// Cari privilege escalation
let PrivilegedUsers = SecurityEvent
| where EventID == 4732
| where TargetGroupName == "Administrators"
| project TargetUser, TimeGenerated, Computer;
let ProcessWithAdmin = SecurityEvent
| where EventID == 4688
| where SubjectUserSid == SubjectLogonId
| project TimeGenerated, Account, ProcessName;
PrivilegedUsers | join kind=inner ProcessWithAdmin on Account, TimeGenerated

4. Lateral Movement

Indikator:

  • Logon dengan explicit credentials (Event ID 4648) - user login ke beberapa workstation.
  • Remote Desktop connections (Logon Type 10).
  • PsExec atau WMI execution (Event ID 4688 dengan parent process services.exe).
  • File share access (Event ID 5140) dari IP internal yang tidak biasa.
  • Service creation remote (Event ID 7045).

Deteksi KQL:

SecurityEvent
| where EventID == 4648
| summarize LateralMoves = count()
by SubjectAccount, TargetServer, IpAddress
| where LateralMoves > 3

Studi Kasus: Investigasi Data Breach via Log

Skenario: Perusahaan ritel mendeteksi kebocoran data kartu kredit pelanggan. Tim forensik melakukan analisis log untuk merekonstruksi insiden.

Langkah-langkah:

  1. Pengumpulan log dari berbagai sumber: Windows Event Log (20 server), Apache access log (4 web server), firewall log, WAF log, dan log database.

  2. Normalisasi timestamp - semua log dikonversi ke UTC menggunakan script Python.

  3. Timeline reconstruction:

UTC Time Source Event
2026-07-21 02:00:01 WAF SQLi attempt detected - URL: /products?id=1'
2026-07-21 02:05:12 Apache GET /admin/login.php dari 45.33.xx.xx
2026-07-21 02:05:30 Apache POST /admin/login.php - 401 (brute force) x200
2026-07-21 02:15:00 Windows Sec Event 4624 - user admin login dari 45.33.xx.xx
2026-07-21 02:16:00 Windows Sec Event 4688 - cmd.exe /c "net use \db01\sales"
2026-07-21 02:20:00 Database Log SELECT * FROM credit_cards - 50.000 rows
2026-07-21 02:25:00 Firewall 100MB outbound dari web01 ke 45.33.xx.xx:443
2026-07-21 02:25:30 Windows Sec Event 4624 - admin logoff
  1. Korelasi log: Ditemukan bahwa:

    • Attacker mengeksploitasi SQL injection di halaman produk.
    • Mendapatkan credential admin dari database.
    • Login ke panel admin via brute force yang berhasil.
    • Dari server web, melakukan lateral movement ke database server.
    • Mengekstrak 50.000 data kartu kredit.
    • Mengompres dan meng-exfiltrate data melalui HTTPS.
  2. Root cause: Input validation tidak memadai di parameter id pada endpoint /products.

  3. Rekomendasi:

    • Implement parameterized query untuk semua endpoint.
    • WAF rule untuk blocking SQL injection pattern.
    • Enable extended audit logging di database.
    • Implement detection rule untuk lateral movement.

Kesimpulan

Log forensics adalah ujung tombak investigasi digital modern. Dengan menguasai:

  1. Sumber log - Windows Event Log, Syslog, Apache/Nginx, Firewall, IDS/IPS.
  2. Tools analisis - LogParser, KQL, ELK Stack, Wazuh.
  3. Teknik korelasi - time-based, IP-based, attack chain.
  4. Deteksi pattern - brute force, data exfiltration, privilege escalation, lateral movement.
  5. Timeline reconstruction - normalisasi timestamp, unified timeline.

Seorang analis forensik dapat merekonstruksi seluruh attack chain hanya dari data log - asalkan log dikonfigurasi, dikelola, dan diamankan dengan baik. Investasi pada log management yang robust (SIEM seperti Wazuh atau ELK) adalah salah satu keputusan keamanan paling strategis yang bisa dilakukan organisasi.

PADA HALAMAN INI