Bucket

Detailed Walkthrough

Initial Access

Upon establishing a connection to the VPN, the tester initiated the assessment by performing a service enumeration. This process revealed the following open ports:

Additionally, by looking the website source code, it was discovered s3.bucket.htb subdomain associated with the host indicating the presence of AWS implemented on the server.

Utilizing this information, the tester proceeded to use awscli to verify the scope and permissions of the S3 bucket. It was determined that the adserver bucket was completely publicly accessible with write permissions and was also hosting the files for the http://bucket.htb/ application.

To compromise the server, the tester crafted a PHP shell and uploaded it to the bucket, which was subsequently activated by accessing http://bucket.htb/shell.php, successfully compromising the server.

Lateral Movement

After gaining an initial foothold as www-data, the tester discovered /home/roy/project/db.php, which contained the DynamoDB client configuration pointing at a local endpoint (http://localhost:4566). This revealed a new internal service to enumerate.

Using the AWS CLI against the local endpoint (after configuring temporary fake credentials), the tester listed tables and scanned the users table, recovering several account records and password values.

One of the recovered credentials corresponded to the roy user, enabling direct lateral movement into that account.

Privilege escalation

Once authenticated as roy user. it was identified an internal application running on 8000 port.

The tester set up Local Port Forwarding via SSH to redirect the traffic from the tester's machine to the target machine using port 8000.

Further investigation uncovered the internal application source code located at /var/www/bucket-app/index.php, which contains a remote command execution vulnerability due to the utilization of the passthru PHP function.

The application require a POST request to http://localhost:8080 with the parameter action=get_alerts, which is triggered by pd4ml_demo.jar that is passed to passthru for execution.

PD4ML is a Java-based tool designed to convert HTML and CSS content into PDF documents. It includes a useful tag known as pd4ml:attachment , which allows for the inclusion of an arbitrary document or binary file as an attachment in the resulting PDF.

On the other hand, a DynamoDB table named alerts must exist with the following columns to facilitate the exploitation:

  • title

  • data

In order to fulfill the requirements, the tester created the table along with the values necessary to attach the root's SSH keys into the resulted pdf.

Finally, the tester triggered the vulnerability and successfully downloaded the PDF, which led to the attachment of the root SSH keys, compromising the entire server as root user.

Credentials

Username
Password
Methods
Scope
Notes

roy

n2vM-<_K_Q:.Aa2

Extracted from DynamoDB

SSH User

👤 Users wordlist

🔑 Password wordlist

Subdomains / Hosts

Subdomain / Host
Host
Description
Notes

s3.bucket.htb

10.10.10.212

Host the main application.

AWS S3

Host Discovered

Name
IP
Domain
Low Access
High Access
OS

Bucket

10.10.10.212

Windows

Scans

Scripts / Automations

Flag Discovered

Flag #
Host
Flag location
Method used
Value

User

10.10.10.212

roy

Extracted from Dynamodb

<SNIF>

Root

10.10.10.212

root

Abusing Local Application

<SNIF>

Last updated