writeup
HackTheBox
SolidState
medium
OSCP
As we can see we have a Apache James 2.3.2 Server that is a Mail Server so let's look if there is some vulnerability for this version.
After looking in exploit-db I found a RCE authenticated here. If we look more in the code we see we can change the payload so I putted the netcat reverse shell , check the following code:
Reading the exploit we see the exploit use SMTP with the adduser function asusuming the credentials are the default credentials root:root, after that we see we have to login into the ssh before receive a shell so ti's time to enumerate the Server knowing the default credentials.
Using telnet we can connect to the 4555 port using the default password root:root and we can make changes on it.
Using HELP command we can see which commands we can use:
Let's start enumerating users:
I ran the exploit before login in so i can see the payload of the exploit.
We want to access to the mails of these accounts so change the password of each account to be able to connect from the pop with credentials.
After changing the password it's time to enumerate the emails for looking interesting emails.
We can understand how to interact with POP using telnet with this guide.
So let's login in the users, i logued in mindy that has some emails with interesting data.
Loged in we can list the emails with the LIST command
Looking the second email using the RETR [number] command to retrieve the email we see some credentials:
Username: mindy
Pass: P@55W0rd1!2@
Wow! We have ssh credentials, with that we can make work the exploit so it's time to start the explotation!
After executed the exploit we receive this response:
So let'ts start a netcat listener:
Login into the ssh using the credentials:
Receive a shell and upgrade it using python3:
Looking into the opt directories I found a file that is writable by me and is property of root:
With this it's time to privesc!
Needless to say, we could already read the home flag.
After knowing we can edit this file add this line to the python script to send a root shell to a netcat listner that we started because it' s probable that a root cronjob is running this script:
And add it as we see in the next image
And after wait a few seconds:
We have root shell!!
:bird:Twitter
:desktop_computer: Github
:ballot_box_with_check: TryHackMe
:green_book:HackTheBox