When a browser gets hooked by BeEF, by default it only stays hooked as long as it is on the page that infected it. If the user navigates away from that page, it will no longer be hooked to our BeEF console. In this recipe, we show how can create persistence with BeEF even if a user navigates away from the infecting page.
Creating a persistent connection with BeEF
Getting ready
BeEF comes preinstalled on Kali Linux. In the examples provided, an instance of Metasploitable2 is used to demonstrate hooking a browser via XSS. For more information on how to set up systems in a local lab environment, refer to the Installing Metasploitable2 and Installing Windows Server recipes in Chapter 1, Getting Started. Additionally, this section will require a script to be written to...