• Zero-Day Wire
  • Posts
  • Break the Web (Week 5): Cross-Site Scripting (XSS)

Break the Web (Week 5): Cross-Site Scripting (XSS)

XSS Exploitation: Step-by-Step Tutorial with XSStrike, BeEF, Browser Hijacking & Payload Crafting

In partnership with

🎯 Week 5: Cross-Site Scripting (XSS)

Break the Web: Part 5 of 8

Welcome back to Offensive Tuesday.

Hey πŸ‘‹

Last week you injected SQL and commands directly into servers. You bypassed logins, dumped databases, and executed system commands. If you missed it, catch up here πŸ‘‰

  • Week 1: Recon & Attack Surface

  • Week 2: Authentication & Session Management

  • Week 3: Access Control & IDOR

  • Week 4: Injection (SQL & Command)

This week? We're hijacking browsers.

Here's what most people don't understand β€” the browser trusts the website completely. If you can inject JavaScript into a page, you own every user who visits it.

Their cookies? Yours.
Their keystrokes? Captured.
Their session? Hijacked.
Their bank account? One click away.

You're not attacking the server anymore. You're attacking everyone who uses it.

This is Cross-Site Scripting (XSS) β€” the vulnerability behind some of the biggest data breaches in history. MySpace worm that infected a million users in 24 hours? XSS. British Airways breach that stole 380,000 credit cards? XSS. Countless session hijackings and account takeovers? You guessed it.

Today you're learning how to turn innocent web pages into attack platforms.

Let's weaponize some JavaScript. ⚑

⚑Starting a business in 2026? Only AI is not enough…

The Future of Shopping? AI + Actual Humans.

AI has changed how consumers shop by speeding up research. But one thing hasn’t changed: shoppers still trust people more than AI.

Levanta’s new Affiliate 3.0 Consumer Report reveals a major shift in how shoppers blend AI tools with human influence. Consumers use AI to explore options, but when it comes time to buy, they still turn to creators, communities, and real experiences to validate their decisions.

The data shows:

  • Only 10% of shoppers buy through AI-recommended links

  • 87% discover products through creators, blogs, or communities they trust

  • Human sources like reviews and creators rank higher in trust than AI recommendations

The most effective brands are combining AI discovery with authentic human influence to drive measurable conversions.

Affiliate marketing isn’t being replaced by AI, it’s being amplified by it.

🧠 What is XSS?

XSS happens when an attacker injects malicious scripts into web pages viewed by other users.

Here's the flow:

  1. You find where the website displays user input (search box, comment, profile)

  2. You inject JavaScript code instead of normal text

  3. Website doesn't sanitize it

  4. Website serves your malicious script to other users

  5. Their browsers execute your code

  6. You steal their data, hijack sessions, or take over accounts

The key difference from SQL injection: You're not attacking the server. You're attacking the users.

Every victim's browser becomes your puppet.

🎭 The Three Types of XSS

Reflected XSS β€” Instant Attack

Your payload is in the URL. Victim clicks your link. Script executes immediately.

Think of it like this: You send someone a link to search for "laptops" but you sneak JavaScript into the search term. They click. The website reflects your search back to them. Your code runs in their browser.

Example URL:

http://shop.com/search?q=<script>alert('XSS')</script>

Real example: Victim gets an email saying "Check out these deals!" with a link. Link contains hidden JavaScript. They click. Session stolen.

Use case: Phishing emails, malicious links, social engineering attacks

Stored XSS β€” Time Bomb

Your payload gets saved in the database. Every user who views that page gets attacked automatically.

You post a comment with hidden JavaScript. The site stores it. Now everyone who reads that comment section executes your code. You don't need to send links anymore. The website does your work for you.

Real example: You leave a "product review" on an e-commerce site. Hidden in your review is code that steals cookies. Every shopper who reads reviews? Compromised.

Use case: Forum posts, user profiles, comment sections, reviews, guestbooks

Why it's the most dangerous: One injection = unlimited victims. Set it and forget it.

DOM-Based XSS β€” Client-Side Chaos

The vulnerability exists in JavaScript itself, not the server code.

