In order to replicate the CTF environment, you must have XAMPP and SSH installed. You will also need a password configured for your root user. However, even if those conditions have been met, you will still need to do some configuration. The steps you should take (assuming you are running Linux) are outlined below:
-
Create a new user. This user will run the web server that hosts the webapp with RCE vulnerabilities. Let's call this user
developer. -
Give
developerownership of the/opt/lampp/htdocsfolder with this command:
sudo chown -R developer:developer /opt/lampp/htdocs
- Configure LAMPP to run as the
developeruser by opening/opt/lampp/etc/httpd.confand modifying the User directive:
User developer
Group developer
- Verify the command was successful:
ls -ld /opt/lampp/htdocs
You should see developer instead of root.
-
Download the webapp source code (it is just one file:
index.php) and place it directly inside the/opt/lampp/htdocsfolder. -
Run LAMPP with this command:
sudo /opt/lampp/lampp start
-
Navigate to
127.0.0.1to verify the server is working and you can view the webpage. -
Assuming you already have a password set for your root user, download the
TODO.txtfile from the repository and replace the placeholder with your actual root password. (This is how the user will instigate privilege escalation) -
Also download the
user.txtfile with the flag inside it. Both this and theTODO.txtfiles should be located in/home/developer/. -
Log into your root account and place the
root.txtfile in/rootdirectory. -
Run these commands to ensure
root.txtis only readable by therootuser.
sudo chown root:root /root/root.txt
sudo chmod 600 /root/root.txt
- Verify the command succeeded with:
ls -l /root/root.txt
The output should look something like:
-rw------- 1 root root 32 Month Day Timestamp root.txt
- The environment setup is now complete; you may begin the CTF by starting LAMPP with:
sudo /opt/lampp/lampp start.
Note: If you find yourself stuck or are simply curious to see the solution, you can view the write-up on my blog here.