HackTheBox - Postman 📮✉️
Quick Summary
→ This easy machine is very fit to all beginners to learn the basic of Penetration Testing. The machine have a vulnerable software – Redis
.
Redis is unprotected without a password set up, and so forth. The simplest thing you can do in such a case, is to write random file such as SSH keys which i’ll use to get in into the machine. After getting the shell, there’s SSH key for user Matt. The machine is very straightforward to the root after you get the credentials of the user and use it for another vulnerability – CVE Webmin 1.910
.
Penetration Testing Methodologies
Network Scanning
→ Nmap scan
→ discover open ports and what services are running
Enumeration
→ Browsing the HTTP Service on different ports
→ Bruteforce the Web page directories
→ Check the software vulnerabilities
Post - Exploitation
→ Check if we can inject or put some file inside in the Redis
→ The goal is to transfer SSH keys
→ Get in into redis shell
Exploitation
→ Find some interesting things using
LinEnum.sh
that can use for Exploitation→ Get the backup SSH key of a user
→ Use the credentials for
CVE Webmin 1.910
→ Get the root shell
Network Scanning
Walkthrough
→ First, I run the Nmap to scan the target and get information about the various services that are running on the target machine. I use
- -sV ⇒ Probe open ports to determine service/version info
- -sC ⇒ equivalent to —script=default
- -T 0-5 ⇒ Set timing template - higher is faster (less accurate)
- -p- ⇒ Scan all 65535 ports
- -oN ⇒ to save our scan results to a text file
# bash |
Nmap results
So there’s port open.
- 22 ⇒ running on OpenSSH 7.6p1
- 80 ⇒ running on Apache/2.24.49
- 6379 ⇒ running on Redis key-value version 4.0.9
- 10000 ⇒ running on MiniServ 1.910 (Webmin httpd)
Enumeration
I visited the web page in port 80 and there’s nothing interesting stuffs here except the Postman@htb
so added it into my /etc/hosts/
# bash |
Scan the Web directories
So, since I don’t have any clue what is on the Web page, I use dirsearch Web path scanner
to find some stuffs with the following command.
# bash |
So I have this following directories, everything is a normal web directories except on the /upload/
directory which caught my attention.
# bash |
Going to the /upload/
directory we will see a lot of image there. I tried to look fo the interesting image’ but I realize that this one is a rabbit hole so moved on and go the next phase.
Upload page
Webmin 1.910
Next is to visit the Port 10000
which holding an HTTP
service – Miniserv 1.910 (Webmin httpd)
I search the webmin
version that runs on the machine to look if there’s an existing exploit and there is.
Webmin Package Updates Remote Code Execution.
→ Description: This module exploits an arbitrary command execution vulnerability in Webmin 1.910 and lower versions. Any user authorized to the “Package Updates” module can execute arbitrary commands with root privileges.
Since I don’t have any credentials that will use on that exploits, i will leave this for a while and moved on to the next phase of hunting.
Post Exploitation
Next is to try Redis that appear on my nmap scan.
→ Redis is an open source (BSD licensed), in-memory data structure store, used as a database, cache and message broker.
I used the redis-tools package to communicate to the service of Redis. The existing vulnerability in version 4.0.9, you can interact redis without username and password.
So, to start let’s check if I can access the instance, which is a prerequisite:
Communicate with telnet
Works, Redis
it is unprotected without a password set up.
Next is to try the redis-cli
to look if i’ll got something.
# bash |
By using get s-key
command inside redis
it shows that there’s an existing ssh key that use for authentication. As a redis user shell I can write something in the database to a file with SAVE
command. So I was thinking if I can put mine to get in.
Inject SSH Keys
Since the Redis
is not protected. I will try to write something into ~/.ssh/authorized_keys in order to gain access to shell. So i will generate my SSH Key
first and save into my postman directory.
OPENSSH Key
will not valid. To get this work I’ll need RSA PRIVATE Key
using this line I can push my ssh-key into private key.
# bash |
Generated SSH Key
Now I’ve a key. My goal is to put it into the Redis server memory, and later to transfer it into a file, in a way that the resulting authorized_keys file is still a valid one.
So’ by following this method I will now put my generated ssh-key.
Now Let’s now put my SSH Key into the Redis
.
Using redis-cli
I can check, set a directory for redis and save.
I’ve successfully save my SSH key. Now I’ll try to login with ssh.
# bash |
It works! I’ve got now the initial shell.
Exploitation
Recon
By doing some Recon
i’ll use LinEnum.sh – Scripted Local Linux Enumeration & Privilege Escalation Checks.
It will help to find weaknesses and save my time to do the Privilege Escalation, I’ll uploaded it into /tmp/
directories of redis and execute it, so:
At first it will show the system information of Postman machine.
Shell user
I see the user Matt
and also my shell user as Redis.
Backup private SSH Key
Going deep of recon, there’s a file that caught my attention. Is a backup SSH key of some user. Base on the info that show’ it is owned by user Matt
Going to the /opt/
directory, I’ll try to transfer id_rsa.bak
into my machine but it seems not working, so I used cat
to view the content of the file.
Cracking the HASH
I copy the content of id_rsa.bak
into my machine and I use ssh2john to convert and crack it with John The Ripper
Cracking this using John The Ripper.
Just only 14 seconds. I’ve got now the password of Matt
# bash |
Login as Matt
I may now able to login as Matt
and get the user.txt
CVE Webmin 1.910
In the early stage of my Penetration Testing to this machine’ there’s an existing vulnerability – CVE Webmin 1.910
that need credentials. I’ll use metasploit to do the exploitation and pick the webmin_packageup_rce
I will use the credentails for Matt and let’s see what will happen ;)
# metasploit |
base on the options it requires – PASSWORD
, RPORT is on default 10000
, RHOSTS which is the victim IP (Postman)
, SSL (will set to true)
, and USERNAME
so:
# metasploit |
It works! And to upgrade my shell i use import pty
using python
:
# python |
Root
Very straightforward – Rooted! Now i can get the root.txt
# bash |
If you liked my writeup please leave a respect on my Profile
Referrences: