Often, web applications do not employ very secure or robust token generation algorithms. An example is an application that generates CSRF tokens as follows (pseudocode): md5(username).
How can we tell if that is the case? We can register an account, look into the requests to identify a CSRF token, and then check if the MD5 hash of the username is equal to the CSRF token’s value.
Now that we know how the CSRF token for this action is generated let us see how we can attack other users through CSRF.
Find below the malicious page. Save it as press_start_2_win.html
For your malicious page to have MD5-hashing functionality, save the below as md5.min.js and place it in the directory where the malicious page resides.
We can serve the page and JavaScript code above from our attacking machine as follows.
Open a New Private Window, navigate to http://csrf.htb.net and log in to the application using the credentials below:
Email: crazygorilla983
Password: pisces
This account will play the role of the victim. As you can see, Ela Stienen’s profile is not public. Let us try to make it public through a CSRF attack.
While still logged in as Ela Stienen, open a new tab and visit the page you are serving from your attacking machine http://<VPN/TUN Adapter IP>:1337/press_start_2_win.html.
Now press “Start!“. You will notice that when Ela Stienen presses “Start,” her profile will become public!