dsh-redteam-model
SeaOf0
基于dsh web实现的多种模式,目的是服务于redteam进行授权的安全研究,覆盖渗透测试、红队评估、代码审计等范围领域,请勿用于非法行为。(允许二开,赋予模块各位自己的业务逻辑,方法论只有自己熟练的才好用,好的方法论=好的生态)
PROJECT TOPICS
INSTALL REFERENCE
dsh plugin --profile web add github:Wang-Lin-Chang/dsh-macos
该命令指向仓库当前默认分支;尚无绑定当前 commit 的完整验证结果。
PROJECT README
Part of the DSH plugin suite — six Apache-2.0 plugins for DeepSeek Harness.
macOS backend for dsh-witness and dsh-anchor: uchg immutable flags + a sandbox-exec deny view give macOS the same six-dimension evidence protection the other platforms have. Every capability claim carries an experiment number and a control group.
中文版见 README.zh-CN.md。
dsh-witness's task evidence chain needs a sandbox at the same level on all three platforms. Windows uses a six-dimension NTFS ACL closure, Linux uses chattr +i + bubblewrap — macOS is the last piece of the puzzle:
| Capability | Windows (dsh-witness) | Linux (dsh-cross-platform) | macOS (this package) |
|---|---|---|---|
| Overwrite-proof | NTFS ACL deny | chattr +i + bwrap read-only view | sandbox-exec deny view |
| Delete-proof | NTFS ACL deny | chattr +i | chflags uchg |
| Forge-proof lock/exit.txt | ACL + guard handle | chattr +i | chflags uchg |
| Write isolation view | Restricted token | bubblewrap (EROFS) | sandbox-exec (allow default) + surgical deny |
| Process identity | PowerShell StartTime | /proc/ |
ps -o lstart |
| Exit protocol | EXIT:<code> |
EXIT:<code> |
EXIT:<code> (fully aligned) |
Each task is supervised by the runner with the following sequence (aligned with the Linux architecture verdict):
node detach-runner-macos.cjs <jobDir> <outFile> <exitFile> <commandBase64>
① lock (wx exclusive) lock ← "pid:startSec" (ps -o lstart, EXP-3 measured format)
② Pre-create protocol files exit.txt (truncate-rewritten per lifecycle) + out.log (append)
③ uchg only on protocol files chmod 444 → chflags uchg: exit.txt / lock (the runner no longer writes them)
④ sandbox-exec wraps the task (allow default) (deny file-write* (subpath "<realpath(jobDir)>"))
—— network available, outside-directory writable, in-directory writes all blocked (EXP-3 P1 three-case control winner)
⑤ Output pipe capture stdout/stderr → out.log (out.log not uchg'd — the deny view protects it)
⑥ Exit nouchg → write EXIT:<code> → delete lock → process exits
Two key verdicts (EXP-2): on macOS 26, sandbox-exec with no explicit default implicitly defaults to deny — a task missing (allow file-read*) gets silently SIGKILLed by the kernel; /bin/bash must use an absolute path (execvp's PATH lookup inside the sandbox is refused). The deny subpath must use the realpath'd path (/tmp → /private/tmp symlink mismatch silently disables the sandbox).
ps -o lstart start-time formula (EXP-3 PS-LSTART measured + smoke ±5s); PID-reuse protection at the same level as Windows/Linux.EXIT:<code>, lock = pid:startSec, O_EXCL race semantics identical to the two published backends; the registry switches platforms without noticing.chmod 444 same-user write protection (EXP-1 measured); Windows/Linux have no such free lunch.# Install (git source, pinned tag — the pre-npm installation path)
dsh plugin --profile <name> add "github:Wang-Lin-Chang/dsh-macos#v0.1.0"
import { MacosSandboxBackend } from 'dsh-macos'
const backend = new MacosSandboxBackend('/path/to/job-dir')
backend.apply() // chflags uchg evidence files (before task spawn)
backend.verify() // fail-closed self-check (aligned EXIT:-998 semantics)
backend.restore() // restore after task death (registry terminal-state window)
Direct runner usage (same protocol as detach-runner.cjs / detach-runner-linux.cjs):
node detach-runner-macos.cjs <jobDir> <outFile> <exitFile> <commandBase64>
test/witness-final-macos-test.ts — 12 scenarios / 34 assertions, 34/34 ×3 stable (GitHub Actions macos-latest · macOS 26.5.2 arm64 · Node 25.9). Plus: runner smoke 9/9.
| Category | Scenario | Assertions |
|---|---|---|
| Persistence A | Survives restart / zombie recovery (SIGKILL) / cursor-based output read / ID collision-free | 4 |
| Adoption coordination B | 50-process O_EXCL race yields exactly one terminal state / cross-session adoption / silent-task protection / PID-reuse guard | 4 |
| Event sourcing C | Event log complete and ordered / autopsy report generated | 2 |
| Sandbox boundary D | Overwrite-proof / delete-proof (sandbox-exec deny view + uchg) | 2 |
Run it yourself: npm test (node --experimental-strip-types test/witness-final-macos-test.ts).
All experiments live in EXPERIMENTS.md: 4 verdicts, each with a control group. Three decisive results:
(allow file-read*), consistent across three reruns.(allow default) wins (IN-WRITE-BLOCKED / OUT-WRITE-ALLOWED / network 200).src/
├── detach-runner-macos.cjs # task runner (sandbox-exec wrap + uchg, protocol fully aligned with Windows/Linux)
├── macos-backend.mjs # sandbox backend (uchg apply/verify/restore + capability self-report)
└── macos-utils.mjs # ps lstart start time + process liveness + exit-code protocol
vendor/
├── detach-runner-macos.cjs # self-contained runner copy (for registry integration)
└── lib/ # WitnessJobRegistry compiled output (darwin branch)
(allow default) or the full allow set, otherwise the task is SIGKILLed./tmp symlink trap: the deny subpath must use the realpath'd path, otherwise the /tmp → /private/tmp mismatch silently disables the sandbox (the runner has realpath built in).npm test # 12 acceptance scenarios, macOS edition (needs macOS; see EXPERIMENTS.md lab notes)
Requires: Node ≥ 22.6 (node:sqlite, measured on 25.9), macOS (sandbox-exec / chflags).
Apache-2.0
CLASSIFICATION EVIDENCE
系统优先读取 GitHub Topics,再与站内分类词典和词根规则比对。当前命中: sandbox。