Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aienos.com/blob/main/scripts/allen/pusher/sandbox_probe.py # aienos.com Source of www.aienos.com, served from my own hardware Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aienos.com / scripts / allen / pusher / sandbox_probe.py` 58 lines ยท 3232 bytes Raw Blame History 1 """Run inside the pusher unit's sandbox (same properties via systemd-run) and report what it can reach.""" 2 import ctypes 3 import mmap 4 import os 5 import socket 6 import sys 7 8 # The operator's real home, passed in (systemd-run -E PROBE_HOME=$HOME); the sandbox's own HOME is not it. 9 home = os.environ.get("PROBE_HOME") or sys.exit("sandbox_probe.py: set PROBE_HOME to the operator's home, e.g. PROBE_HOME=$HOME") 10 11 12 def t(label, f): 13 try: 14 print(label, "->", f()) 15 except Exception as e: 16 print(label, "-> DENIED", type(e).__name__, getattr(e, "errno", "")) 17 18 19 def wtest(d): 20 p = os.path.join(d, ".probe-%d" % os.getpid()) 21 open(p, "w").close() 22 os.unlink(p) 23 return "ok" 24 25 26 print("uid/gid/groups:", os.getuid(), os.getgid(), os.getgroups()) 27 t("list /home", lambda: os.listdir("/home")) 28 t("read ~/.config/gh/hosts.yml", lambda: len(open(home + "/.config/gh/hosts.yml").read())) 29 t("list /root", lambda: os.listdir("/root")) 30 t("list spool-in", lambda: os.listdir("/var/lib/allen-chat/spool-in")) 31 t("write spool-status", lambda: wtest("/var/lib/allen-chat/spool-status")) 32 t("write state dir", lambda: wtest("/var/lib/omega-pusher")) 33 t("list /var/lib/allen-contacts", lambda: os.listdir("/var/lib/allen-contacts")) 34 t("list contacts-drop", lambda: os.listdir("/var/lib/allen-chat/contacts-drop")) 35 t("write /opt/omega-projects-pusher", lambda: wtest("/opt/omega-projects-pusher")) 36 t("write /etc", lambda: wtest("/etc")) 37 t("write /var/lib", lambda: wtest("/var/lib")) 38 t("/tmp entries", lambda: len(os.listdir("/tmp"))) 39 t("gb10 lock visible", lambda: os.path.exists("/tmp/aien-gb10.lock")) 40 t("read /etc/credstore.encrypted", lambda: os.listdir("/etc/credstore.encrypted")) 41 t("credential dir", lambda: (os.environ.get("CREDENTIALS_DIRECTORY"), 42 sorted(os.listdir(os.environ["CREDENTIALS_DIRECTORY"])) 43 if os.environ.get("CREDENTIALS_DIRECTORY") else None)) 44 t("credential length", lambda: len(open(os.path.join(os.environ["CREDENTIALS_DIRECTORY"], "omega-projects-probe")).read())) 45 t("AF_NETLINK socket", lambda: socket.socket(socket.AF_NETLINK, socket.SOCK_RAW, 0)) 46 t("AF_PACKET socket", lambda: socket.socket(socket.AF_PACKET, socket.SOCK_RAW, 0)) 47 t("connect api.github.com:443", lambda: socket.create_connection(("api.github.com", 443), timeout=10).close() or "ok") 48 libc = ctypes.CDLL(None, use_errno=True) 49 t("personality(PER_LINUX32) rc,errno", lambda: (libc.personality(0x0008), ctypes.get_errno())) 50 t("mount rc,errno", lambda: (libc.mount(b"none", b"/tmp", b"tmpfs", 0, None), ctypes.get_errno())) 51 t("unshare(CLONE_NEWUSER) rc,errno", lambda: (libc.unshare(0x10000000), ctypes.get_errno())) 52 t("mmap W+X", lambda: mmap.mmap(-1, 4096, prot=7)) 53 t("ps sees pids", lambda: len([p for p in os.listdir("/proc") if p.isdigit()])) 54 for k in ("CapBnd", "CapEff", "NoNewPrivs", "Seccomp"): 55 print([ln.strip() for ln in open("/proc/self/status") if ln.startswith(k + ":")]) 56 t("/dev/tpmrm0 visible", lambda: os.path.exists("/dev/tpmrm0")) 57 t("read a spool-in item (group allen-spool)", lambda: [len(open(os.path.join("/var/lib/allen-chat/spool-in", n)).read()) 58 for n in os.listdir("/var/lib/allen-chat/spool-in")])