Autonomous OODA-loop pentesting agent. Hermes brain, Kali + Playwright tools over MCP, ATT&CK as the Orient language.
Python ai-agentsautonomous-agentskali-linuxllm-agentsoffensive-securityooda-looppentestingplaywrightsecurity
feat: add local vulnerable PHP2Shell Docker lab (php 8.2.34)
irraza688e2932165
diff --git a/php2shell-lab/README.md b/php2shell-lab/README.mdnew file mode 100644index 0000000..302e2d4--- /dev/null+++ b/php2shell-lab/README.md@@ -0,0 +1,103 @@+# php2shell-lab — Lab Docker local y vulnerable (PHP2Shell)++Entorno de laboratorio **local**, **vulnerable** y **autorizado** para investigar la+vulnerabilidad PHP2Shell (**CVE-2026-109618 / CVE-2026-109619**) en un contexto de CTF+controlado. Replica (adaptado) el lab oficial del investigador `ikow/php2shell-poc/lab`.++> **Uso exclusivo en CTF local autorizado.** Todos los servicios escuchan únicamente en+> `127.0.0.1`, nunca se exponen a la red. No ejecutar escaneos ni exploits contra sistemas+> externos. Este lab sólo sirve para probar la explotación localmente de forma controlada.++## ¿Qué es el lab?++La vulnerabilidad vive en el handler `session.upload_progress` de PHP (habilitado por+defecto) combinado con el bailout OOM del allocator de memoria. Afecta a PHP desde la+versión 5.4.0 hasta la 8.5.11, y está **corregida** en 8.2.35 / 8.3.36 / 8.4.27 / 8.5.12.++Para que el lab sea **realmente vulnerable** se fija una versión afectada anterior al+parche. No se usan las etiquetas flotantes `php:8.2-fpm` / `php:8.2-apache` porque hoy ya+resuelven a la versión parcheada (8.2.35+).++## Versión de PHP corriendo (verificada)++Etiqueta fijada: **`php:8.2.34-fpm`** y **`php:8.2.34-apache`**.++Versión exacta confirmada con `docker exec php2shell-fpm php -v`:++```+PHP 8.2.34 (cli) (built: Oct 21 2026 00:37:31) (NTS)+```++`8.2.34 < 8.2.35` → **vulnerable**.++## Endpoints y puertos (todos en 127.0.0.1)++| Servicio | Contenedor | Binding | SAPI | Descripción |+|--------------|--------------------|---------------------------|-----------------|--------------------------------------|+| nginx → fpm | `php2shell-nginx` | `127.0.0.1:18080` → 80 | `fpm-fcgi` | nginx como front hacia php-fpm |+| apache | `php2shell-apache` | `127.0.0.1:18081` → 80 | `apache2handler`| Apache con mod_php |+| php-fpm | `php2shell-fpm` | `127.0.0.1:9000` → 9000 | `fpm-fcgi` | FastCGI php-fpm directo |++Comprobación rápida:++```bash+curl -s http://127.0.0.1:18080/index.php # nginx -> php-fpm+curl -s http://127.0.0.1:18081/index.php # apache mod_php+```++Salida esperada (versión < 8.2.35 y `upload_progress 1`):++```+PHP 8.2.34+SAPI fpm-fcgi+upload_progress 1+OK+```++## Configuración vulnerable++`session.upload_progress` está **activado** y la limpieza (`cleanup`) **desactivada**, lo+que permite que los datos de progreso de subida persistan en los ficheros de sesión:++- `session.upload_progress.enabled = On`+- `session.upload_progress.cleanup = Off`++Ver `php.ini` (FPM) y `php-apache.ini` (Apache mod_php). El servicio Apache usa además+`memory_limit = 32M` para exponer la superficie OOM necesaria para Chain D.++## Mapeo de cadenas de ataque a endpoints++| Cadena | Endpoint / fichero | Qué habilita |+|----------|-------------------------------------------------|---------------------------------------------------------------------|+| Chain A | `vuln.php?page=...` (vía :18080 / :18081) | LFI simulado (`include($_GET['page'])`) hacia el fichero de sesión |+| Chain C | `app/` (`.user.ini` → `php_serialize`) y `api/` (`.user.ini` → `php`) | Distintos `session.serialize_handler` por directorio |+| Chain D | Apache `:18081` (`memory_limit = 32M`) | Superficie OOM del allocator (bailout) con memoria reducida |++Ficheros de apoyo:++- `webroot/index.php` — informa versión, SAPI y estado de `upload_progress`.+- `webroot/nosession.php` — variante sin `session_start`.+- `webroot/vuln.php` — LFI simulado para Chain A.+- `webroot/app/.user.ini` → `session.serialize_handler = php_serialize` (Chain C).+- `webroot/app/upload.php` — copia de `nosession.php`.+- `webroot/api/.user.ini` → `session.serialize_handler = php` (Chain C).+- `webroot/api/endpoint.php` — copia de `nosession.php`.++## Arrancar y parar++```bash+# Arrancar (desde php2shell-lab/)+docker compose up -d++# Parar y eliminar contenedores + red+docker compose down+```++El `pull` inicial de las imágenes puede tardar; usa un timeout amplio la primera vez.++## Referencias++- Repo del PoC del investigador: `ikow/php2shell-poc` — https://github.com/ikow/php2shell-poc+- Plantillas Nuclei: `Ademking/php2shell-nuclei-templates` — https://github.com/Ademking/php2shell-nuclei-templates+- CVE-2026-109618+- CVE-2026-109619diff --git a/php2shell-lab/docker-compose.yml b/php2shell-lab/docker-compose.ymlnew file mode 100644index 0000000..3a6d666--- /dev/null+++ b/php2shell-lab/docker-compose.yml@@ -0,0 +1,33 @@+services:+ php:+ image: php:8.2.34-fpm+ container_name: php2shell-fpm+ volumes:+ - ./webroot:/var/www/html+ - ./php.ini:/usr/local/etc/php/php.ini+ ports:+ - "127.0.0.1:9000:9000"+ security_opt:+ - seccomp:unconfined+ privileged: true+ command: bash -c "mkdir -p /tmp/sessions && chmod 1777 /tmp/sessions && php-fpm"++ nginx:+ image: nginx:alpine+ container_name: php2shell-nginx+ volumes:+ - ./webroot:/var/www/html+ - ./nginx.conf:/etc/nginx/conf.d/default.conf+ ports:+ - "127.0.0.1:18080:80"+ depends_on:+ - php++ apache:+ image: php:8.2.34-apache+ container_name: php2shell-apache+ volumes:+ - ./webroot:/var/www/html+ - ./php-apache.ini:/usr/local/etc/php/php.ini+ ports:+ - "127.0.0.1:18081:80"diff --git a/php2shell-lab/nginx.conf b/php2shell-lab/nginx.confnew file mode 100644index 0000000..faf742c--- /dev/null+++ b/php2shell-lab/nginx.conf@@ -0,0 +1,14 @@+server {+ listen 80;+ root /var/www/html;+ index index.php;+ client_max_body_size 128m;+ location / { try_files $uri $uri/ /index.php?$query_string; }+ location ~ \.php$ {+ fastcgi_pass php:9000;+ fastcgi_index index.php;+ fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;+ include fastcgi_params;+ fastcgi_request_buffering off;+ }+}diff --git a/php2shell-lab/php-apache.ini b/php2shell-lab/php-apache.ininew file mode 100644index 0000000..76dd2d9--- /dev/null+++ b/php2shell-lab/php-apache.ini@@ -0,0 +1,10 @@+memory_limit = 32M+post_max_size = 256M+upload_max_filesize = 256M+max_input_vars = 100000+max_file_uploads = 100000+display_errors = On+error_reporting = E_ALL+session.upload_progress.enabled = On+session.upload_progress.cleanup = Off+session.save_path = /tmpdiff --git a/php2shell-lab/php.ini b/php2shell-lab/php.ininew file mode 100644index 0000000..b388ac7--- /dev/null+++ b/php2shell-lab/php.ini@@ -0,0 +1,18 @@+[Session]+session.save_handler = files+session.save_path = /tmp/sessions+session.use_strict_mode = 0+session.use_cookies = 1+session.use_only_cookies = 0+session.upload_progress.enabled = On+session.upload_progress.cleanup = Off+session.upload_progress.prefix = upload_progress_+session.upload_progress.name = PHP_SESSION_UPLOAD_PROGRESS+session.upload_progress.freq = 1%+session.upload_progress.min_freq = 0+[PHP]+display_errors = On+error_reporting = E_ALL+file_uploads = On+post_max_size = 128M+upload_max_filesize = 128Mdiff --git a/php2shell-lab/webroot/api/.user.ini b/php2shell-lab/webroot/api/.user.ininew file mode 100644index 0000000..67a04c5--- /dev/null+++ b/php2shell-lab/webroot/api/.user.ini@@ -0,0 +1 @@+session.serialize_handler = phpdiff --git a/php2shell-lab/webroot/api/endpoint.php b/php2shell-lab/webroot/api/endpoint.phpnew file mode 100644index 0000000..5a144fe--- /dev/null+++ b/php2shell-lab/webroot/api/endpoint.php@@ -0,0 +1,2 @@+<?php+echo "PHP " . PHP_VERSION . "\nno session_start\n";diff --git a/php2shell-lab/webroot/app/.user.ini b/php2shell-lab/webroot/app/.user.ininew file mode 100644index 0000000..17f4b72--- /dev/null+++ b/php2shell-lab/webroot/app/.user.ini@@ -0,0 +1 @@+session.serialize_handler = php_serializediff --git a/php2shell-lab/webroot/app/upload.php b/php2shell-lab/webroot/app/upload.phpnew file mode 100644index 0000000..5a144fe--- /dev/null+++ b/php2shell-lab/webroot/app/upload.php@@ -0,0 +1,2 @@+<?php+echo "PHP " . PHP_VERSION . "\nno session_start\n";diff --git a/php2shell-lab/webroot/index.php b/php2shell-lab/webroot/index.phpnew file mode 100644index 0000000..241f95f--- /dev/null+++ b/php2shell-lab/webroot/index.php@@ -0,0 +1,6 @@+<?php+session_start();+echo "PHP " . PHP_VERSION . "\n";+echo "SAPI " . php_sapi_name() . "\n";+echo "upload_progress " . ini_get('session.upload_progress.enabled') . "\n";+echo "OK\n";diff --git a/php2shell-lab/webroot/nosession.php b/php2shell-lab/webroot/nosession.phpnew file mode 100644index 0000000..5a144fe--- /dev/null+++ b/php2shell-lab/webroot/nosession.php@@ -0,0 +1,2 @@+<?php+echo "PHP " . PHP_VERSION . "\nno session_start\n";diff --git a/php2shell-lab/webroot/vuln.php b/php2shell-lab/webroot/vuln.phpnew file mode 100644index 0000000..7711d2b--- /dev/null+++ b/php2shell-lab/webroot/vuln.php@@ -0,0 +1,3 @@+<?php+$page = $_GET['page'] ?? 'home';+include($page);