Basic XSS (Cross-Site Scripting)

Basic XSS (Cross-Site Scripting)

Basic XSS (Cross-Site Scripting)

1. Apa itu XSS?

Cross-Site Scripting (XSS) adalah celah keamanan pada aplikasi web di mana penyerang mampu menyuntikkan skrip berbahaya (biasanya JavaScript) ke halaman yang dipakai oleh pengguna lain.

“Serangan XSS memanfaatkan kurangnya validasi atau sanitasi input di sisi server maupun klien.”

2. Tiga Tipe Utama XSS

  • Reflected XSS: input disuntikkan lewat URL/form lalu dipantulkan langsung ke halaman tanpa disimpan.
  • Stored XSS: skrip jahat disimpan di database dan dijalankan tiap kali halaman tersebut diakses pengguna.
  • DOM-Based XSS: penyuntikan terjadi di sisi klien melalui manipulasi DOM (misalnya via document.write()).

3. Contoh Reflected XSS

  1. Target URL: https://target.com/search?q=hello
  2. Inject: https://target.com/search?q=<script>alert("XSS")</script>
  3. Jika alert muncul, berarti parameter q rentan.

4. Payload Dasar

Tipe Payload Contoh Keterangan
Alert sederhana <script>alert(1)</script> Uji eksekusi JS
Inline event handler <img src=x onerror=alert('XSS')> Gunakan elemen HTML
HTML injection <b onmouseover=alert(1)>Hover me!</b> Kombinasi HTML + JS
URI encoded %3Cscript%3Ealert(document.cookie)%3C%2Fscript%3E Bypass filter sederhana

5. Cara Deteksi di Browser

  • Inspect Element: cari apakah input user muncul langsung di HTML.
  • Console: pantau pesan error atau output skrip.
  • Network Tab: amati request dan respons.

6. Mitigasi XSS

  • Output Encoding: gunakan encoding HTML untuk karakter spesial.
  • Content Security Policy (CSP): batasi sumber skrip yang dijalankan.
  • Validasi & Sanitasi Input: filter input dari user.
  • HttpOnly Cookie: cegah JavaScript membaca cookie.

7. Langkah Selanjutnya

  • Belajar XSS lanjut: bypass filter, DOM-based, CSP trick.
  • Gunakan tools: Burp Suite, OWASP ZAP, Acunetix.
  • Latihan: DVWA, Juice Shop, testphp.vulnweb.com

Kesimpulan

XSS adalah salah satu celah paling umum dan berbahaya. Dengan memahami tipe, payload, dan mitigasi dasar, kau sudah satu langkah lebih dekat menjadi pentester yang solid.


Author: Nyx6st

Post a Comment

Lebih baru Lebih lama

Mengenai Saya

Foto saya
6ickzone
I've been deep in the world of cybersecurity, crypto, AI, and hacking for years. This blog is where I share my journey, tools, tips, and everything I learn along the way. But beyond code and exploits, there's also rhythm. I'm also exploring the digital soundscape — producing beats, fusing dark tech vibes with trap, drill, and EDM. Music is my second language, and it's where I channel the energy of the underground digital world. From my early days as a defacer to my current focus on ethical hacking and experimental music, I’m building 6ickzone as a hybrid space where hacking meets art. Why 6ickzone? 6ickzone is more than just a blog — it's a realm where hackers, beatmakers, and digital renegades gather. Whether you're here for the tools or the tunes, welcome to the zone.
Lihat profil lengkapku

Cari Blog Ini

About