The page's own JavaScript reads something (like the URL) and unsafely inserts it into the page. The server never sees your payload. Web Application Firewalls can't block it.

Real example: A single-page app reads the URL fragment (everything after the #) and displays it on the page without checking what's in it. You craft a malicious URL. Victim clicks. Their own browser executes your code.

Use case: Single-page apps, JavaScript-heavy sites, modern frameworks like React/Angular/Vue

πŸ”§ The XSS Attack Process

Step 1: Find Input Points

Look everywhere users can submit data:

βœ… Search boxes
βœ… Comment sections
βœ… Contact forms
βœ… URL parameters
βœ… User profiles (name, bio, location)
βœ… File upload names
βœ… HTTP headers (User-Agent, Referer)
βœ… Chat features
βœ… Review sections
βœ… Error messages βœ… Markdown editors

Your mantra: If it displays user input, test it.

Pro tip: The weirdest places often have the weakest protections. File upload filename? Test it. "Report a bug" form? Test it. Password reset error message? Test it.

Step 2: Test for Vulnerabilities

Start dead simple. Type this into every input field you find:

<script>alert('XSS')</script>

Does a popup appear? Congrats, you found XSS.

But modern sites usually block script tags. So you need alternatives.

Try these payloads instead (full list at PayloadsAllTheThings and PortSwigger's XSS cheat sheet):

  • Image tags with error events

  • SVG tags with onload events

  • Body tags with onload

  • Input tags with autofocus

The goal is simple: get JavaScript to execute. If you see alert() pop up, you've proven the vulnerability.

Pro tip: Use alert() for testing only. In real attacks, you're not showing popups β€” you're stealing cookies and sessions silently.

Step 3: Bypass Filters

Sites try to block XSS. Here's how attackers get around them:

Mix uppercase and lowercase β€” Filters looking for <script> might miss <ScRiPt>

Use encoding β€” Turn characters into HTML entities or URL encoding

Try different tags β€” If <script> is blocked, try <img>, <svg>, <iframe>, <body>, <input>

Use event handlers β€” onerror, onload, onfocus, onmouseover

Double encoding β€” Encode your payload twice

JavaScript protocol β€” javascript:alert(1) in href attributes

Template literals and backticks β€” Bypasses some WAFs

Don't memorize these. Use the cheat sheets: PayloadsAllTheThings bypass section and PortSwigger's filter evasion guide. There are literally thousands of bypass techniques documented.

The game is simple: keep trying variations until something works.

Step 4: Weaponize Your Payload

alert() proves it works. But real attackers aren't showing popups. They're doing this:

Cookie theft β€” Send the victim's cookies to your server (full payloads here)

Session hijacking β€” Steal their authentication tokens (examples here)

Keylogging β€” Record every keystroke on that page (payload examples)

Phishing β€” Inject a fake login form over the real page (techniques here)

Credential harvesting β€” Create a convincing "Your session expired, please log in again" prompt

BeEF framework β€” Hook the victim's browser for complete remote control (setup guide) - screenshots, keylogging, webcam access, network pivoting

Cryptocurrency miners β€” Use their CPU to mine coins

Defacement β€” Change the page content

Admin actions β€” If the victim is logged in as admin, perform admin actions silently

The scariest part? All of this happens invisibly. The victim sees a normal webpage. Behind the scenes, you're owning their session.

Check out PayloadsAllTheThings and PortSwigger's resources above for full working examples. Don't reinvent the wheel β€” use battle-tested payloads.

Step 5: Deliver the Attack

For Reflected XSS:

Craft your malicious URL. Shorten it with bit.ly so it doesn't look suspicious. Then:

  • Send via email ("Check out this cool feature!")

  • Post on Discord, Slack, Reddit

  • Send in SMS/WhatsApp messages

  • Post in forums with "Check this bug I found"

  • Use in phishing campaigns

Social engineering is key. Make people want to click.

For Stored XSS:

Inject once. Walk away. Every visitor gets attacked automatically.

Post your payload as:

  • A forum comment

  • A product review

  • A profile bio

  • A chat message

  • A support ticket

The website becomes your distribution network.

For DOM XSS:

Target JavaScript-heavy apps. Your payload never touches the server, so WAFs can't see it. Perfect for bypassing security.

🎯 Real-World XSS Hunting

Where XSS hides in 2025:

πŸ” Modern JavaScript frameworks β€” React, Vue, Angular apps with dangerous functions
πŸ” User-generated content platforms β€” Social networks, forums, review sites
πŸ” Search functionality β€” Query parameters reflected in results
πŸ” Error messages β€” "No results found for [your input here]"
πŸ” Rich text editors β€” Markdown, WYSIWYG editors
πŸ” Email clients β€” Webmail rendering HTML emails
πŸ” Admin panels β€” Lower security, higher privileges = bigger payout
πŸ” File upload features β€” Filename gets displayed without sanitization πŸ” URL shorteners β€” Original URL displayed on preview page πŸ” Translation features β€” Translated text rendered without encoding

Bug bounty pro tip: Look for XSS in features developers just launched. New code = less testing = more bugs. Check the changelog, then hunt those fresh endpoints.

πŸ›‘οΈ Why XSS is So Dangerous

Here's the brutal truth about XSS:

It bypasses basically everything:

❌ Same-Origin Policy? Doesn't matter. Your script runs in the victim's origin.
❌ HTTPS? Doesn't matter. The malicious script is served over the same secure connection.
❌ Strong passwords? Doesn't matter. You're stealing the session after they log in.
❌ 2FA? Doesn't matter. You hijack the authenticated session.
❌ CORS protections? Doesn't matter. You're already inside their origin.

XSS turns the website itself into your attack tool. The victim trusts the website. The website executes your code. Game over.

πŸ› οΈ Essential XSS Tools

Testing & Exploitation:

XSStrike β€” Automated XSS scanner with smart payload generation β€” Get it here

Burp Suite β€” Industry standard for manual XSS testing β€” Download

OWASP ZAP β€” Free alternative to Burp β€” Download

dalfox β€” Fast, powerful XSS scanner β€” Get it here

XSSer β€” Automatic XSS testing framework β€” Get it here

Browser Developer Tools β€” Built-in, inspect how the page handles your input

Payload Generation & Exploitation:

BeEF (Browser Exploitation Framework) β€” Hook browsers and control them remotely β€” Official site

XSS Polyglots β€” One payload that works in multiple contexts β€” Get them here

Payload Collections:

PayloadsAllTheThings - XSS Section β€” Massive collection of XSS payloads and bypasses β€” Browse here

PortSwigger XSS Cheat Sheet β€” Comprehensive payload reference with interactive examples β€” View here

XSS Payload List β€” Curated collection of working payloads β€” Get it here

Awesome XSS β€” Curated list of XSS resources β€” Check it out

πŸ“š Learning Resources

Interactive Labs:

PortSwigger XSS Labs β€” Free hands-on practice with progressive difficulty β€” Start here

OWASP WebGoat β€” Practice XSS in a safe environment β€” Try it

HackTheBox β€” Real vulnerable machines with XSS challenges β€” Join here

TryHackMe XSS Room β€” Guided XSS learning path β€” Start learning

Google XSS Game β€” Learn XSS by exploiting intentionally vulnerable pages β€” Play here

Deep Dives:

OWASP XSS Guide β€” Complete reference documentation β€” Read here

PortSwigger XSS Guide β€” Comprehensive tutorial series β€” Learn here

Excess XSS β€” In-depth XSS tutorial β€” Read it

The Tangled Web β€” Book by Michal Zalewski, Chapter on browser security

HackerOne XSS Reports β€” Learn from actual disclosed bugs β€” Browse reports

That's Week 5. ⚑

Tomorrow (Wednesday): How to defend against XSS and write secure frontend code.

Next Tuesday (Week 6): File Uploads & Remote Code Execution β€” we're uploading shells and taking over servers.

See you then.

Your Feedback Matters

Did You Enjoy This Week’s Offensive Tutorial?

Login or Subscribe to participate in polls.

P.S. Got questions? Reply to this email. I read everything.

Reply

or to participate.