Wazuh Agent — Config & Response
Konfigurasi ossec.conf, tambah log sources, active response, Sysmon integration, dan FIM advanced.
1. 01 — ossec.conf — Agent Configuration
File konfigurasi utama: /var/ossec/etc/ossec.conf (Linux/Mac) atau C:\Program Files (x86)\ossec-agent\ossec.conf (Windows).
2. Section: <server> — Koneksi ke Manager
<ossec_config>
<client>
<server>
<address>192.168.1.10</address>
<port>1514</port>
<protocol>tcp</protocol>
</server>
<server>
<address>192.168.1.11</address>
</server>
<notify_time>10</notify_time>
<time-reconnect>60</time-reconnect>
</client>
</ossec_config>3. Section: <localfile> — Log Sources
<localfile>
<log_format>syslog</log_format>
<location>/var/log/syslog</location>
</localfile>
<localfile>
<log_format>syslog</log_format>
<location>/var/log/auth.log</location>
</localfile>
<localfile>
<log_format>apache</log_format>
<location>/var/log/apache2/access.log</location>
</localfile>
<localfile>
<log_format>json</log_format>
<location>/var/log/myapp/events.json</location>
</localfile>4. Section: <syscheck> — FIM
<syscheck>
<disabled>no</disabled>
<frequency>43200</frequency>
<directories check_all="yes" realtime="yes">/etc,/usr/bin,/usr/sbin</directories>
<directories check_all="yes" realtime="yes">/bin,/sbin,/boot</directories>
<ignore>/etc/mtab</ignore>
<ignore type="sregex">.log$|.swp$</ignore>
</syscheck>5. Section: <rootcheck> & <syscollector>
<rootcheck>
<disabled>no</disabled>
<frequency>36000</frequency>
</rootcheck>
<wodle name="syscollector">
<disabled>no</disabled>
<interval>1h</interval>
<scan_on_start>yes</scan_on_start>
<hardware>yes</hardware>
<os>yes</os>
<network>yes</network>
<packages>yes</packages>
<ports all="no">yes</ports>
<processes>yes</processes>
</wodle>Setelah edit ossec.conf: Selalu restart agent! sudo systemctl restart wazuh-agent. Cek log untuk error parsing XML.
6. 02 — Centralized Configuration
Push konfigurasi dari Manager pakai agent.conf — nggak perlu SSH ke setiap agent.
7. agent.conf (di Manager)
<!-- /var/ossec/etc/shared/webservers/agent.conf -->
<agent_config>
<localfile>
<log_format>apache</log_format>
<location>/var/log/apache2/access.log</location>
</localfile>
<localfile>
<log_format>apache</log_format>
<location>/var/log/apache2/error.log</location>
</localfile>
<syscheck>
<directories check_all="yes" realtime="yes">/var/www/html</directories>
<directories check_all="yes" realtime="yes">/etc/apache2</directories>
</syscheck>
</agent_config>8. ossec.conf vs agent.conf
| Aspek | ossec.conf (lokal) | agent.conf (centralized) |
|---|---|---|
| Lokasi edit | Di setiap agent | Di Manager, per group |
| Scope | Satu agent | Semua agent di group |
| Deploy | Manual (SSH) | Otomatis push |
| Priority | Di-override oleh agent.conf | Menang kalau konflik |
9. 03 — Windows Event Channels
<localfile>
<location>Security</location>
<log_format>eventchannel</log_format>
</localfile>
<localfile>
<location>System</location>
<log_format>eventchannel</log_format>
</localfile>
<localfile>
<location>Microsoft-Windows-Sysmon/Operational</location>
<log_format>eventchannel</log_format>
</localfile>
<localfile>
<location>Microsoft-Windows-PowerShell/Operational</location>
<log_format>eventchannel</log_format>
</localfile>
<localfile>
<location>Microsoft-Windows-Windows Defender/Operational</location>
<log_format>eventchannel</log_format>
</localfile>10. 04 — Active Response
Otomatis ambil tindakan saat rule trigger: block IP, disable account, kirim notifikasi.
Active Response bisa auto-block IP legitimate kalau salah konfigurasi. Selalu test di staging dulu. Gunakan whitelist untuk management IP.
11. Built-in Commands
| Command | Fungsi | Platform |
|---|---|---|
| firewall-drop | Block IP di iptables/netsh | Linux, Windows |
| host-deny | Tambah IP ke /etc/hosts.deny | Linux |
| disable-account | Disable user account | Linux, Windows |
| restart-wazuh | Restart Wazuh agent/manager | All |
12. Active Response Config (Manager)
<command>
<name>firewall-drop</name>
<executable>firewall-drop</executable>
<timeout_allowed>yes</timeout_allowed>
</command>
<active-response>
<command>firewall-drop</command>
<location>local</location>
<rules_id>5763</rules_id>
<timeout>600</timeout>
</active-response>
<global>
<white_list>10.0.0.1</white_list>
<white_list>192.168.1.0/24</white_list>
</global>13. Custom: Slack Notification Script
#!/bin/bash
# /var/ossec/active-response/bin/slack-notify.sh
read INPUT_JSON
ALERT_MSG=$(echo $INPUT_JSON | jq -r '.parameters.alert.rule.description')
ALERT_LEVEL=$(echo $INPUT_JSON | jq -r '.parameters.alert.rule.level')
SRC_IP=$(echo $INPUT_JSON | jq -r '.parameters.alert.data.srcip')
AGENT_NAME=$(echo $INPUT_JSON | jq -r '.parameters.alert.agent.name')
WEBHOOK_URL="https://hooks.slack.com/services/YOUR/WEBHOOK/URL"
curl -s -X POST "$WEBHOOK_URL" \
-H 'Content-Type: application/json' \
-d "{ \"text\": \"Wazuh Alert (Level $ALERT_LEVEL)\\n$ALERT_MSG\\nAgent: $AGENT_NAME\\nSource: $SRC_IP\" }"14. 05 — Sysmon + Wazuh (Windows)
Sysmon dari Microsoft Sysinternals = game changer untuk Windows endpoint monitoring. Tanpa Sysmon, kamu buta terhadap process-level activity.
15. Tanpa vs Dengan Sysmon
| Event Type | Tanpa Sysmon | Dengan Sysmon |
|---|---|---|
| Process creation | Event 4688 — nama proses saja | Sysmon 1 — full command line, parent, hash |
| Network connection | Firewall log (terbatas) | Sysmon 3 — proses mana konek ke IP mana |
| File creation | Tidak ada | Sysmon 11 — file baru oleh proses apa |
| Registry changes | Audit policy (ribet) | Sysmon 12/13/14 — create, modify, delete |
| DNS queries | Tidak ada | Sysmon 22 — proses mana query domain apa |
16. Install Sysmon
# Download config SwiftOnSecurity
Invoke-WebRequest -Uri "https://raw.githubusercontent.com/SwiftOnSecurity/sysmon-config/master/sysmonconfig-export.xml" -OutFile sysmonconfig.xml
# Install Sysmon
.\Sysmon64.exe -accepteula -i sysmonconfig.xml
# Verify
Get-Service Sysmon64
Get-WinEvent -LogName "Microsoft-Windows-Sysmon/Operational" -MaxEvents 517. Best Practice
Sysmon + Wazuh Agent adalah minimum setup untuk Windows endpoint monitoring di SOC. Install Sysmon di SEMUA Windows endpoint.
18. 06 — FIM Advanced
Fitur advanced FIM: real-time monitoring, who-data, registry monitoring, dan tuning.
19. Who-Data — Track Siapa yang Ubah File
<syscheck>
<directories check_all="yes" whodata="yes">/etc</directories>
<directories check_all="yes" whodata="yes">/var/www/html</directories>
</syscheck>Who-data butuh auditd aktif di Linux. Install: apt install auditd.
20. FIM Tuning & Ignore Patterns
<syscheck>
<file_limit>
<enabled>yes</enabled>
<entries>200000</entries>
</file_limit>
<ignore>/etc/mtab</ignore>
<ignore type="sregex">\.log$|\.tmp$|\.swp$</ignore>
<directories check_all="yes" restrict=".conf$|.cfg$|.ini$">/etc</directories>
<directories check_all="yes" recursion_level="3">/home</directories>
</syscheck>21. Windows Registry Monitoring
<syscheck>
<windows_registry arch="both">HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run</windows_registry>
<windows_registry arch="both">HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunOnce</windows_registry>
<windows_registry arch="both">HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run</windows_registry>
<windows_registry>HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services</windows_registry>
<windows_registry>HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tasks</windows_registry>
</syscheck>Prioritaskan Run, RunOnce, dan Services — ini yang paling umum dipakai malware untuk persistence.