root@sparrow:~/writeups$ cat flag-command.md
// writeups
Flag Command
31 May 2024
· 2 min read
A terminal-style web "game" keeps its logic in the frontend. The command list — including a secret one — travels in an API response you can read straight from DevTools.
Challenge overview
| Field | Value |
|---|
| Platform | Hack The Box · Challenge |
| Category | Web |
| Difficulty | Very Easy |
| State | Retired |
Attack map
[Web /] terminal-style game
│
▼
[DevTools ▸ Network] /api/options
│
▼
[JSON] secret command
│
▼
[FLAG]
Un "juego" web tipo terminal esconde su lógica en el frontend. La lista de comandos —incluido uno secreto— viaja en una respuesta de la API que se ve en las DevTools.
Ficha del challenge
| Campo | Valor |
|---|
| Plataforma | Hack The Box · Challenge |
| Categoría | Web |
| Dificultad | Very Easy |
| Estado | Retirado |
Mapa del ataque
[Web /] juego tipo terminal
│
▼
[DevTools ▸ Network] /api/options
│
▼
[JSON] comando secreto
│
▼
[FLAG]
1. Recon the application
The UI mimics a terminal with a limited command set (start, help…). It's not a real game — it's JavaScript deciding what's accepted.
help
> start clear audio restart info
2. Rule out command injection
Trying classic payloads confirms there's no arbitrary execution: only predefined commands are accepted, so the flaw is in the client logic, not the server.
$(whoami)
> You do realise its not a park...
The Network tab shows every request the page makes on load. That's where the endpoint feeding the game shows up.
# F12 ▸ Network ▸ recargar (F5)
GET /api/options
4. Read the API endpoint
The endpoint returns the full command JSON, including a secret key with the magic phrase and the flag.
curl -s http://TARGET/api/options
{
"commands": [ ... ],
"secret": [
"Blip-blop, in a pickle with a hiccup! Shmiggity-shmack",
"HTB{D3v3l0p3r_t00l5_4r3_b35t__t00l5_wh4t_d0_y0u_Th1nk??}"
]
}
5. Run the secret command
Blip-blop, in a pickle with a hiccup! Shmiggity-shmack
> HTB{D3v3l0p3r_t00l5_4r3_b35t__t00l5_wh4t_d0_y0u_Th1nk??}
Chain summary
| Phase | Component | Weakness | Impact |
|---|
| Recon | Frontend JS | Game logic client-side | Commands controlled by JS |
| Leak | /api/options | Sensitive data in API | Secret command + flag exposed |
Lessons learned
- The frontend is never a security boundary — anything that reaches the browser is visible.
- Don't ship sensitive data in API endpoints assuming "nobody will look".
- DevTools (Network/Sources) is the first stop in any web challenge.
1. Reconocer la aplicación
La interfaz simula una terminal con comandos limitados (start, help…). No es un juego real: es JavaScript controlando qué se acepta.
help
> start clear audio restart info
2. Descartar inyección de comandos
Probar payloads clásicos confirma que no hay ejecución arbitraria: solo se aceptan comandos predefinidos, así que el fallo está en la lógica cliente, no en el servidor.
$(whoami)
> You do realise its not a park...
La pestaña Network muestra todas las peticiones que hace la página al cargar. Ahí aparece un endpoint que alimenta al juego.
# F12 ▸ Network ▸ recargar (F5)
GET /api/options
4. Leer el endpoint de la API
El endpoint devuelve el JSON completo de comandos, incluyendo una clave secret con la frase mágica y la flag.
curl -s http://TARGET/api/options
{
"commands": [ ... ],
"secret": [
"Blip-blop, in a pickle with a hiccup! Shmiggity-shmack",
"HTB{D3v3l0p3r_t00l5_4r3_b35t__t00l5_wh4t_d0_y0u_Th1nk??}"
]
}
5. Ejecutar el comando secreto
Blip-blop, in a pickle with a hiccup! Shmiggity-shmack
> HTB{D3v3l0p3r_t00l5_4r3_b35t__t00l5_wh4t_d0_y0u_Th1nk??}
Resumen de la cadena
| Fase | Componente | Debilidad | Impacto |
|---|
| Recon | Frontend JS | Lógica de juego en cliente | Comandos controlados por JS |
| Fuga | /api/options | Datos sensibles en la API | Comando secreto + flag expuestos |
Lecciones aprendidas
- El frontend nunca es una frontera de seguridad: todo lo que llega al navegador es visible.
- No expongas datos sensibles en endpoints de API pensando que "nadie los mirará".
- Las DevTools (Network/Sources) son la primera parada en cualquier challenge web.