Breathtaking View

Description

Check out my new website showcasing a breathtaking view—let's hope no one can 'manipulate' it!

Source

Dockerfile

FROM openjdk:8-jdk-slim

# Install Maven
RUN apt-get update && apt-get install -y maven && rm -rf /var/lib/apt/lists/*

# Copy the entire project into the container
COPY . /app

# Set the working directory
WORKDIR /app

# Compile the project
RUN mvn clean package

# Copy the compiled JAR file to the final location
RUN cp target/breathtaking_view-0.0.1-SNAPSHOT.jar /app/breathtaking_view-0.0.1-SNAPSHOT.jar

# Handle the flag
COPY flag.txt /
RUN FLAG_NAME=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 12) && cp /flag.txt "/flag_${FLAG_NAME}_.txt" && rm /flag.txt

# Set the command to run the application
CMD ["java", "-jar", "breathtaking_view-0.0.1-SNAPSHOT.jar"]

# Expose the port the application runs on
EXPOSE 8081

application.properties

main/java/com/hackthebox/breathtaking_view/Repositories/UserRepository.java

main/java/com/hackthebox/breathtaking_view/Models/Users.java

main/java/com/hackthebox/breathtaking_view/Controllers/IndexController.java

main/java/com/hackthebox/breathtaking_view/Controllers/AccountController.java

Solution

Breathtaking_View.png

Sign up.

Creds: test02:test02

Breathtaking_View-1.png

URL changed to: http://83.136.255.40:33805/?lang=frarrow-up-right

Breathtaking_View-2.png

IndexController does all the page including and stuff. Via parameter injection it receives get parameter lang.

https://0xn3va.gitbook.io/cheat-sheets/framework/spring/view-manipulationarrow-up-right

This exploit uses expression preprocessingarrow-up-right. In order for the expression to be executed by the Thymeleaf, no matter what prefixes or suffixes are, it is necessary to surround it with __${ and }__::.x.

SSTI is possible:

Breathtaking_View-3.png

https://exploit-notes.hdks.org/exploit/web/framework/java/spring-pentesting/arrow-up-righthttps://www.pwny.cc/web-attacks/server-side-template-injection-ssti#expression-language-elarrow-up-right

To make interaction easier I used a script:

After too many trials and errors I gave up on RCE (command -> read output) and switched to getting a reverse shell.

circle-check

Post Flag

Garbage Dump

Mostly useless, but leaving it here. exec doesn't allow redirections and stuff btw as string AFAIK.

Challenge solver.py by Author

solver.py from the challenge 💀

With my script:

Overkill

Create a Java file which downloads the static ncat binary.

Convert to Base64, upload to remote via echo and base64.

Go into /tmp, compile java code, run java code and make it executable

Note: Binary is ~2.8mb in size, download may take few seconds.

Finally run the ncat to get a reverse shell:

Uploading ncat unlocks new features of data transfer.

Last updated