Skip to content

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.

License

Notifications You must be signed in to change notification settings

Dinas-Kominfo-Kota-Tangerang/wazuh-extract-ip

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Wazuh IP Address Processing Tools

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.

📋 Daftar Isi

Overview

Tool ini dirancang untuk memproses data dari Wazuh SIEM, dengan fokus pada alamat IP yang diblokir (Firewall-Drop). Proses dilakukan dalam dua tahap:

  1. Ekstraksi IP: Mengekstrak alamat IP dari file CSV hasil export Wazuh
  2. Pembersihan IP: Menghapus duplikat dan memformat output final

Prerequisites

  • Python 3.11
  • Wazuh v4.11
  • Modul Python: csv, re
  • File CSV hasil export dari Wazuh

Script 1 {Sample}: CSV Formatter (csv-formarter.py)

🎯 Fungsi

Script ini mengekstrak alamat IP dari file CSV hasil export Wazuh dan menyimpannya dalam format teks.

💻 Penggunaan

# Pastikan file input tersedia
ls works-1.csv

# Jalankan script
python3 csv-formarter.py

📊 Output

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 2: IP Cleaner (clean_ip.py)

🎯 Fungsi Utama

Script ini membersihkan daftar IP address dari duplikat dan menghasilkan laporan statistik lengkap.

💻 Penggunaan

# Pastikan file input dari script pertama tersedia
ls ip-saja.txt

# Jalankan script
python3 clean_ip.py

📊 Output

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 ===

Workflow Penggunaan

Langkah 1: Persiapan Data

  1. Export data dari Wazuh dalam format CSV
  2. Pastikan file berada di direktori yang sama dengan script

Langkah 2: Ekstraksi IP

python3 csv-formarter.py

Expected Output: File ip-saja.txt berisi daftar semua IP address

Langkah 3: Clean IP

python3 clean_ip.py

Expected Output: File ip-bersih.txt berisi daftar IP address yang telah dibersihkan

Langkah 4: Verifikasi Hasil

# 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 Input/Output

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

📄 Lisensi

© NAuliajati - GPLv3.


Note: Pastikan selalu melakukan backup file asli sebelum memproses data penting.

About

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.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%