HTB Magic Walkthrough
Aug 31, 2020 | nanobyte
Last updated
Aug 31, 2020 | nanobyte
Last updated
Aug 31, 2020 | nanobyte
I began with some simple enumeration scans:
I was able to identify SQL Injection on a login page, at http://10.10.10.185/login.php, using the following in the username and password fields:
I tried to upload a PHP reverse shell, but got an error back asking What are you trying to do here!?
so obviously it is blocked. By changing .php to .jpg resulted in the same error, so moved on. I downloaded an image from the internet, named it index.jpeg and used exfiltool to make a malicious image file:
Once I uploaded, I used BURP to intercept the image file, and sent to repeater. Once in repeater, I changed the filename to index.php.jpeg and sent the POST forward:
Once the malicious image was uploaded, I went back to the home page that was full of images, and I found that images were uploaded to /images/uploads
. With this, I went to my image at 10.10.10.186/images/uploads/index.php.jpeg
and could then run commands:
Then, I got to work on a reverse shell! There were many shells that would not connect back. Eventually, I found python3 in /usr/bin
and used a python reverse shell using my web shell:
And I owned user:
While enumerating for root, I found that the sysinfo
binary had SUID set:
And now that we have our path set, let’s make the malicious binary. When sysinfo runs, it calls lshw to look at the hardware on the system. Make a malicious lshw file:
Then once sysinfo is run, you will have root!
And I got a reverse shell back:
I then began enumerating the /var/www/Magic directory
, working my way down. Eventually I came across a bk.sql
file, that had hardcoded credentials:
It did not work for root, but there is another user on the system, theseus
. I was able to log right in as that user:
Looking on the internet, there are a lot of MagniComp vulnerabilities that appeared for this binary. Ultimately, this was a combination of two attacks to get root. First, was a PATH injection. I had to set a path, in this case /tmp
, into the $PATH
variable for a malicious binary to run: