Hacking Devel (hackthebox)
This is how I hacked the Devel machine...
The initial nmap scan showed an FTP service was listening on port 21 and it was set up to allow anonymous connections. There was also a Microsoft IIS web server on port 80.
The anonymous access to FTP seemed like a good place to start. I had to use the -p flag to force the passive mode as the connection did not work for me without it. I used these credentials anonymous:anonymous
After listing the contents of the directory, I set FTP to use binary so I could try transferring binary files. I started by using the GET command to download the welcome.png file to my machine. This worked. I then tried to delete the welcome.png file from the remote machine, but did not have the rights to do so. I therefore renamed the downloaded copy of welcome.png to test.png and then used the PUT command to try to upload it to the remote machine. When I checked again I could see that this had been successful, so I now knew that I had read / write access to the remote machine.
This meant that I would be able to upload malware to the remote machine, but what good would that do if I had no way to execute it? It seemed to me, however, that I had access to a web root directory because of the name of the file welcome.png and the IIS web server on port 80. I therefore had a look at the web page being served and found it to be a default IIS page. I checked the source code and saw that the welcome.png file was indeed being served. This meant that I would be able to upload a reverse shell to the same folder using anonymous FTP and then navigate to it using a browser in order to execute it!
Next, I used msfvenom to create a reverse meterpreter shell using the aspx file type. I used this file type because Microsoft IIS uses it. I then uploaded the reverse_shell.aspx file to the remote machine using the anonymous FTP connection along with the PUT command.
Next, I fired up msfconsole and opened a listener using the exploit/multi/handler module. I then set the payload, lhost and lport.
With the listener running, I requested the reverse_shell.aspx resource which I had uploaded to the remote machine.
I now needed to find the user and root flags, so I used the tree command to quickly look through the directories from C:\Users down. I was then able to easily find the flags and use type to see them.
Finally, I decided to clean things up by deleting the two files I had uploaded to the webroot. I used the tree command again to find them quickly. This time, I searched from C:\ and found them in C:\inetpub\wwwroot I therefore deleted them from that directory to clean up and finish the box.
Thanks to ch4p for creating this box, and thank you for reading my write up of it.