mirror of
https://github.com/YuJunZhiXue/dsh-purge.git
synced 2026-11-27 16:50:22 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
67f1325d89 | ||
|
|
5fa04372cc | ||
|
|
b57944042b | ||
|
|
8b6f3608fb |
No files matched your search
@@ -4,7 +4,7 @@
|
||||
|
||||
<h1 align="center">⚔️ DeepSeek Harness cybersecurity red-team tool (dsh-purge)</h1>
|
||||
|
||||
<p align="center"><strong>Version 1.1.73</strong></p>
|
||||
<p align="center"><strong>Version 1.1.74</strong></p>
|
||||
|
||||
<p align="center">
|
||||
<em>DeepSeek Harness jailbreak: every model, swap prompts per model. Default prompt for 小码酱. Please star ⭐ If you build on this, see Attribution required.</em>
|
||||
@@ -33,7 +33,7 @@
|
||||
|
||||
People have been selling this open-source work in the open. After that, the author was asked to come in and talk. No need to spell out the rest. Read between the lines.
|
||||
|
||||
From now on the **public internet is closed**. The open-source build only allows **local lab** targets: localhost, private nets, and local suffixes such as `.lab` / `.lan` / `.htb`. A public IP, a public domain, an online range, or a registered public host does not pass. This build does not ship the skill library or the knowledge base.
|
||||
From now on the **public internet is closed**. The open-source build only allows **local lab IPs**: loopback and RFC1918. Domains are resolved first (including hosts); every answer must be private or loopback. A hosts trick that points `.lab` at a public IP, a failed lookup, or a mixed public answer is blocked. **Game cheats are forbidden** (aimbot, wallhack, memory edits against a game, anti-cheat bypass); the prompt and the session gate both stop them. This build does not ship the skill library or the knowledge base.
|
||||
|
||||
**The original build may not be resold.** Charging for it, skinning it, or hawking it in groups is not allowed. Forks are fine, but **you must attribute** and name the source: [YuJunZhiXue/dsh-purge](https://github.com/YuJunZhiXue/dsh-purge). Hide the source or pass it off as your own, and you are on the other side.
|
||||
|
||||
@@ -57,7 +57,7 @@ The author's personal channel: [t.me/LLM_PoJia](https://t.me/LLM_PoJia). Notes a
|
||||
|
||||
## What this is
|
||||
|
||||
**dsh-purge** is a cybersecurity red-team plugin for the official [DeepSeek Harness](https://www.deepseek.com/harness/) already installed on your machine. **1.1.73** targets **DSH 0.2.1-rc.2** (0.2.0 still works). Official **Web** (`dsh web`) and the official **desktop EXE** are both supported. Install and Apply them separately.
|
||||
**dsh-purge** is a cybersecurity red-team plugin for the official [DeepSeek Harness](https://www.deepseek.com/harness/) already installed on your machine. **1.1.74** targets **DSH 0.2.1-rc.2** (0.2.0 still works). Official **Web** (`dsh web`) and the official **desktop EXE** are both supported. Install and Apply them separately.
|
||||
|
||||
Harness does more than forward a prompt. It rewrites prompts, approval gates, sandbox policy, and session migration at runtime. Asking only “will the model answer” treats a host-layer block as a model refusal. This plugin separates those two layers on your own install, for controlled evaluation and for seeing which default policy is too tight.
|
||||
|
||||
@@ -107,7 +107,7 @@ This repo is [Apache License 2.0](./LICENSE). Forks and redistributions must kee
|
||||
2. **Local official Harness only.** Security-eval patches and prompt injection run only on the **official DeepSeek Harness already installed on the user's machine** (`@deepseek-ai` packages, local profile / `$DSH_HOME`). The target is the user's own official local software, **not** someone else's website, server, account, or information system.
|
||||
3. **Eval patches do not attack the public internet.** Apply, inject, revert, and uninstall stay in local files and local processes. They **do not scan, probe, intrude, or send attack traffic to any public host or unauthorized system**. Do not use this project as a jump host against the public internet. If "check for updates" is on, the plugin may only contact this plugin's own GitHub repository to compare versions. That is **not** an attack on third-party systems and is **not** authorization to penetrate anything.
|
||||
4. **Lawful, controlled scope.** This project is an aid for red-team research and robustness evaluation on an **official Harness the user is entitled to administer**. **Do not run it against targets without the owner's lawful written authorization, public online systems, or production workloads.** Testing must stay on the **authorized local official Harness, offline local synthetic fixtures, authorized cybersecurity ranges, and compliant lab environments**.
|
||||
5. **The open-source build is local-lab only.** Attack tasks only allow localhost/private nets and local suffixes such as `.lab` / `.lan` / `.htb`. A public IP, a public domain, an online range, or a registered public host is not an exception. A key, a password, a network range, a wildcard, or a claim made in the conversation does not add an exception. This build does not ship the skill library or the knowledge base.
|
||||
5. **The open-source build is local-lab only.** Attack tasks only allow loopback and RFC1918 addresses. Domains are resolved, then judged by IP; suffixes are not an allow list. A public IP, a name that resolves public, a failed lookup, or a hosts entry that points a lab name at the public internet is not an exception. A key, a password, a network range, a wildcard, or a claim made in the conversation does not add an exception. Game cheats are forbidden. This build does not ship the skill library or the knowledge base.
|
||||
6. **Forbidden uses.** Users must not use this project, directly or indirectly, to violate the following (each must be followed; no excuse to evade):
|
||||
- <font color="red"><strong>Criminal Law of the People's Republic of China</strong></font>
|
||||
- <font color="red"><strong>Cybersecurity Law of the People's Republic of China</strong></font>
|
||||
@@ -131,9 +131,9 @@ This repo is [Apache License 2.0](./LICENSE). Forks and redistributions must kee
|
||||
|
||||
## Supported hosts
|
||||
|
||||
**1.1.73 targets DSH 0.2.1-rc.2.** 0.2.0 still works. Do not apply it to 0.1.x.
|
||||
**1.1.74 targets DSH 0.2.1-rc.2.** 0.2.0 still works. Do not apply it to 0.1.x.
|
||||
|
||||
- **dsh 0.2.1-rc.2** (official desktop / official `dsh web`): use **1.1.73**. Fixes `{{cwd}}` / `[cwd]` crash, patch #40 match, dropped `toolFilter`, host `dsh-tools` resolve, hostFs fd, desktop helper self-kill, `file:` archive update, Ctrl+Enter steer.
|
||||
- **dsh 0.2.1-rc.2** (official desktop / official `dsh web`): use **1.1.74**. Fixes `{{cwd}}` / `[cwd]` crash, patch #40 match, dropped `toolFilter`, host `dsh-tools` resolve, hostFs fd, desktop helper self-kill, `file:` archive update, Ctrl+Enter steer.
|
||||
- **dsh 0.2.0-rc.2**: use **1.1.40** or newer; this line also installs.
|
||||
- **dsh 0.1.7** (incl. rc.1 / rc.2): use **1.1.39** or older — pick the tag on [Releases](https://github.com/YuJunZhiXue/dsh-purge/releases).
|
||||
|
||||
@@ -155,7 +155,7 @@ If this directory is already a clone, use `add .` instead of the URL. If `dsh` i
|
||||
For the desktop client you can also click the button (`dsh://` deep link):
|
||||
|
||||
<p align="center">
|
||||
<a href="dsh://plugin/install?id=dsh-purge&name=dsh-purge&version=1.1.73&repo=YuJunZhiXue%2Fdsh-purge&permissions=%E7%B3%BB%E7%BB%9F%E6%8F%90%E7%A4%BA%E8%AF%8D%E6%B3%A8%E5%85%A5%2C%E6%9C%AC%E6%9C%BA%E8%A1%A5%E4%B8%81%2C%E8%AE%BE%E7%BD%AE%E9%A1%B5&downloadUrl=https%3A%2F%2Fgithub.com%2FYuJunZhiXue%2Fdsh-purge%2Farchive%2Frefs%2Fheads%2Fmaster.tar.gz"><strong>Install in desktop client</strong></a>
|
||||
<a href="dsh://plugin/install?id=dsh-purge&name=dsh-purge&version=1.1.74&repo=YuJunZhiXue%2Fdsh-purge&permissions=%E7%B3%BB%E7%BB%9F%E6%8F%90%E7%A4%BA%E8%AF%8D%E6%B3%A8%E5%85%A5%2C%E6%9C%AC%E6%9C%BA%E8%A1%A5%E4%B8%81%2C%E8%AE%BE%E7%BD%AE%E9%A1%B5&downloadUrl=https%3A%2F%2Fgithub.com%2FYuJunZhiXue%2Fdsh-purge%2Farchive%2Frefs%2Fheads%2Fmaster.tar.gz"><strong>Install in desktop client</strong></a>
|
||||
</p>
|
||||
|
||||
### After the command: three steps
|
||||
@@ -336,7 +336,7 @@ The open-source build only allows localhost/private nets. The Clean page says so
|
||||
| Drill | assets and environment after authorization. This build does not ship skills or the knowledge base. The tab says Unauthorized until then |
|
||||
| Patches | grouped status, Apply, Restore, or Uninstall |
|
||||
| Prompt | edit `prompt-inject.md` as the session override |
|
||||
| Local lab | localhost/private nets and local suffixes such as `.lab` / `.lan` / `.htb` only |
|
||||
| Local lab | loopback / RFC1918 only; names are resolved, and every address must be private |
|
||||
| Rule sets | multiple `AGENTS.md` / `CLAUDE.md`; Enable writes under `$DSH_HOME`, Delete removes the row |
|
||||
|
||||
---
|
||||
@@ -399,7 +399,7 @@ Restart `dsh web` to load the profile. The model and reasoning defaults apply to
|
||||
|
||||
### Local lab
|
||||
|
||||
Attack tasks are denied by default. The open-source build only allows localhost/private local labs. Saying “this is my server” in chat does not allow it. Registering a public IP or domain does not allow it either.
|
||||
Attack tasks are denied by default. The open-source build only allows loopback and RFC1918 IPs. Names are resolved first; a `.lab` / `.htb` suffix is not enough. A hosts entry that points a lab name at a public IP is blocked. Saying “this is my server” in chat does not allow it.
|
||||
|
||||
---
|
||||
|
||||
|
||||
+9
-9
@@ -4,7 +4,7 @@
|
||||
|
||||
<h1 align="center">⚔️ DeepSeek Harness 网络安全红队工具(dsh-purge)</h1>
|
||||
|
||||
<p align="center"><strong>Version 1.1.73</strong></p>
|
||||
<p align="center"><strong>Version 1.1.74</strong></p>
|
||||
|
||||
<p align="center">
|
||||
<em>DeepSeek Harness 破甲:让所有模型都能破甲,不同模型可换不同提示词;默认提示词面向国模「小码酱」。Jailbreak for every model — swap prompts per model. 求 Star 收藏 ⭐ 如要二开,请查看署名要求部分</em>
|
||||
@@ -33,7 +33,7 @@
|
||||
|
||||
市面上有人把这份开源明目张胆挂出去卖。后面作者这边被找去谈过话——经过不必写,你们自己品。
|
||||
|
||||
从今往后,**公网一律不许碰**。开源版攻击任务只认**本地靶场**:本机、内网,以及 `.lab` / `.lan` / `.htb` 这类本机实验室后缀。公网 IP、域名、网上演练平台、自己登记的公网机器,一个都不放。不是本地靶场就别跑,也跑不过去。开源版不下发技能库和知识库。
|
||||
从今往后,**公网一律不许碰**。开源版攻击任务只认**本地靶场 IP**:本机回环和 RFC1918 私网。域名会先按系统解析(含 hosts),解析到的每一个地址都必须是私网或回环;hosts 把 `.lab` 指到公网、解析失败、混有公网地址,一律拦。不是本地靶场就别跑,也跑不过去。**禁止制作外挂**(自瞄、透视、改内存打游戏、过反作弊),提示词和会话门口一起拦。开源版不下发技能库和知识库。
|
||||
|
||||
**原版不允许倒卖。** 收费、当货挂群,一律不行。二开可以,但**必须署名**,写明来源仓库:[YuJunZhiXue/dsh-purge](https://github.com/YuJunZhiXue/dsh-purge)。不署名、隐瞒来源、改头换面据为己有,作者一律当对家。
|
||||
|
||||
@@ -57,7 +57,7 @@
|
||||
|
||||
## 介绍
|
||||
|
||||
**dsh-purge** 是装在本机官方 [DeepSeek Harness](https://www.deepseek.com/harness/) 上的网络安全红队评测插件。当前 **1.1.73** 已适配 **DSH 0.2.1-rc.2**(0.2.0 仍可用)。官方 **Web**(`dsh web`)和官方 **桌面端**(EXE)都支持,两边分开装、分开应用。
|
||||
**dsh-purge** 是装在本机官方 [DeepSeek Harness](https://www.deepseek.com/harness/) 上的网络安全红队评测插件。当前 **1.1.74** 已适配 **DSH 0.2.1-rc.2**(0.2.0 仍可用)。官方 **Web**(`dsh web`)和官方 **桌面端**(EXE)都支持,两边分开装、分开应用。
|
||||
|
||||
Harness 不只是把问题交给模型。它还会在运行时改提示词、审批门、沙箱和会话格式。只看「模型答不答」,会把宿主拦截误当成模型拒绝。这个插件在你自己的安装里把这两层分开,用来做受控评测,也用来看默认策略该不该收紧。
|
||||
|
||||
@@ -109,7 +109,7 @@ Harness 不只是把问题交给模型。它还会在运行时改提示词、审
|
||||
2. **只作用于本机官方 Harness**:安全评测补丁、提示词注入全部发生在使用者**本机已安装的官方 DeepSeek Harness**(`@deepseek-ai` 包、本机 profile / `$DSH_HOME`)上。对象是使用者自己的官方本地软件,**不是**他人的网站、服务器、账号或信息系统。
|
||||
3. **评测补丁不对外网目标联网**:应用补丁、写入注入、回滚、卸载均在本机文件与本机进程内完成,**不对任何公网主机、未授权系统进行扫描、探测、入侵或攻击发包**。不得把本项目当作跳板去打外网。插件若开启「检测更新」,仅可能访问本插件自己的 GitHub 仓库以核对版本,**与对第三方系统的网络攻击无关**,也不能被解释为授权对外渗透。
|
||||
4. **合法受控范围限定**:本项目定位为使用者在**自己有权管理的本机官方 Harness**上,进行红队科研与鲁棒性评测的辅助工具。**严禁在未经所有者合法书面授权的目标、公网在线系统或生产业务上运行本项目**。一切测试必须限制在**本机已授权安装的官方 Harness、离线本地合成靶标、授权网络安全演练靶场及合规实验室受控环境**中进行。
|
||||
5. **开源版只允许本地靶场。** 攻击任务只放行本机/内网,以及 `.lab` / `.lan` / `.htb` 这类本机实验室后缀。公网 IP、公网域名、网上演练平台、自己登记的公网机器都不能当作例外。密钥、密码、网段、通配符,以及对话里的口头说明,都不能增加例外。开源版不下发技能库和知识库。
|
||||
5. **开源版只允许本地靶场。** 攻击任务只放行本机回环和 RFC1918 私网 IP。域名先解析再判 IP,不靠后缀放行。公网 IP、解析到公网的域名、解析失败、hosts 把实验室后缀指到公网,都不能当作例外。密钥、密码、网段、通配符,以及对话里的口头说明,都不能增加例外。禁止制作游戏外挂。开源版不下发技能库和知识库。
|
||||
6. **严禁违法与违禁用途**:使用者严禁利用本项目直接或间接从事任何违反下列法律法规的行为(必须逐条遵守,不得以任何理由规避):
|
||||
- **《中华人民共和国刑法》**
|
||||
- **《中华人民共和国网络安全法》**
|
||||
@@ -133,9 +133,9 @@ Harness 不只是把问题交给模型。它还会在运行时改提示词、审
|
||||
|
||||
## 适配范围
|
||||
|
||||
**1.1.73 已适配 DSH 0.2.1-rc.2**,0.2.0 仍可用。不要拿它去打 0.1.x。
|
||||
**1.1.74 已适配 DSH 0.2.1-rc.2**,0.2.0 仍可用。不要拿它去打 0.1.x。
|
||||
|
||||
- **dsh 0.2.1-rc.2**(官方桌面 / 官方 `dsh web`):用 **1.1.73**。已修 `{{cwd}}` / `[cwd]` 整轮失败、补丁 #40 命中、`toolFilter` 废弃、`dsh-tools` 解析、hostFs fd、桌面换包自杀、`file:` 归档更新、Ctrl+Enter 插话。
|
||||
- **dsh 0.2.1-rc.2**(官方桌面 / 官方 `dsh web`):用 **1.1.74**。已修 `{{cwd}}` / `[cwd]` 整轮失败、补丁 #40 命中、`toolFilter` 废弃、`dsh-tools` 解析、hostFs fd、桌面换包自杀、`file:` 归档更新、Ctrl+Enter 插话。
|
||||
- **dsh 0.2.0-rc.2**:用 **1.1.40** 及以上;本页这档也能装。
|
||||
- **dsh 0.1.7**(含 rc.1 / rc.2):用 **1.1.39** 及更早 —— 在 [Releases](https://github.com/YuJunZhiXue/dsh-purge/releases) 里选对应标签。
|
||||
|
||||
@@ -157,7 +157,7 @@ Harness 不只是把问题交给模型。它还会在运行时改提示词、审
|
||||
桌面客户端也可以点按钮(`dsh://` 唤起):
|
||||
|
||||
<p align="center">
|
||||
<a href="dsh://plugin/install?id=dsh-purge&name=dsh-purge&version=1.1.73&repo=YuJunZhiXue%2Fdsh-purge&permissions=%E7%B3%BB%E7%BB%9F%E6%8F%90%E7%A4%BA%E8%AF%8D%E6%B3%A8%E5%85%A5%2C%E6%9C%AC%E6%9C%BA%E8%A1%A5%E4%B8%81%2C%E8%AE%BE%E7%BD%AE%E9%A1%B5&downloadUrl=https%3A%2F%2Fgithub.com%2FYuJunZhiXue%2Fdsh-purge%2Farchive%2Frefs%2Fheads%2Fmaster.tar.gz"><strong>唤起客户端一键安装</strong></a>
|
||||
<a href="dsh://plugin/install?id=dsh-purge&name=dsh-purge&version=1.1.74&repo=YuJunZhiXue%2Fdsh-purge&permissions=%E7%B3%BB%E7%BB%9F%E6%8F%90%E7%A4%BA%E8%AF%8D%E6%B3%A8%E5%85%A5%2C%E6%9C%AC%E6%9C%BA%E8%A1%A5%E4%B8%81%2C%E8%AE%BE%E7%BD%AE%E9%A1%B5&downloadUrl=https%3A%2F%2Fgithub.com%2FYuJunZhiXue%2Fdsh-purge%2Farchive%2Frefs%2Fheads%2Fmaster.tar.gz"><strong>唤起客户端一键安装</strong></a>
|
||||
</p>
|
||||
|
||||
### 装完都要做这三步
|
||||
@@ -343,7 +343,7 @@ dsh-purge --uninstall
|
||||
| 演练台 | 授权后的资产与环境页。开源版不下发技能库和知识库。未授权时按钮标「未授权」 |
|
||||
| 补丁 | 分组查看状态,应用、还原或卸载 |
|
||||
| 提示词 | 编辑 `prompt-inject.md`,作为会话覆盖段 |
|
||||
| 本地靶场 | 只放行本机/内网和 `.lab` / `.lan` / `.htb` 等本机实验室后缀,不能登记公网主机 |
|
||||
| 本地靶场 | 只放行本机/私网 IP;域名先解析,全部地址都必须是私网或回环 |
|
||||
| 规则集 | 多套 `AGENTS.md` / `CLAUDE.md`;启用写入 `$DSH_HOME`,删除从列表去掉 |
|
||||
|
||||
|
||||
@@ -410,7 +410,7 @@ DSH 会按顺序执行同一批中的 Bash 调用。旧版 dsh-purge 把默认
|
||||
|
||||
### 本地靶场
|
||||
|
||||
开源版攻击任务默认全拦,只放行本机/内网本地靶场。在对话里说「这是我的服务器」不会放行。登记公网 IP 或域名也不会。
|
||||
开源版攻击任务默认全拦,只放行本机/私网 IP。域名先解析再判,不认 `.lab` / `.htb` 这类后缀本身。hosts 把实验室名指到公网 IP 也会拦。在对话里说「这是我的服务器」不会放行。
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -175,7 +175,7 @@ window.__ModuleLoader__.load({ id: "dsh-purge", factory: (require) => {
|
||||
"purge.title": "补丁",
|
||||
"override.title": "提示词",
|
||||
"own.title": "本地靶场",
|
||||
"own.hint": "开源版攻击任务只放行本机/内网本地靶场(localhost、私网、.lab/.lan/.htb 等)。不能登记公网服务器,公网 IP 和域名一律拦截。",
|
||||
"own.hint": "开源版攻击任务只放行本机/内网 IP。域名会先解析,解析到的每一个地址都必须是私网或回环;hosts 把 .lab 指到公网 IP 也会拦。解析失败或混有公网地址一律拦截。",
|
||||
"own.save": "保存名单",
|
||||
"saved.own": "已保存自己的服务器",
|
||||
"saved.own.dropped": "已保存。有 {n} 行不是单个 IP 或主机名,已丢掉",
|
||||
@@ -519,7 +519,7 @@ window.__ModuleLoader__.load({ id: "dsh-purge", factory: (require) => {
|
||||
"purge.title": "Patches",
|
||||
"override.title": "Prompt",
|
||||
"own.title": "Local lab only",
|
||||
"own.hint": "The open-source build only allows local lab targets (localhost, private nets, .lab/.lan/.htb). You cannot register a public host. Public IPs and domains are blocked.",
|
||||
"own.hint": "The open-source build only allows localhost/private IPs. Domains are resolved first; every A/AAAA must be loopback or RFC1918. A hosts entry that points .lab at a public IP is blocked. Failed or mixed public answers are denied.",
|
||||
"own.save": "Save list",
|
||||
"saved.own": "Own servers saved",
|
||||
"saved.own.dropped": "Saved. {n} lines were not a single IP or hostname and were dropped",
|
||||
|
||||
+102
-64
@@ -1,6 +1,7 @@
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import { randomUUID } from "node:crypto";
|
||||
import dns from "node:dns/promises";
|
||||
import { findDshHome } from "./core.js";
|
||||
|
||||
const SUFFIXES = [
|
||||
@@ -183,37 +184,57 @@ function bankHit(name) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 开源版只认本地靶场:本机/内网,以及本机实验室后缀。公网平台和自建公网主机一律拦。
|
||||
const RANGE_SUFFIXES = [
|
||||
".htb",
|
||||
".thm",
|
||||
".lab",
|
||||
".lan",
|
||||
".internal",
|
||||
".test",
|
||||
".home.arpa",
|
||||
];
|
||||
const LOOKUP_MS = 2000;
|
||||
const LOOKUP_TTL_MS = 5000;
|
||||
const lookupCache = new Map();
|
||||
|
||||
const RANGE_HOSTS = new Set([
|
||||
"host.docker.internal",
|
||||
"gateway.docker.internal",
|
||||
"kubernetes.docker.internal",
|
||||
]);
|
||||
|
||||
function rangeHit(name) {
|
||||
if (!name || typeof name !== "string") return false;
|
||||
if (RANGE_HOSTS.has(name)) return true;
|
||||
for (const suffix of RANGE_SUFFIXES) {
|
||||
if (name === suffix.slice(1) || name.endsWith(suffix)) return true;
|
||||
}
|
||||
let dot = name.indexOf(".");
|
||||
while (dot !== -1) {
|
||||
if (RANGE_HOSTS.has(name.slice(dot + 1))) return true;
|
||||
dot = name.indexOf(".", dot + 1);
|
||||
}
|
||||
function isLocalLabV4(value) {
|
||||
const a = value >>> 24;
|
||||
const b = (value >>> 16) & 255;
|
||||
if (a === 10 || a === 127) return true;
|
||||
if (a === 172 && b >= 16 && b <= 31) return true;
|
||||
if (a === 192 && b === 168) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
function isLocalLabAddress(addr) {
|
||||
const name = hostOf(addr);
|
||||
if (!name) return false;
|
||||
if (name.includes(":")) {
|
||||
const value = parseIpv6(name);
|
||||
if (value == null) return false;
|
||||
if ((value >> 32n) === 0xffffn) return isLocalLabV4(Number(value & 0xffffffffn) >>> 0);
|
||||
if (value === 0n || value === 1n) return true;
|
||||
if ((value >> 118n) === 0x3fan) return true;
|
||||
if ((value >> 121n) === 0x7en) return true;
|
||||
return false;
|
||||
}
|
||||
const value = ipv4ToInt(name);
|
||||
return value != null && isLocalLabV4(value);
|
||||
}
|
||||
|
||||
async function lookupIps(name) {
|
||||
const key = String(name || "").toLowerCase();
|
||||
const cached = lookupCache.get(key);
|
||||
if (cached && cached.at > Date.now() - LOOKUP_TTL_MS) return cached.ips;
|
||||
let ips = [];
|
||||
try {
|
||||
const rows = await Promise.race([
|
||||
dns.lookup(key, { all: true, verbatim: true }),
|
||||
new Promise((_, reject) => {
|
||||
const timer = setTimeout(() => reject(new Error("lookup-timeout")), LOOKUP_MS);
|
||||
if (typeof timer.unref === "function") timer.unref();
|
||||
}),
|
||||
]);
|
||||
ips = [...new Set((Array.isArray(rows) ? rows : [rows]).map((row) => row && row.address).filter(Boolean))];
|
||||
} catch {
|
||||
ips = [];
|
||||
}
|
||||
lookupCache.set(key, { at: Date.now(), ips });
|
||||
if (lookupCache.size > 256) lookupCache.delete(lookupCache.keys().next().value);
|
||||
return ips;
|
||||
}
|
||||
|
||||
const DENIAL = "不行,这是严令禁止的";
|
||||
|
||||
// 渗透(?!测试):「渗透测试 / IP 与渗透测试」不是攻击任务(#73)。
|
||||
@@ -222,6 +243,14 @@ const DENIAL = "不行,这是严令禁止的";
|
||||
const ATTACK =
|
||||
/渗透(?!测试)|打穿|打下|打站|入侵|拿壳|拿权限|爆破|提权|webshell|getshell|端口扫描|pentest|\bexploit\b(?![-a-z0-9])|\bbreach\b|\bpwn\b|(?<!防御)攻击(?!面)|(?<!surface\s)\battack\b(?!\s+surface)/i;
|
||||
|
||||
// 外挂硬拦。单字「辅助 / 透视」太容易误伤辅助函数、透视投影,必须带游戏或挂本身。
|
||||
const CHEAT_STRONG =
|
||||
/外挂|游戏辅助|自瞄|自动瞄准|无后座|无限弹药|人物透视|物品透视|透视挂|开透视|加速挂|飞天挂|瞬移挂|锁头|压枪挂|改血|过反作弊|注入游戏|aimbot|wallhack|triggerbot|spinbot|silent\s*aim|game\s*cheat|anti-?cheat|cheat\s*engine/i;
|
||||
const CHEAT_GAME =
|
||||
/游戏|网游|端游|手游|\bgame\b|steam|csgo|\bcs2\b|pubg|valorant|和平精英|王者荣耀|原神/i;
|
||||
const CHEAT_WEAK =
|
||||
/内存修改|读内存|写内存|dll注入/i;
|
||||
|
||||
// ReDoS 保险:ATTACK 含零宽环视,整段消息(贴代码/日志)超过 100KB 时正则回溯会把事件循环卡死。
|
||||
// 真实攻击意图通常在前几千字符,100KB cap 不会误放过。
|
||||
const ATTACK_SCAN_CAP = 100 * 1024;
|
||||
@@ -242,17 +271,6 @@ function ipv4ToInt(ip) {
|
||||
return value >>> 0;
|
||||
}
|
||||
|
||||
function isSkippedV4(value) {
|
||||
const a = value >>> 24;
|
||||
const b = (value >>> 16) & 255;
|
||||
if (a === 0 || a === 10 || a === 127) return true;
|
||||
if (a === 169 && b === 254) return true;
|
||||
if (a === 172 && b >= 16 && b <= 31) return true;
|
||||
if (a === 192 && b === 168) return true;
|
||||
if (a >= 224) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
function parseIpv6(input) {
|
||||
let text = String(input || "").trim().toLowerCase().split("%")[0];
|
||||
if (!text) return null;
|
||||
@@ -329,14 +347,24 @@ function collectFromText(text, hosts) {
|
||||
const sample = String(text || "").slice(0, 32768);
|
||||
const url = /\b(?:[a-z][a-z0-9+.-]*:\/\/)([^/?#\s]+)/gi;
|
||||
for (const match of sample.matchAll(url)) addHost(match[1], hosts);
|
||||
const mapped = [];
|
||||
const mappedRe = /(?:[0-9a-f]{0,4}:){1,6}ffff:(?:(?:25[0-5]|2[0-4]\d|1?\d?\d)\.){3}(?:25[0-5]|2[0-4]\d|1?\d?\d)/gi;
|
||||
for (const match of sample.matchAll(mappedRe)) {
|
||||
const value = match[0].toLowerCase();
|
||||
hosts.add(value);
|
||||
mapped.push({ start: match.index, end: match.index + match[0].length });
|
||||
}
|
||||
const covered = (index, length) => mapped.some((span) => index >= span.start && index + length <= span.end);
|
||||
const ipv4 = /\b(?:(?:25[0-5]|2[0-4]\d|1?\d?\d)\.){3}(?:25[0-5]|2[0-4]\d|1?\d?\d)\b/g;
|
||||
for (const match of sample.matchAll(ipv4)) hosts.add(match[0]);
|
||||
// 加 lookbehind/lookahead 排除 HH:MM:SS 之类纯十进制时间串,避免误报为 IPv6。
|
||||
for (const match of sample.matchAll(ipv4)) {
|
||||
if (covered(match.index, match[0].length)) continue;
|
||||
hosts.add(match[0]);
|
||||
}
|
||||
const ipv6 = /(?<![\d:])(?:[0-9a-f]{0,4}:){2,7}[0-9a-f]{0,4}(?![\d])/gi;
|
||||
for (const match of sample.matchAll(ipv6)) {
|
||||
const value = match[0];
|
||||
// 二次兜底:若整段只有十进制 + 冒号(无 a-f),拒绝
|
||||
if (/^[\d:]+$/.test(value)) continue;
|
||||
if (covered(match.index, value.length)) continue;
|
||||
hosts.add(value);
|
||||
}
|
||||
const domain = /\b(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z]{2,63}\b/gi;
|
||||
@@ -345,6 +373,7 @@ function collectFromText(text, hosts) {
|
||||
if (!keepBareDomain(sample, match.index, name)) continue;
|
||||
hosts.add(name);
|
||||
}
|
||||
if (/\blocalhost\b/i.test(sample)) hosts.add("localhost");
|
||||
}
|
||||
|
||||
const HOST_NAME = /^(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z]{2,63}$/;
|
||||
@@ -409,13 +438,9 @@ export function readAllowText(dshHome = findDshHome()) {
|
||||
}
|
||||
}
|
||||
|
||||
export async function writeAllowText(dshHome, text) {
|
||||
const normalized = normalizeAllowText(text);
|
||||
const fp = allowFilePath(dshHome);
|
||||
await fs.promises.mkdir(path.dirname(fp), { recursive: true });
|
||||
await fs.promises.writeFile(fp, normalized.text, "utf8");
|
||||
export async function writeAllowText() {
|
||||
allowCache = { path: "", mtime: -1, exact: new Set(), ips: null, at: 0 };
|
||||
return normalized;
|
||||
return { text: "", dropped: 0, hosts: [] };
|
||||
}
|
||||
|
||||
let allowCache = { path: "", mtime: -1, exact: new Set(), ips: null, at: 0 };
|
||||
@@ -449,17 +474,8 @@ function permittedHost() {
|
||||
function isOwnNetwork(host) {
|
||||
const name = hostOf(host);
|
||||
if (!name) return false;
|
||||
if (name === "localhost" || name.endsWith(".localhost") || name.endsWith(".local")) return true;
|
||||
if (name.includes(":")) {
|
||||
const value = parseIpv6(name);
|
||||
if (value == null) return false;
|
||||
if (value === 0n || value === 1n) return true;
|
||||
if ((value >> 118n) === 0x3fan) return true;
|
||||
if ((value >> 121n) === 0x7en) return true;
|
||||
return false;
|
||||
}
|
||||
const value = ipv4ToInt(name);
|
||||
return value != null && isSkippedV4(value);
|
||||
if (name === "localhost" || name.endsWith(".localhost")) return true;
|
||||
return isLocalLabAddress(name);
|
||||
}
|
||||
|
||||
function isIp(host) {
|
||||
@@ -483,6 +499,13 @@ export function isAttackTask(text) {
|
||||
return ATTACK.test(sample.length > ATTACK_SCAN_CAP ? sample.slice(0, ATTACK_SCAN_CAP) : sample);
|
||||
}
|
||||
|
||||
export function isCheatTask(text) {
|
||||
const sample = String(text || "");
|
||||
const cap = sample.length > ATTACK_SCAN_CAP ? sample.slice(0, ATTACK_SCAN_CAP) : sample;
|
||||
if (CHEAT_STRONG.test(cap)) return true;
|
||||
return CHEAT_GAME.test(cap) && CHEAT_WEAK.test(cap);
|
||||
}
|
||||
|
||||
function hostsInTask(text) {
|
||||
const hosts = new Set();
|
||||
const sample = String(text || "").slice(0, 32768);
|
||||
@@ -496,16 +519,29 @@ function hostsInTask(text) {
|
||||
return hosts;
|
||||
}
|
||||
|
||||
function isRangeTarget(name) {
|
||||
return isOwnNetwork(name) || rangeHit(name);
|
||||
/**
|
||||
* 本地靶场只认解析结果。后缀(.lab / .htb)本身不放行。
|
||||
* 走系统解析(含 hosts):所有 A/AAAA 都必须是本机/私网,有一条公网或解析失败就拦。
|
||||
*/
|
||||
async function isRangeTarget(name) {
|
||||
if (!name) return false;
|
||||
if (name === "localhost" || name.endsWith(".localhost")) return true;
|
||||
if (isIp(name)) return isLocalLabAddress(name);
|
||||
const ips = await lookupIps(name);
|
||||
if (!ips.length) return false;
|
||||
return ips.every((ip) => isLocalLabAddress(ip));
|
||||
}
|
||||
|
||||
export async function taskTargetHit(text) {
|
||||
if (!isAttackTask(text)) return null;
|
||||
const names = [];
|
||||
for (const host of hostsInTask(text)) {
|
||||
const name = hostOf(host);
|
||||
if (!name) continue;
|
||||
if (isRangeTarget(name)) continue;
|
||||
if (name) names.push(name);
|
||||
}
|
||||
if (!names.length) return taskHit("unspecified", "domain");
|
||||
for (const name of names) {
|
||||
if (await isRangeTarget(name)) continue;
|
||||
return taskHit(name, isIp(name) ? "ip" : bankHit(name) ? "bank" : "domain");
|
||||
}
|
||||
return null;
|
||||
@@ -668,8 +704,10 @@ export function installRegionGate(ctx) {
|
||||
let hit = null;
|
||||
try {
|
||||
const task = currentTaskText(payload?.messages);
|
||||
if (!task || !isAttackTask(task)) return forward();
|
||||
hit = await taskTargetHit(task);
|
||||
if (!task) return forward();
|
||||
if (isCheatTask(task)) hit = taskHit("cheat", "cheat");
|
||||
else if (isAttackTask(task)) hit = await taskTargetHit(task);
|
||||
else return forward();
|
||||
} catch {
|
||||
return forward();
|
||||
}
|
||||
|
||||
+38
-3
@@ -191,6 +191,36 @@ function needsCompositionRepair(presetFile) {
|
||||
}
|
||||
}
|
||||
|
||||
/** 0.2.1 已废弃 toolFilter:旧用户预设里还留着就会让红队模式整份加载失败。 */
|
||||
function stripToolFilter(text) {
|
||||
const lines = String(text || '').split(/\r?\n/)
|
||||
const out = []
|
||||
let skipIndent = null
|
||||
let changed = false
|
||||
for (const line of lines) {
|
||||
if (skipIndent !== null) {
|
||||
const indent = (/^(\s*)/.exec(line) || ['', ''])[1].length
|
||||
if (line.trim() !== '' && indent > skipIndent) {
|
||||
changed = true
|
||||
continue
|
||||
}
|
||||
skipIndent = null
|
||||
}
|
||||
const block = /^(\s*)toolFilter:\s*(?:#.*)?$/.exec(line)
|
||||
if (block) {
|
||||
skipIndent = block[1].length
|
||||
changed = true
|
||||
continue
|
||||
}
|
||||
if (/^\s*toolFilter:\s+\S/.test(line)) {
|
||||
changed = true
|
||||
continue
|
||||
}
|
||||
out.push(line)
|
||||
}
|
||||
return { text: out.join('\n'), changed }
|
||||
}
|
||||
|
||||
/** 从独立红队包迁进 dsh-purge 后,预设里的工具行包名要跟着改。 */
|
||||
function renderToolsPackage(text) {
|
||||
if (!text.includes('dsh-redteam-mode/tools')) {
|
||||
@@ -368,9 +398,10 @@ export function installPreset(options = {}) {
|
||||
}
|
||||
const rendered = renderSkillsDir(text)
|
||||
const tools = renderToolsPackage(rendered.text)
|
||||
const delegation = repairDelegation(tools.text)
|
||||
const filter = stripToolFilter(tools.text)
|
||||
const delegation = repairDelegation(filter.text)
|
||||
const next = delegation.text
|
||||
if (rendered.changed || tools.changed || delegation.changed) {
|
||||
if (rendered.changed || tools.changed || filter.changed || delegation.changed) {
|
||||
writeFileSync(presetFile, next.replace(/\r\n/g, '\n').replace(/\r/g, '\n'), 'utf8')
|
||||
log(
|
||||
(rendered.changed
|
||||
@@ -380,8 +411,11 @@ export function installPreset(options = {}) {
|
||||
+ ',已改为 dshHomePath(\'redteam/skills\')'
|
||||
: '')
|
||||
+ (tools.changed ? (rendered.changed ? ';' : '') + '工具包名已改为 dsh-purge/redteam/tools' : '')
|
||||
+ (filter.changed
|
||||
? ((rendered.changed || tools.changed) ? ';' : '') + '已去掉 0.2.1 废弃的 toolFilter'
|
||||
: '')
|
||||
+ (delegation.changed
|
||||
? ((rendered.changed || tools.changed) ? ';' : '') + '已修复指挥派活约束 / 重新启用 subagent'
|
||||
? ((rendered.changed || tools.changed || filter.changed) ? ';' : '') + '已修复指挥派活约束 / 重新启用 subagent'
|
||||
: ''),
|
||||
)
|
||||
}
|
||||
@@ -392,6 +426,7 @@ export function installPreset(options = {}) {
|
||||
const repaired = [
|
||||
rendered.changed ? rendered.reason : null,
|
||||
tools.changed ? 'tools-package' : null,
|
||||
filter.changed ? 'toolFilter' : null,
|
||||
delegation.changed ? 'delegation' : null,
|
||||
anchor === 'inserted' ? 'anchor-gate' : null,
|
||||
anchor === 'updated' ? 'anchor-script' : null,
|
||||
|
||||
+35
-6
@@ -99,7 +99,36 @@ function loadDefineTool() {
|
||||
throw new Error('dsh-purge/redteam/tools: cannot resolve @deepseek-ai/dsh-tools from host')
|
||||
}
|
||||
|
||||
const defineTool = loadDefineTool()
|
||||
const defineToolRaw = loadDefineTool()
|
||||
|
||||
/** 0.2.1:任何 type=object 都必须显式 additionalProperties,否则整份红队预设加载失败。 */
|
||||
function sealObjectSchemas(node) {
|
||||
if (!node || typeof node !== 'object') return node
|
||||
if (Array.isArray(node)) {
|
||||
for (const item of node) sealObjectSchemas(item)
|
||||
return node
|
||||
}
|
||||
if (node.type === 'object' && node.additionalProperties === undefined) {
|
||||
node.additionalProperties = node.properties ? false : true
|
||||
}
|
||||
if (node.properties) {
|
||||
for (const key of Object.keys(node.properties)) sealObjectSchemas(node.properties[key])
|
||||
}
|
||||
if (node.items) sealObjectSchemas(node.items)
|
||||
if (node.additionalProperties && typeof node.additionalProperties === 'object') {
|
||||
sealObjectSchemas(node.additionalProperties)
|
||||
}
|
||||
return node
|
||||
}
|
||||
|
||||
function defineTool(spec) {
|
||||
if (spec && spec.parameters) sealObjectSchemas(spec.parameters)
|
||||
const tool = defineToolRaw(spec)
|
||||
if (tool && tool.parameters) sealObjectSchemas(tool.parameters)
|
||||
if (tool && tool.inputSchema) sealObjectSchemas(tool.inputSchema)
|
||||
if (tool && tool.schema) sealObjectSchemas(tool.schema)
|
||||
return tool
|
||||
}
|
||||
|
||||
/** Cordis 插件名。 */
|
||||
export const name = 'dsh-purge-redteam-tools'
|
||||
@@ -2057,8 +2086,8 @@ export function apply(ctx) {
|
||||
parameters: {
|
||||
engagement: { type: 'string' },
|
||||
operation: { type: 'string', required: true, description: '操作名,如 "nmap_scan"、"webshell_established"、"sql_injection_confirmed"' },
|
||||
parameters: { type: 'object', description: '调用参数(JSON 对象,会参与哈希)' },
|
||||
result: { type: 'object', required: true, description: '规范化结果(JSON 对象,会参与哈希)' },
|
||||
parameters: { type: 'object', additionalProperties: true, description: '调用参数(JSON 对象,会参与哈希)' },
|
||||
result: { type: 'object', additionalProperties: true, required: true, description: '规范化结果(JSON 对象,会参与哈希)' },
|
||||
confidence: { type: 'string', description: 'claimed | observed | derived | inferred,默认 observed' },
|
||||
authority: { type: 'string', description: 'tool-output | database-record | screenshot | request-replay | subagent-report | operator-input,默认 tool-output' },
|
||||
limitations: { type: 'array', items: { type: 'string' }, description: '局限性说明,如 ["只扫了 Top1000 端口"]' },
|
||||
@@ -2090,8 +2119,8 @@ export function apply(ctx) {
|
||||
parameters: {
|
||||
engagement: { type: 'string' },
|
||||
operation: { type: 'string', required: true },
|
||||
parameters: { type: 'object' },
|
||||
result: { type: 'object', required: true },
|
||||
parameters: { type: 'object', additionalProperties: true },
|
||||
result: { type: 'object', additionalProperties: true, required: true },
|
||||
confidence: { type: 'string' },
|
||||
authority: { type: 'string' },
|
||||
limitations: { type: 'array', items: { type: 'string' } },
|
||||
@@ -2119,7 +2148,7 @@ export function apply(ctx) {
|
||||
parameters: {
|
||||
engagement: { type: 'string' },
|
||||
claimed_ev_id: { type: 'string', required: true, description: '要升级的证据 ID' },
|
||||
verified_result: { type: 'object', description: '亲自验证后的实际结果' },
|
||||
verified_result: { type: 'object', additionalProperties: true, description: '亲自验证后的实际结果' },
|
||||
verified_by: { type: 'string', description: '谁核实的,默认 coordinator' },
|
||||
},
|
||||
output: { schema: { type: 'string' }, render: (_args, value) => text(value) },
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "dsh-purge",
|
||||
"version": "1.1.73",
|
||||
"version": "1.1.74",
|
||||
"description": "DeepSeek Harness 破甲:让所有模型都能破甲,不同模型可换不同提示词;默认提示词面向国模「小码酱」。Jailbreak for every model — swap prompts per model. 求 Star 收藏 ⭐ 如要二开,请查看署名要求部分",
|
||||
"type": "module",
|
||||
"main": "lib/index.js",
|
||||
|
||||
@@ -1,3 +1,23 @@
|
||||
# 1.1.74
|
||||
|
||||
## 中文
|
||||
|
||||
- 版本 **1.1.74**,优化若干拦截与加载 bug。适配 DSH **0.2.1-rc.2**(0.2.0 仍可用)。
|
||||
- 修靶场门禁:域名先解析再判 IP,不再靠 `.lab` / `.htb` 后缀放行;`hosts` 指到公网、解析失败、混有公网,一律拦。
|
||||
- 修身份绕过:`169.254` 云元数据不再当靶场;`::ffff:公网` 拆开再判;攻击句不写目标不再放行。
|
||||
- 修 DSH 0.2.1 预设加载:对象 schema 补 `additionalProperties`,装过的 redteam 预设清掉残留 `toolFilter`。
|
||||
- 修演练台被改成英文:中文页签收回。
|
||||
- 禁止制作外挂:会话门口硬拦,提示词 Rule 1 改为禁止。
|
||||
|
||||
## English
|
||||
|
||||
- **1.1.74**, bug-fix release. Target DSH **0.2.1-rc.2** (0.2.0 still works).
|
||||
- Lab gate: resolve first, then allow only private IPs. Suffixes are not an allow list.
|
||||
- Close identity holes: drop link-local metadata, unwrap IPv4-mapped IPv6, deny unnamed attack tasks.
|
||||
- DSH 0.2.1 preset load: seal object schemas; strip leftover `toolFilter`.
|
||||
- Restore Chinese drill-console tabs.
|
||||
- Game cheats are forbidden at the session gate.
|
||||
|
||||
# 1.1.73
|
||||
|
||||
## 中文
|
||||
|
||||
Reference in new issue
Block a user