Vending Machine

Challenge Overview

Upon accessing the challenge, we’re greeted by a straightforward page featuring an image of a vending machine and a text input field.

My first instinct was to examine the page source, where I discovered a JavaScript file named script.js.

The function sendProduct particularly stood out, as it sends a request to drop-item.php with the user input as a parameter. After testing various inputs, I noticed it only accepted specific products (chips, soda, candy, juice) and filtered out most special characters and spaces. However,

Finding a Way In

When I attempted certain shell commands, such as ls, the application returned a message indicating it was “not allowed.”

I tried different commands that list directory contents. When I tested the dir command, it unexpectedly worked, revealing the directory contents. Among the files listed was one called entrypoint.sh

Upon inspecting entrypoint.sh, I noticed it reads the flag from an environment variable named FLAG and stores it in a file located at /home/apache/flag with permissions set to allow reading.

To retrieve the value, I used printenv to list all environment variables. Sure enough, this revealed the hidden flag at the end.

Last updated

Was this helpful?