mirror of
https://github.com/YuJunZhiXue/dsh-purge.git
synced 2026-11-30 16:40:22 +08:00
fix: 全仓审计加固与死代码清理,版本 1.1.87
- 回滚/备份:空 bak 改名 .bad 跳过;升级刷新 bak 补上单数 marker 补丁;统一原子写 - 补丁命中:optional 命中不符记软失败;#42 插入型替换加探针防重复插入 - Windows:进程枚举改用 | 分隔 + UTF-8,修复中文路径换包不杀旧进程;换包失败拉起原版 - 安全:asar 解包防越界;红队路径校验 realpath 防空 symlink;更新仅 https;报告回放去换行注入 - 提示词钩子:停用后 rewriteFn 返回原装配文本并清理 assemble guard;缓存签名纳入红队/策略/override - 红队:listEngagements 默认不算统计;listVulns/报告支持 evidenceLimit - 子代理名额占位即时生效并回退;--apply 有失败项退出码 1 - 清理:删除 lib/mnemon-settings.js 及 13 处死代码/未使用 import;移除 test 目录与 test 脚本
This commit is contained in:
1 parent
71d3a55884
commit
f806b048ac
48 files changed
+890
-1652
No files matched your search
+39
-27
@@ -77,19 +77,40 @@ function rmTree(dir) {
|
||||
}
|
||||
}
|
||||
|
||||
function pidsForImage(image) {
|
||||
const out = execFileSync("tasklist", ["/FI", `IMAGENAME eq ${image}`, "/FO", "CSV", "/NH"], {
|
||||
encoding: "utf8",
|
||||
windowsHide: true,
|
||||
timeout: 8000,
|
||||
});
|
||||
/** 按安装根路径找进程,不按映像名:DSH NEXT / 改名版进程名不同,写死会误杀同名第三方。 */
|
||||
function listWindowsPids(exe) {
|
||||
if (!exe) return [];
|
||||
let out = "";
|
||||
try {
|
||||
out = execFileSync("powershell.exe", [
|
||||
"-NoProfile", "-NonInteractive", "-Command",
|
||||
// 用 '|' 分隔:PowerShell 单引号字符串不解释 `t,路径里也不允许 '|'。
|
||||
// 先统一输出编码:中文安装路径在 OEM 代码页下会被 execFileSync(utf8) 读成乱码。
|
||||
"[Console]::OutputEncoding = [System.Text.Encoding]::UTF8; " +
|
||||
"Get-CimInstance Win32_Process | Where-Object { $_.ExecutablePath } | ForEach-Object { $_.ProcessId.ToString() + '|' + $_.ExecutablePath }",
|
||||
], { encoding: "utf8", windowsHide: true, timeout: 10000 });
|
||||
} catch {
|
||||
return [];
|
||||
}
|
||||
const want = String(exe).toLowerCase().replace(/\\/g, "/");
|
||||
const root = want.slice(0, want.lastIndexOf("/"));
|
||||
const pids = [];
|
||||
for (const line of String(out || "").split(/\r?\n/)) {
|
||||
const cols = line.split(",");
|
||||
const pid = Number(String(cols[1] || "").replace(/"/g, "").trim());
|
||||
if (pid) pids.push(pid);
|
||||
const bar = line.indexOf("|");
|
||||
if (bar < 0) continue;
|
||||
const pid = Number(line.slice(0, bar).trim());
|
||||
const ep = line.slice(bar + 1).trim().toLowerCase().replace(/\\/g, "/");
|
||||
if (!pid || !ep) continue;
|
||||
if (ep === want || (root && ep.startsWith(`${root}/`))) pids.push(pid);
|
||||
}
|
||||
return pids;
|
||||
return [...new Set(pids)];
|
||||
}
|
||||
|
||||
function listDesktopPids(exe = info.execPath) {
|
||||
if (process.platform === "darwin") return listDarwinPids(exe);
|
||||
if (process.platform !== "win32") return listPosixPids(exe);
|
||||
// 助手自己若仍是 Electron 映像,绝不能进待杀名单(#133)。
|
||||
return listWindowsPids(exe).filter((pid) => pid !== process.pid);
|
||||
}
|
||||
|
||||
function darwinBundleOf(exe) {
|
||||
@@ -181,22 +202,6 @@ function listPosixPids(exe) {
|
||||
return [...new Set(pids)];
|
||||
}
|
||||
|
||||
function listDesktopPids(exe = info.execPath) {
|
||||
if (process.platform === "darwin") return listDarwinPids(exe);
|
||||
if (process.platform !== "win32") return listPosixPids(exe);
|
||||
const images = ["DeepSeek Harness.exe", "DSH Desktop.exe", "DSH NEXT.exe"];
|
||||
const pids = [];
|
||||
for (const image of images) {
|
||||
try {
|
||||
pids.push(...pidsForImage(image));
|
||||
} catch {
|
||||
// 该进程名不存在
|
||||
}
|
||||
}
|
||||
// 助手自己若仍是 Electron 映像,绝不能进待杀名单(#133)。
|
||||
return pids.filter((pid) => pid !== process.pid);
|
||||
}
|
||||
|
||||
function signalPids(pids, signal) {
|
||||
for (const pid of pids) {
|
||||
if (pid === process.pid) continue;
|
||||
@@ -462,7 +467,14 @@ if (info.respawn === false) {
|
||||
}
|
||||
|
||||
if (info.asar && !asarReleased) {
|
||||
log("asar still sealed; not relaunching");
|
||||
// 桌面端已经在上面的 killApp 分支被杀掉;这里直接退出就是"应用凭空消失"。
|
||||
// Windows 的 PS1 分支早已改成失败时拉起原版 + 留 rename-pending,这里对齐。
|
||||
try {
|
||||
fs.writeFileSync(`${info.asar}.rename-pending`, new Date().toISOString());
|
||||
} catch { /* 锁写不上也要先把用户拉回来 */ }
|
||||
log("asar still sealed; relaunching original app");
|
||||
relaunchDesktop();
|
||||
await sleep(400);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user