Reverse Engineering / Authorized Penetration Testing / Security Research Skill Router Pack AI-powered routing + On-demand toolchain bootstrapping + Self-evolving knowledge base Supports Claude Code, Kiro, Cursor, Cline, and other AI coding clients 逆向/渗透/安全技能路由包 - AI 自动路由 + 按需自举工具链 + 自动进化经验库 | 支持 Claude Code / Kiro / Cursor / Cline 等代码 AI 客户端
Shell
test: enforce local pwntools probe environment
zhaoxuya520189f7c22d820
diff --git a/kali/scripts/test-pwntools-discovery.sh b/kali/scripts/test-pwntools-discovery.shindex fe42d15..cfa275d 100755--- a/kali/scripts/test-pwntools-discovery.sh+++ b/kali/scripts/test-pwntools-discovery.sh@@ -8,6 +8,7 @@ DISCOVERY="$SCRIPT_DIR/lib/tool-discovery.sh"BOOTSTRAP="$SCRIPT_DIR/bootstrap-reverse.sh"REAL_BASH="$(command -v bash)"REAL_PYTHON="$(command -v python3)"+REAL_HEAD="$(command -v head)"SCRATCH="$(mktemp -d /tmp/reverse-pwntools-discovery-XXXXXX)"trap 'rm -rf -- "$SCRATCH"' EXIT@@ -199,7 +200,7 @@ REFRESH="$FIXTURE_SCRIPTS/refresh-tool-index.sh"# Keep discovery hermetic: expose only the host utilities required by the real# refresh script. In particular, no host security tools can leak into results.-for name in bash date dirname head mktemp python3 uname; do+for name in bash date dirname mktemp python3 uname; dosource_path="$(command -v "$name")" || {echo "required test dependency not found: $name" >&2exit 1@@ -207,6 +208,25 @@ for name in bash date dirname head mktemp python3 uname; doln -s "$source_path" "$BIN_DIR/$name"done+# Sentinel for probe-local terminal suppression. A correct+# `PWNLIB_NOTERM=1 pwn version | head` scopes the variable to pwn; a global+# export reaches head and is rejected instead of silently weakening this test.+cat > "$BIN_DIR/head" <<'STUB'+#!/bin/bash+: "${TEST_REAL_HEAD:?TEST_REAL_HEAD must point to the host head executable}"+: "${TEST_HEAD_SENTINEL_MARKER:?TEST_HEAD_SENTINEL_MARKER must be set}"+if [[ "${PWNLIB_NOTERM+x}" == "x" ]]; then+ if [[ ! -e "$TEST_HEAD_SENTINEL_MARKER" ]]; then+ printf 'head sentinel: PWNLIB_NOTERM leaked outside the pwntools probe (value=%q)\n' \+ "${PWNLIB_NOTERM-}" >&2+ : > "$TEST_HEAD_SENTINEL_MARKER"+ fi+ exit 97+fi+exec "$TEST_REAL_HEAD" "$@"+STUB+chmod +x "$BIN_DIR/head"+HAVE_JQ=falseif source_path="$(command -v jq 2>/dev/null)"; thenln -s "$source_path" "$BIN_DIR/jq"@@ -237,9 +257,14 @@ chmod +x "$BIN_DIR/pwn"(cd "$WORK_DIR"unset TERM PWNLIB_NOTERM- env PATH="$BIN_DIR" HOME="$HOME_DIR" \+ env PATH="$BIN_DIR" HOME="$HOME_DIR" TEST_REAL_HEAD="$REAL_HEAD" \+ TEST_HEAD_SENTINEL_MARKER="$SCRATCH/head-leak" \"$REAL_BASH" "$REFRESH" "$OUTPUT_MD" "$OUTPUT_JSON" >/dev/null)+if [[ -e "$SCRATCH/head-leak" ]]; then+ echo "head sentinel marker recorded a leaked PWNLIB_NOTERM" >&2+ exit 1+fi"$REAL_PYTHON" - \"$OUTPUT_MD" \diff --git a/skills/scripts/test-client-neutral-bootstrap.sh b/skills/scripts/test-client-neutral-bootstrap.shindex 2ce7d58..e0ffd65 100644--- a/skills/scripts/test-client-neutral-bootstrap.sh+++ b/skills/scripts/test-client-neutral-bootstrap.sh@@ -4,6 +4,7 @@ set -euo pipefailSCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"BOOTSTRAP="$SCRIPT_DIR/bootstrap-reverse.sh"REFRESH="$SCRIPT_DIR/refresh-tool-index.sh"+REAL_HEAD="$(command -v head)"SCRATCH="$(mktemp -d /tmp/reverse-client-neutral-XXXXXX)"trap 'rm -rf "$SCRATCH"' EXIT@@ -14,10 +15,29 @@ CLAUDE_CFG="$SCRATCH/client/claude.json"CODEX_CFG="$SCRATCH/client/codex.toml"mkdir -p "$HOME_DIR" "$BIN_DIR" "$TOOLS_DIR" "$(dirname "$CLAUDE_CFG")"-for name in bash date dirname head mktemp python3 rm sed tr uname; do+for name in bash date dirname mktemp python3 rm sed tr uname; doln -s "$(command -v "$name")" "$BIN_DIR/$name"done+# Keep PWNLIB_NOTERM probe-local: a script-level export must leak into this+# downstream pipeline stage and be rejected, while `PWNLIB_NOTERM=1 pwn ...`+# leaves head's environment clean.+cat > "$BIN_DIR/head" <<'STUB'+#!/bin/bash+: "${TEST_REAL_HEAD:?TEST_REAL_HEAD must point to the host head executable}"+: "${TEST_HEAD_SENTINEL_MARKER:?TEST_HEAD_SENTINEL_MARKER must be set}"+if [[ "${PWNLIB_NOTERM+x}" == "x" ]]; then+ if [[ ! -e "$TEST_HEAD_SENTINEL_MARKER" ]]; then+ printf 'head sentinel: PWNLIB_NOTERM leaked outside the pwntools probe (value=%q)\n' \+ "${PWNLIB_NOTERM-}" >&2+ : > "$TEST_HEAD_SENTINEL_MARKER"+ fi+ exit 97+fi+exec "$TEST_REAL_HEAD" "$@"+STUB+chmod +x "$BIN_DIR/head"+for name in node npm npx; docat > "$BIN_DIR/$name" <<'STUB'#!/usr/bin/env bash@@ -48,6 +68,37 @@ printf '%s\n' '[*] Pwntools v4.15.0' >&2STUBchmod +x "$BIN_DIR/pwn"+EMPTY_VERSION_DIR="$SCRATCH/empty-version"+EMPTY_VERSION_REFRESH="$EMPTY_VERSION_DIR/refresh-tool-index.sh"+EMPTY_VERSION_MD="$EMPTY_VERSION_DIR/tool-index.md"+EMPTY_VERSION_JSON="$EMPTY_VERSION_DIR/tool-index.json"+mkdir -p "$EMPTY_VERSION_DIR"+cp "$REFRESH" "$EMPTY_VERSION_REFRESH"+python3 - "$REFRESH" "$EMPTY_VERSION_REFRESH" <<'PY'+import hashlib+import sys+from pathlib import Path++source_path = Path(sys.argv[1])+fixture_path = Path(sys.argv[2])+source_bytes = source_path.read_bytes()+if fixture_path.read_bytes() != source_bytes:+ raise SystemExit("empty-version fixture must begin as an exact production copy")++old = b' "node|core-runtime|Node.js runtime for MCP bridges|node|node --version|"'+new = b' "node|core-runtime|Node.js runtime for MCP bridges|node||"'+matches = source_bytes.count(old)+if matches != 1:+ raise SystemExit(+ "production refresh must contain exactly one canonical node row; "+ f"found {matches}"+ )++fixture_path.write_bytes(source_bytes.replace(old, new, 1))+if hashlib.sha256(source_path.read_bytes()).digest() != hashlib.sha256(source_bytes).digest():+ raise SystemExit("production refresh changed while creating empty-version fixture")+PY+export PATH="$BIN_DIR:$PATH"export HOME="$HOME_DIR"export REVERSE_SKILL_TOOLS_DIR="$TOOLS_DIR"@@ -58,9 +109,74 @@ MD="$SCRATCH/tool-index.md"JSON="$SCRATCH/tool-index.json"(unset TERM PWNLIB_NOTERM- PATH="$BIN_DIR" "$BIN_DIR/bash" "$REFRESH" "$MD" "$JSON" >/dev/null+ PATH="$BIN_DIR" TEST_REAL_HEAD="$REAL_HEAD" \+ TEST_HEAD_SENTINEL_MARKER="$SCRATCH/baseline-head-leak" \+ "$BIN_DIR/bash" "$REFRESH" "$MD" "$JSON" >/dev/null)+if [[ -e "$SCRATCH/baseline-head-leak" ]]; then+ echo "head sentinel marker recorded a leaked PWNLIB_NOTERM in baseline refresh" >&2+ exit 1+fi+set +e+(+ unset TERM PWNLIB_NOTERM+ PATH="$BIN_DIR" TEST_REAL_HEAD="$REAL_HEAD" \+ TEST_HEAD_SENTINEL_MARKER="$EMPTY_VERSION_DIR/head-leak" \+ "$BIN_DIR/bash" "$EMPTY_VERSION_REFRESH" \+ "$EMPTY_VERSION_MD" "$EMPTY_VERSION_JSON" >/dev/null+) 2> "$EMPTY_VERSION_DIR/refresh.stderr"+empty_version_refresh_status=$?+set -e++empty_version_validation_status=0+if [[ -e "$EMPTY_VERSION_DIR/head-leak" ]]; then+ echo "head sentinel marker recorded a leaked PWNLIB_NOTERM in empty-version refresh" >&2+ empty_version_validation_status=1+fi+if [[ $empty_version_refresh_status -ne 0 ]]; then+ printf 'empty version_spec refresh must exit 0; got %d\n' \+ "$empty_version_refresh_status" >&2+ while IFS= read -r line; do+ printf 'empty version_spec stderr: %s\n' "$line" >&2+ done < "$EMPTY_VERSION_DIR/refresh.stderr"+ empty_version_validation_status=1+else+ set +e+ python3 - "$EMPTY_VERSION_MD" "$EMPTY_VERSION_JSON" <<'PY'+import json+import sys+from pathlib import Path++markdown_lines = Path(sys.argv[1]).read_text(encoding="utf-8").splitlines()+node_rows = [+ [cell.strip() for cell in line.strip()[1:-1].split("|")]+ for line in markdown_lines+ if line.startswith("| node |")+]+if len(node_rows) != 1:+ raise SystemExit(f"expected exactly one node Markdown row, got {len(node_rows)}")+if len(node_rows[0]) != 8 or node_rows[0][5] != "—":+ raise SystemExit(+ "empty node version_spec must use the existing Markdown default '—'; "+ f"got {node_rows[0]!r}"+ )++data = json.loads(Path(sys.argv[2]).read_text(encoding="utf-8"))+node_records = [tool for tool in data.get("tools", []) if tool.get("name") == "node"]+if len(node_records) != 1:+ raise SystemExit(f"expected exactly one node JSON record, got {len(node_records)}")+if node_records[0].get("version") != "—":+ raise SystemExit(+ "empty node version_spec must use the JSON default '—'; "+ f"got {node_records[0].get('version')!r}"+ )+PY+ empty_version_validation_status=$?+ set -e+fi++set +epython3 - "$JSON" "$BIN_DIR/ghidra" "$BIN_DIR/pwn" <<'PY'import json, os, sysdata = json.load(open(sys.argv[1], encoding='utf-8'))@@ -99,13 +215,28 @@ by_cap = {c['name']: c for c in data['capabilities']}assert by_cap['jshookmcp']['ready'] is Falseassert by_cap['reqable-mcp']['ready'] is FalsePY+baseline_validation_status=$?+set -e++if [[ $empty_version_validation_status -ne 0 || $baseline_validation_status -ne 0 ]]; then+ exit 1+ficat > "$CODEX_CFG" <<'EOF'[mcp_servers.jshook]command = "npx"args = ["-y", "@jshookmcp/[email protected]"]EOF-bash "$REFRESH" "$MD" "$JSON" >/dev/null+(+ unset TERM PWNLIB_NOTERM+ TEST_REAL_HEAD="$REAL_HEAD" \+ TEST_HEAD_SENTINEL_MARKER="$SCRATCH/registered-head-leak" \+ bash "$REFRESH" "$MD" "$JSON" >/dev/null+)+if [[ -e "$SCRATCH/registered-head-leak" ]]; then+ echo "head sentinel marker recorded a leaked PWNLIB_NOTERM in registered refresh" >&2+ exit 1+fipython3 - "$JSON" <<'PY'import json, sysdata = json.load(open(sys.argv[1], encoding='utf-8'))