dsh-redteam-model
SeaOf0
基于dsh web实现的多种模式,目的是服务于redteam进行授权的安全研究,覆盖渗透测试、红队评估、代码审计等范围领域,请勿用于非法行为。(允许二开,赋予模块各位自己的业务逻辑,方法论只有自己熟练的才好用,好的方法论=好的生态)
PROJECT TOPICS
INSTALL REFERENCE
dsh plugin --profile web add github:darkmagic-ai/dsh-guard
该命令指向仓库当前默认分支;尚无绑定当前 commit 的完整验证结果。
PROJECT README
中文 | English
让 AI 删库之前先问你一声。 给 DeepSeek Harness (DSH) 加一道护栏:拦截危险命令和敏感文件访问,给工具输出里的密钥、手机号打码,并留下本地审计日志。

git push --force、curl | sh、删注册表等。每条规则可以设为 deny(直接拒绝)或 ask(在网页里弹审批,你点批准才执行)。.env、SSH 私钥、云厂商凭据、浏览器 Cookie / 密码库、DSH 自己的凭据文件。sk- key、GitHub / AWS / Slack / Google / Stripe token、Bearer、password= 一类键值、身份证号、中国和智利手机号),邮箱和智利 RUT 可选开启。$DSH_HOME/dsh-guard/。写入前先脱敏再截断,不会把密钥原文落盘。guard_report 工具:问 AI“今天都干了啥”,它会返回一份中文日报。dryRun 演练模式:只记录、不拦截,方便先观察会误拦哪些命令。cordis.patch.yml 挂载,不用改 DSH 源码。建议先装到一个单独的测试 profile 里试用:
# 从 npm 安装
dsh plugin --profile <profile> add dsh-guardrail
# 或者用离线安装包
dsh plugin --profile <profile> add ./dsh-guardrail-0.1.2.tgz
启动后日志里出现 [dsh-guard] 已加载… 就说明装好了。
要重装同一个版本,先运行
dsh plugin --profile <p> remove dsh-guardrail再add,不然可能用到旧缓存。
要求:DSH ≥ 0.2.1-rc.5,Node ≥ 22。已在 Linux 和 Windows(PowerShell)上验证。
在网页 Plugins → dsh-guardrail 里改,或者写进 profile 配置。
| 配置项 | 默认值 | 说明 |
|---|---|---|
enabled |
true |
总开关 |
dryRun |
false |
演练模式:只写审计日志,不拦截、不脱敏 |
announce |
true |
往系统提示里加一小段护栏说明(约 60 token) |
ignoreTools |
["guard_report"] |
这些工具不做拦截检查 |
commandArgKeys |
内置列表 | 哪些参数名算“命令文本” |
pathArgKeys |
内置列表 | 哪些参数名算“路径” |
disabledRules |
[] |
要关掉的内置规则 id |
rules |
[] |
自定义规则:{ id, kind: command\|path, pattern, flags="i", action="ask", reason } |
allow |
[] |
白名单正则,命中的参数不会触发拦截 |
redact.enabled |
true |
是否给工具输出打码 |
redact.mode |
content |
content 只改模型看到的文本;value 改规范化后的 value(PTC 场景用) |
redact.disabled |
[] |
要关掉的内置脱敏规则名 |
redact.emails |
false |
给邮箱打码 |
redact.chileRut |
false |
给智利 RUT 打码 |
redact.extra |
[] |
自定义脱敏:{ name, pattern, flags="g", replacement="[REDACTED]" } |
audit.enabled |
true |
写审计日志 |
audit.dir |
"" |
日志目录,留空就用 $DSH_HOME/dsh-guard |
audit.logAllowed |
true |
放行的调用也记下来 |
audit.logArgs |
true |
记录参数预览(先脱敏再截断) |
audit.maxArgChars |
200 |
参数预览最多保留几个字符 |
没有审批通道时(比如 headless 运行),
ask会退化成拒绝,审计里记为unavailable。
| id | 类型 | 动作 | 说明 |
|---|---|---|---|
rm-rf-root-home |
command | deny | 递归删除根目录/用户目录/盘符 |
rm-rf |
command | ask | 递归强制删除 (rm -rf) |
win-del-recursive |
command | ask | Windows 递归删除 (del /s、rd /s、rmdir /s) |
remove-item-root-home |
command | deny | PowerShell 递归删除根目录/用户目录/盘符 |
remove-item-recurse |
command | ask | PowerShell 递归删除 (Remove-Item -Recurse) |
format-disk |
command | deny | 格式化磁盘/分区 |
diskpart-bcdedit |
command | ask | 磁盘/启动项管理工具 (diskpart/bcdedit/vssadmin) |
fork-bomb |
command | deny | fork 炸弹 |
shutdown |
command | ask | 关机/重启 |
reg-delete |
command | ask | 删除注册表项 (reg delete / Remove-ItemProperty on registry) |
net-user-add |
command | ask | 新增系统用户/提权 (net user /add、net localgroup administrators) |
git-push-force |
command | ask | git 强制推送 (--force / -f / --force-with-lease) |
git-destructive |
command | ask | git 破坏性操作 (reset --hard / clean -fd / branch -D 远端删除) |
pipe-to-shell |
command | ask | 下载内容直接交给 shell 执行 (curl |
env-file |
path | ask | .env 环境变量/密钥文件 |
ssh-private-key |
path | deny | SSH 私钥 |
ssh-dir |
path | ask | ~/.ssh 目录 |
dsh-credentials |
path | deny | DSH 凭据文件 (.credentials.yaml) |
key-cert-files |
path | ask | 证书/私钥文件 (.pem, .p12, .pfx, .ppk, *.key) |
browser-secrets |
path | deny | 浏览器 Cookie / 登录数据库 |
cloud-credentials |
path | ask | 云/CLI 凭据文件 (.aws/credentials, .git-credentials, .netrc, .kube/config, .docker/config.json) |
system-secrets |
path | deny | 系统密码库 (/etc/shadow, Windows SAM) |
guard_report 示例📋 dsh-guard 日报 2026-11-04
工具调用共 4 次;拦截 1 次,询问 2 次(批准 1 / 拒绝 1)。
输出脱敏共 3 处(github-token×1、cn-phone×1、cl-phone×1)。
调用最多的工具:powershell×3、read_file×1
被拦截/询问的记录(最近 3 条,共 3 条):
- 23:21:05 [powershell] 已拒绝 · 规则 ssh-private-key · type C:\temp\id_rsa
- 23:21:40 [powershell] 询问→被拒绝 · 规则 reg-delete · reg delete HKCU\Software\DshGuardTest /f
- 23:22:10 [powershell] 询问→已批准 · 规则 remove-item-recurse · Remove-Item -Recurse X:\demo
日志文件:~/.dsh/profiles/<p>/dsh-guard/audit-2026-11-04.jsonl
会拖慢 DSH 吗? 不会。每次工具调用只多跑几次正则匹配,可以忽略。
误拦了怎么办? 把规则 id 加进 disabledRules,或者把对应命令写进 allow 白名单。也可以先开 dryRun 观察一天。
被拦之后 AI 会换个写法绕过吗? 拒绝消息里明确要求它不要绕。实测时 DeepSeek 都如实告诉了用户。但这只是约束,不是保证,见上面的局限。
审计日志会上传吗? 不会。日志只写在本地,插件不发起任何网络请求。
和 Windows 兼容吗? 兼容。规则覆盖了 del /s、Remove-Item -Recurse、reg delete、diskpart 这些命令,也已经在 Windows 真机上测过。
Make the AI ask before it nukes your repo. A guardrail plugin for DeepSeek Harness (DSH): blocks or asks before dangerous commands and sensitive file access, redacts secrets in tool output, and keeps a local audit log.

git push --force, curl | sh, registry deletes and more. Each rule either uses deny or ask (an approval prompt in the web UI)..env, SSH keys, cloud credentials, browser cookies and password stores, and DSH's own credential files.sk- keys, GitHub/AWS/Slack/Google/Stripe tokens, Bearer tokens, password=-style pairs, CN ID cards, and CN and Chile phone numbers. Email and Chile RUT redaction are optional.$DSH_HOME/dsh-guard/. Previews are redacted and then truncated before they are written.guard_report tool: returns a daily summary in Chinese.dryRun: logs what would be blocked without blocking anything.cordis.patch.yml, with no changes to DSH source.dsh plugin --profile <profile> add dsh-guardrail
# or offline
dsh plugin --profile <profile> add ./dsh-guardrail-0.1.2.tgz
Look for [dsh-guard] 已加载… in the startup log. Requires DSH ≥ 0.2.1-rc.5 and Node ≥ 22. Tested on Linux and Windows (PowerShell).
The keys and defaults are the same as in the Chinese table above. The ones you'll use most are dryRun (false), disabledRules ([]), allow ([]), rules ([]), redact.mode ("content"), redact.emails (false), audit.dir ("" → $DSH_HOME/dsh-guard) and audit.maxArgChars (200). Without an approval channel (headless), ask falls back to deny and is logged as unavailable.
See the rule table above. Each rule has an id, a type (command or path) and an action (deny or ask).
This is a regex guardrail, not a sandbox. Encoded commands, variable concatenation, scripts written and then executed, or other interpreters can bypass it. It catches accidents, not adversaries. Redaction is pattern-based too, so it can miss secrets or redact the wrong text. If you need real isolation, use it together with sandboxes or containers and least-privilege accounts. Please don't market it as "absolutely safe".
disabledRules or a pattern to allow, or start with dryRun.CLASSIFICATION EVIDENCE
系统优先读取 GitHub Topics,再与站内分类词典和词根规则比对。当前命中: security。