This repository was made for an academic project in the context of a engineering degree in specialization Cloud Computing & Cybersecurity at Pôle Léonard de Vinci.
The goal was to simulate web vulnerabilities, exploit them and fix them.
- Install XAMPP for Windows.
- Clone this repository in the
htdocsfolder of XAMPP. - Import the database in
assets/data.zipinmysql/dataof your XAMPP folder (the files inside the zip should be inmysql/data/and not likemysql/data/data/). - Add in httpd.conf (in
Configof Apache in XAMPP) the following at the end:
<Directory "PATH_TO_XAMP/htdocs/devinci-cracks">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted
</Directory>
Alias /devinci PATH_TO_XAMP/htdocs/devinci-cracks
- Start Apache and MySQL in XAMPP.
We go on the XSS tab and click on "Go to unsecure" to go on the vulnerable version of the website, then in the form type <scipt>alert("XSS attack!")</script> and click on "Send" to see the alert pop up.
This attack is hard to simulate because it requires either direct access to the target computer or if the attack is done remotely through user side script, we would need to host the server online.
For the physical access, the way to secure this is to prevent session fixation by changing the session id after the user logs in. This way, if the attacker tries to use the session id he got before the user logged in, it will be invalid.
For the remote access, we strengthen the validation logic for the session id. In secure mode, we generate a random token at login and store it both in the session and in a HttpOnly cookie (Https would also be a way to prevent this attack but it is not implemented in this project). Moreover, we add another layer of security by checking the user agent and IP of the request to make sure it is the same as the one that logged in. If it is not, we invalidate the session.
We connect with the following, hardcoded credentials: admin:password and we get a session id. We can copy this session_id and change the action=secure to action=hijack_page&session_id=SESSION_ID_HERE to get access to page that should belong to the admin.
🔧 Example on the same browser on unsecure mode
- We login with admin:password and get the session_id
704dr47i820bmo7a2u3856374a.- We then change the URL from
https://localhost/devinci-cracks/routeur.php?controller=hijacking&action=secure&secure=truetohttps://localhost/devinci-cracks/routeur.php?controller=hijacking&action=hijack_page&secure=true&session_id=704dr47i820bmo7a2u3856374aand we get access to the admin page.
🔧 Example on two browsers on unsecure mode
- We open two browsers, browser A (Edge) and browser B (Firefox).
- We login with admin:password on browser A and get the session_id
704dr47i820bmo7a2u3856374a.- We then change the URL from
https://localhost/devinci-cracks/routeur.php?controller=hijacking&action=secure&secure=falsetohttps://localhost/devinci-cracks/routeur.php?controller=hijacking&action=hijack_page&secure=false&session_id=704dr47i820bmo7a2u3856374aon browser B and we get access to the admin page.NOTE: in secure mode, it wouldn't work because the session_id would be different and thus invalid.