šš¦¶Enumeration/Foothold
Writer is a Medium box from HTB and created by TheCyberGeek. This box features a website with a SQL login bypass and img_url
parameter exploit allowing us to execute code. Once on the box we find a postfix
and apt
exploit allowing us to get root.
Before I begin each machine I kick off a full portĀ nmap
Ā scan. This scan profile should normally not be used with theĀ -T5
Ā as you might miss/get incorrect information/results:
Reviewing the results I can see PortsĀ 22/80/445
Ā open. Starting withĀ SMB
Ā I useĀ enum4linux
Ā to pull some enumeration and directly access the share. I have no rights to the folders but I do find some accounts/users:
Next I navigate over to the website which is sitting onĀ Port 80
. I’ve recently been trying to useĀ ffuf
Ā more in my day to day but highlighted Feroxbuster as well:

Story Bank website sitting on Port 80.
OR
Running the directory scans shows anĀ administrativeĀ directory. Navigating to it shows a login page. I useĀ admin/password
Ā in the fields and capture the request in Burp Suite. I change the parameters to match for easier identification. I then copy the request and create aĀ req.txt
. I useĀ ffuf
Ā to fuzz the username/password fields for possible SQL injection or login bypass.
I get a hit:

Story Bank Dashboard after the SQL Login Bypass.
After logging into the environment I am presented with a dashboard. I can see an area to edit stories. After some trial and error I realize that if I intercept the request with Burp Suite I can also the imageĀ URL
Ā to execute the code added to the end of the image:
ā Attack Machine
I clickĀ Edit StoryĀ and clickĀ Browse. I upload the exploit.jpgĀ (created in the steps above) then browse toĀ HEREĀ to verify. Next, I upload a second image and intercept in Burp suite. Change ourĀ img_urlĀ request with:

Using the Edit Story to upload a malicious jpg on HTB Writer.
A few seconds later the shell pops. I loaded LinPEAS onto the box and notice:
/etc/postfix/disclaimer
Ā running every 5mins. I’ve previously run across a similar privesc regarding disclaimer. Reviewing the script I add in a reverse shell:
ā Attack Machine
I then create a basic send mail script based offĀ HEREĀ and upload them both to the server:
Pulling them both to the server in a folder calledĀ crx. Once pulled I run the send mail script alongside the disclaimer copy noting the task above happens frequently:
šÆ Victim Machine
On my attack machine I kick off a reverse shell after transferring the files:
ā Attack Machine
Once on the virtual machine I grab John’sĀ SSH
Ā key and log back into the box:
šÆ Victim Machine
šEscalation to Root
ā Attack Machine
I run LinPEAS again and noticeĀ apt
Ā running as root. I can also see that I can write to the file.:
GTFOBinsĀ confirms my hunch. I echo a one-liner bash reverse shell into the file and wait the shell.