This Lab is Optional
- Highly recommended, but optional!
For this lab you’ll need:
- A Ubuntu machine running a basic LAMP stack. (We won’t use the MySQL server, but the install is included in the line below.)
- A Kali Linux Machine
Note: Earlier in the course I said things would eventually go rodeo! (This is one of those labs. Stick with this one and take your time!)
The Ubuntu machine will be our webserver. Run the following to spin up a basic LAMP stack
apt install apache2 -y
apt install php mysql-server libapache2-mod-php php-mysql -y
systemctl restart apache2
What is CSRF and CSRF Protection?
Cross Site Request Forgery (CSRF)
Simply Put: CSRF can be written into web applications to prevent unauthorized 3rd parties from hijacking sessions or performing brute force attacks through the use of simple brute force programs like Hydra, or crackmapexec.
In this lab we will:
- Build a simple PHP application that allows the user to enter credentials and log in.
- We’ll use Hydra (Key Sec+ Concept/Application) to brute force the credentials as if we were an attacker.
- We’ll implement CSRF protection.
- We’ll write a Python program to bypass the CSRF protection because Hydra will no longer work.
Create a login.php page so that:
- This page will be a form that asks the user to type in a username and password.
- It will send the username and password via a POST request to action.php.
Create an action.php page that validates the value of username/password.