Bucket
Gaining Access
Nmap scan:
$ nmap -p- --min-rate 4000 10.129.65.220
Starting Nmap 7.93 ( https://nmap.org ) at 2023-08-25 21:28 +08
Nmap scan report for 10.129.65.220
Host is up (0.0070s latency).
Not shown: 65533 closed tcp ports (conn-refused)
PORT STATE SERVICE
22/tcp open ssh
80/tcp open httpDid a detailed scan as well:
$ nmap -p 80 -sC -sV --min-rate 4000 10.129.65.220
Starting Nmap 7.93 ( https://nmap.org ) at 2023-08-25 21:29 +08
Nmap scan report for 10.129.65.220
Host is up (0.0065s latency).
PORT STATE SERVICE VERSION
80/tcp open http Apache httpd 2.4.41
|_http-server-header: Apache/2.4.41 (Ubuntu)
|_http-title: Did not follow redirect to http://bucket.htb/
Service Info: Host: 127.0.1.1We can add bucket.htb to our /etc/hosts file to visit the web application.
Web Enum -> S3 Bucket Shell Upload
The website was looked to be a custom platform:

When I looked through the page source, I could see that there was a subdomain present:

It seems that this uses the AWS S3 Bucket to store images on the website. When we add the subdomain to the /etc/hosts file, we can see that images are loaded:

S3 Bucket is a cloud storage provider for objects, and it too can have misconfigurations. We only know that the bucket for the web application is called adserver. However, it's unlikely this bucket is actually publicly listed (at least I don't think so).
To enumerate this, we can use the --endpoint-url flag with aws to specify where we send the requests.
It seems that we need credentials. Based on Hacktricks Cloud, it is possible for unauthenticated access with null credentials.
Great! We now have access to the files within the S3 Bucket instance. We can try to write files to the instance, and find that it works:
Using this, we can try to write a shell of some sorts. The first thing that came to mind was PHP, since this wasn't a wasn't an IIS server.
This worked! Now we can easily gain a reverse shell:

Privilege Escalation
Project Files -> DynamoDB SSH Creds
We cannot read the user flag yet. Within the /var/www file, there is another bucket-app file:
There's a + at the end of it, meaning that there are extended privileges to this file. We can enumerate it using getfacl:
roy can read this. The user had a few files within their directory:
The db.php file included some code for the DynamoDB instance:
Now that we know this is running, we can enumerate it from our machine that already has aws configure configured.
The database also allows for unauthenticated access. We can read the stuff within this table:
It seems that we have some credentials. The third one worked, and I could su to roy:

Bucket-App PD4ML LFI -> Root SSH Key
Now that we are roy, we can access the bucket-app file:
The index.php had some code in it:
This uses the DynamoDB's alert table, and it takes some data from there that is titled Ransomware and uses pd4ml_demo.jar to convert the HTML into a PDF. Searching for exploits for the pd4ml.jar program spoiled the box a bit:

Anyways, reading the documentation for it provided me with the <attachment> tags.
We could potentially use this for an LFI to read the private SSH key of root. First, we need to find out where this app is running on. Reading the Apache configuration files gave me just that:
We need to forward port 8000 to our machine. I used chisel, but you can use ssh too since we have the credentials of roy. The application is being run as root as well, confirming that if we can exploit LFI, we can read every file in the machine.
Next, we need to create a new table within the DynamoDB instance with a title and data column. Afterwards, we need to insert 2 key pair values for it, with title being set to Ransomware, and the data field being set to our payload:
Afterwards, based on the index.php code, we need to send a POST request with action=get_alerts to run our payload:
We can then download the result.pdf file back to our machine via base64 or scp. When viewed, this would give us the SSH key we need!

Using this, we can ssh into the box:

Rooted!
Last updated