Dynstr

Credentials

Untitled Database

Enumeration

Nmap scan

# Nmap 7.91 scan initiated Tue Jul 13 06:10:11 2021 as: nmap -p22,53,80 -sV -sC -oA nmap/detailed 10.10.10.244
Nmap scan report for 10.10.10.244
Host is up (0.043s 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 at Tue Jul 13 06:10:27 2021 -- 1 IP address (1 host up) scanned in 15.88 seconds

WebServer

On website was some dns records and shared credentials as well as domain from e-mail address.

Fuzzing directories

And endpoint /nic/update returned badauth when accessed

Remote Code Execution

Proof of Concept

Error message showing that nsupdate failed nsupdate is shell utility that could be used to update dynamic DNS records. For this case it is possible to inject shell commands.

This allowed to execute ping command to my local machine.

Exploit

This code snippet automate some of the process with login and encoding the payload.

With this reverse shell was spawned.

Privilege Escalation

Enumeration

User bindmgr can only connect if hi is connecting from domain *.infra.dyna.htb

In addition linpeas.sh found possible private ssh keys

Inside strace-C62796521.txt is indeed private key

And file command-output-C62796521.txt suggest that this is bindmgr key.

Adding new DNS record to match key requirements

Inside the file /var/www/html/nic/update was adding and deleting the records this was used as example.

Inside the /etc/bind directory was file named infra.key

Command

First is needed to add main A record as for every PTR record need A record. The A record point Domain Name/Hostname to IP the PTR record is opposite it points IP to Domain Name/Hostname

This allowed to login with obtained private key as bindmgr user

bindmgr

User bindmgr can run /usr/local/bin/bindmgr.sh as root without password

Source of bindmgr.sh

The vulnerable code is cp .version * /etc/bind/named.bindmgr/ and this can be used to inject commands for example additional flags for the cp command Commands

Last updated