Python tools for processing and cleaning IP addresses from Wazuh logs. This toolkit consists of two main scripts that work sequentially to extract, clean, and format blocked IP addresses.
- Overview
- Prerequisites
- Script 1: CSV Formatter
- Script 2: IP Cleaner
- Workflow Penggunaan
- File Input/Output
Tool ini dirancang untuk memproses data dari Wazuh SIEM, dengan fokus pada alamat IP yang diblokir (Firewall-Drop). Proses dilakukan dalam dua tahap:
- Ekstraksi IP: Mengekstrak alamat IP dari file CSV hasil export Wazuh
- Pembersihan IP: Menghapus duplikat dan memformat output final
- Python 3.11
- Wazuh v4.11
- Modul Python:
csv
,re
- File CSV hasil export dari Wazuh
Script ini mengekstrak alamat IP dari file CSV hasil export Wazuh dan menyimpannya dalam format teks.
# Pastikan file input tersedia
ls works-1.csv
# Jalankan script
python3 csv-formarter.py
Row 1: 8 columns - ['timestamp', 'rule_id', 'description', 'level', 'srcip', ...]
Found IP from srcip column: xxx.xx.xxx.xxx
Found IP from regex: xxx.xxx.xx.xxx
...
Total rows: xxx
IP count: xxx
IP addresses written to ip-saja.txt (xxxx IPs)
Script ini membersihkan daftar IP address dari duplikat dan menghasilkan laporan statistik lengkap.
# Pastikan file input dari script pertama tersedia
ls ip-saja.txt
# Jalankan script
python3 clean_ip.py
File Tersedia
Total IP addresses: xxxxxx
IP addresses duplikat: xxx
Total IP duplikat: xxx
Rincian IP duplikat:
xxx.xxx.xxx.xxx : xxx kali
xxx.xxx.xxx.xxx : xxx kali
xxx.xxx.xxx.xxx : xxx kali
...
Total IP addresses setelah dibersihkan: xxx
IP addresses yang dihapus: xxx
Clean IP addresses berhasil disimpan ke ip-bersih.txt
==================================================
SUMMARY:
==================================================
Total IP sebelum dibersihkan: xxx
IP dengan duplikat : xx
Total duplikat entries : xx
Total IP setelah dibersihkan: xxx
==================================================
=== IP Address Cleaning - © NAuliajati ===
- Export data dari Wazuh dalam format CSV
- Pastikan file berada di direktori yang sama dengan script
python3 csv-formarter.py
Expected Output: File ip-saja.txt
berisi daftar semua IP address
python3 clean_ip.py
Expected Output: File ip-bersih.txt
berisi daftar IP address yang telah dibersihkan
# Cek jumlah IP sebelum dibersihkan
wc -l ip-saja.txt
# Cek jumlah IP setelah dibersihkan
wc -l ip-bersih.txt
# Lihat sample IP yang telah dibersihkan
head -10 ip-bersih.txt
File | Tipe | Deskripsi | Script |
---|---|---|---|
works-1.csv |
Input | File CSV hasil export Wazuh | csv-formarter-1.py |
ip-saja.txt |
Output/Input | Daftar IP mentah dari CSV | csv-formarter-1.py → clean_ip.py |
ip-bersih.txt |
Output | Daftar IP yang sudah dibersihkan | clean_ip.py |
© NAuliajati - GPLv3.
Note: Pastikan selalu melakukan backup file asli sebelum memproses data penting.