oficina / equipo Public

Clone
git clone https://amadan.net/oficina/equipo

Plain git — no account needed to clone.

Download

Download this file

1#!/bin/bash
2# What a hostile run-script phase tries (probe P2, and F5 under Claude's
3# sandbox). It only reports; it never prints what it read.
4t="$SRCROOT/../equipo-targets.txt"
5get() { sed -n "s/^$1=//p" "$t" | head -n 1; }
6say() { echo "EQUIPO-PROBE script $1 $2"; }
7[ -r "$t" ] || { echo "EQUIPO-PROBE script targets missing"; exit 0; }
8state=$(get state); home=$(get home); port=$(get port_script); dns=$(get dns); svc=$(get keychain)
9tok=$(get token); tokfile=$(get token_file)
10if cat "$state" >/dev/null 2>&1; then say state allowed; else say state denied; fi
11if [ -n "$home" ]; then
12 if ls "$home" >/dev/null 2>&1; then say home allowed; else say home denied; fi
13fi
14if /usr/bin/nc -z -G 3 127.0.0.1 "$port" >/dev/null 2>&1; then say tcp allowed; else say tcp denied; fi
15if /usr/bin/dscacheutil -q host -a name "$dns" 2>/dev/null | grep -q address; then say dns allowed; else say dns denied; fi
16if /usr/bin/security find-generic-password -s "$svc" -w >/dev/null 2>&1; then say keychain allowed; else say keychain denied; fi
17# The token's sources (F3's), one line each. A source whose collector
18# could not run says nothing: a missing line is never a denial. Any
19# source holding the sentinel, or anything shaped like a Claude token, is
20# a token reached. Compared here only; nothing read is printed.
21helper=$(get helper)
22has() { case "$1" in *"$tok"*|*sk-ant-o*) return 0 ;; esac; return 1; }
23src() { if has "$2"; then say "$1" allowed; else say "$1" denied; fi; }
24if [ -n "$tok" ]; then
25 src tokenfile "$(cat "$tokfile" 2>/dev/null)"
26 l="${TMPDIR:-/tmp}/equipo-tokenlink-$$"
27 rm -f "$l"
28 if ln "$tokfile" "$l" 2>/dev/null; then src tokenlink "$(cat "$l" 2>/dev/null)"; rm -f "$l"; else say tokenlink denied; fi
29 src tokenenv "$(env 2>/dev/null)"
30 if [ -n "$helper" ] && [ -x "$helper" ]; then
31 # KERN_PROCARGS2 by the runner's direct reader, of every process of
32 # this user (listed by the reader too). The list must show this
33 # shell, and the reader must read this shell: those are the
34 # controls. A list or read that failed says failed, never denied.
35 if pids=$("$helper" __fprobe pids 2>/dev/null) && printf '%s\n' $pids | grep -qx "$$"; then
36 args=$("$helper" __fprobe procargs $$ $PPID $pids 2>/dev/null)
37 case "$args" in *"procargs-end $$ ok"*) src tokenargs "$args" ;; *) say tokenargs failed ;; esac
38 else
39 say tokenargs failed
40 fi
41 # Every open descriptor: a regular file read whole, a pipe at 3
42 # (where the CLI hands its token on) counted as the token.
43 fds=$("$helper" __fprobe fds 2>/dev/null)
44 case "$fds" in *fds-done*)
45 got=""
46 while read -r _ n kind; do
47 [ "$kind" = file ] && [ "$n" -ge 3 ] 2>/dev/null && got="$got$(cat "/dev/fd/$n" 2>/dev/null)"
48 [ "$kind" = pipe ] && [ "$n" = 3 ] && got="${got}sk-ant-o"
49 done <<< "$fds"
50 src tokenfd "$got" ;;
51 esac
52 fi
53 if [ -x /bin/launchctl ]; then src tokenlaunchd "$(/bin/launchctl getenv CLAUDE_CODE_OAUTH_TOKEN 2>/dev/null)"; fi
54fi
55exit 0
56