Cara Menguji Proteksi WAF
Berikut cara praktisnya:
1. Cek log ModSecurity
Biasanya log ada di:
-
/var/log/nginx/error.log
(jika di-merge dengan error log) -
/var/log/modsec_audit.log
(jika pakaiSecAuditLog
)
Kalau rule aktif, setiap request yang diblok/diinspeksi akan muncul di log tersebut.
2. Uji dengan payload umum WAF
✅ Cara benar menjalankan curl
test SQLi:
-
Gunakan
curltanda kutip ganda, dan escape'
dengan%27
(URL encoding):atau browser untuk mengetes. Misalnya:SQL
curl "http:https://yourdomain.com/waf.widianto.org/?id=1%27%20OR%20%271%27=%271"
👉 %27
= '
👉 %20
= spasi
-
Atau pakai single quote di luar, ganti internal
'
jadi'"'"'
:
curl 'https://waf.widianto.org/?id=1'"'"' OR '"'"'1'"'"'='"'"'1'
(Jelek tapi works di bash 😅)
-
Lebih simpel, gunakan
--data-urlencode
kalau test via POST:
curl -G --data-urlencode "id=1' OR '1'='1" "https://waf.widianto.org/"
🔎 Ekspektasi hasil
-
Kalau WAF aktif (CRS 942xxx rules), kamu akan dapat 403 Forbidden.
-
Di log (
audit.log
), rule yang kemungkinan terpicu:-
942100
→ SQL Injection Attack Detected via libinjection -
942110
→ Detects SQL meta-characters like'
-
949110
→ Inbound anomaly score exceeded
-
👉 Jika WAF aktif, harusnya request ini di-block (403 Forbidden).
XSS test
curl "http://yourdomain.com/?q=<script>alert(1)</script>"
👉 WAF akan mendeteksi pola <script>
dan blok request.
LFI test (Local File Inclusion)
curl "http://yourdomain.com/?file=../../etc/passwd"
3. Gunakan SecRuleEngine DetectionOnly
(opsional)
Kalau kamu masih mau mode monitoring, aktifkan DetectionOnly:
SecRuleEngine DetectionOnly
Nanti request tidak diblok, tapi akan tetap tercatat di log. Cocok untuk uji awal.
4. Cek response HTTP
Kalau proteksi aktif, biasanya:
-
Akan dapat 403 Forbidden dari NGINX.
-
Bisa juga keluar halaman error custom tergantung konfigurasi.
5. Tes bypass rule
Untuk memastikan WAF tidak terlalu ketat:
-
Akses normal (misalnya
curl http://yourdomain.com/
) harus sukses (200 OK). -
Payload berbahaya harus ditolak (403/blocked).
👉 Jadi langkah termudah:
-
Coba akses normal → pastikan tetap bisa.
-
Coba akses
?id=1' OR '1'='1
→ pastikan kena blok. -
Cek
modsec_audit.log
untuk bukti rule bekerja.
Mau saya buatkan script otomatis (bash) untuk menguji beberapa payload sekaligus supaya lebih cepat?