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:
22/tcp open OpenSSH 8.2p1
80/tcp open HTTP redirect to http://bucket.htb/

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.
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.
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
roy
n2vM-<_K_Q:.Aa2
Extracted from DynamoDB
SSH User
👤 Users wordlist
🔑 Password wordlist
Subdomains / Hosts
s3.bucket.htb
10.10.10.212
Host the main application.
AWS S3
Host Discovered
Bucket
10.10.10.212
Scans
Scripts / Automations
Flag Discovered
User
10.10.10.212
roy
Extracted from Dynamodb
<SNIF>
Root
10.10.10.212
root
Abusing Local Application
<SNIF>
Last updated