BeEF Browser Exploitation

Browser Exploitation Framework (BeEF)

BeEF comes bundled with Kali Linux. Iโ€™m going to assume you have access to a Kali Linux instance and if not I recommend setting it up by following my other article, โ€œEthical Hacking (Part 2): Introducing Kali Linuxโ€. You can also download it here on other Linux variants.

The location of BeEF in Kali Linux is, โ€œ/usr/share/beef-xssโ€.

We will need to configure BeEF before we are able to use it. Please open, โ€œ/usr/share/beef-xss/config.yamlโ€ which is a symbolic link back to โ€œ/etc/beef-xss/config.yamlโ€.

Please locate the โ€œcredentialsโ€ section of the configuration.

These are the credentials we will use to access the framework GUI. BeEF wonโ€™t start unless you change these. I recommend changing both the username and password to something non-standard and strong.

Please locate the โ€œhttpโ€ section of the configuration.

You need to set the host IP of your Kali Linux server where the hacked browser will connect back to. In my case Iโ€™m going to set the host to, โ€œ192.168.1.2โ€.

Now run BeEFโ€ฆ

The two important bits of information are:

The, โ€œHook URLโ€ is the Javascript you need to try and get your victim to run. You could look at something advanced like XSS but really the scary thing is any page you browse could just include this in the script tags to allow full access to your machine!

The, โ€œUI URLโ€ is the GUI for BeEF and where weโ€™ll be able to monitor and carry out the attack once an unsuspecting browser connects.

In order to demonstrate this Iโ€™m going to create a very basic HTML page called โ€œbeef.htmlโ€ to load the Javascript. This could be placed on a web server, put on a file server, emailed to someone etc. If someone opens this file they will be open for the attack. No warnings will be given, the browser wonโ€™t complain, and the virus scanner wonโ€™t pick it up :(

I saved the โ€œbeef.htmlโ€ on my desktop and double-clicked on it to open it.

As soon as I opened it I can see the BeEF console reported the new connection.

Letโ€™s open the โ€œUI URLโ€ and take a look.

Sign in with the credentials from, โ€œconfig.yamlโ€.

Firstly, just clicking on the host which connected shows a stack of information about the victim.

Please click on the, โ€œCommandsโ€ tab.

There is a huge amount of options in each of those sections but Iโ€™m just going to point out a few.

As you can see, many options!

Iโ€™ll demonstrate how a couple of them work.

Browser, Hooked Domain, Create Alert Dialog

I will โ€œExecuteโ€ and send the โ€œAlert textโ€ of โ€œBeEF Alert Dialogโ€ to my victim browser.

Social Engineering, Pretty Theft

Iโ€™m going to pop up a window that looks like Facebook login page in my victim browser.

Iโ€™m going to add some fake credentials and see what happens.

As you can see โ€œ[email protected]โ€ and โ€œsecretpwโ€ was recorded!

There are literally loads of nasty options there from fake session timeouts on many popular services, fake Flash update modals to upload exploits, accessing webcams, taking screenshots, playing sounds, creating users, and much more.

Protecting against BeEF

There are a few browser extensions which help prevent against BeEF attacks. They arenโ€™t really that pleasant to use as it involves โ€œwhitelistingโ€ safe Javascript to run on sites.

Chrome

Firefox

Both of these arenโ€™t all that great and will cause problems with normal browsing. If anyone knows any good ways to prevent against BeEF attacks please leave a comment :)

Last updated