Back to skill

Security audit

Bat Ps1 Dev Publish

Security checks across malware telemetry and agentic risk

Overview

This is a Markdown-only scripting reference, but it contains detailed recipes for persistence, self-protection, process termination, and system changes that merit Review before installation.

Install only if you specifically want a defensive Windows/PowerShell security-tool cookbook. Review generated scripts before running them, require explicit user approval for startup persistence, firewall/hosts edits, service or driver changes, self-protection, and deletion/quarantine actions, and consider disabling automatic skill self-updates unless you intentionally want the skill to persist new lessons.

SkillSpector

By NVIDIA
Vulnerability Patterns
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Tool MisuseTool Parameter Abuse, Chaining Abuse, Unsafe Defaults
  • Rogue AgentSelf-Modification, Session Persistence
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
Findings (5)

Context-Inappropriate Capability

Medium
Confidence
92% confidence
Finding
This section goes well beyond generic batch/PowerShell development guidance and documents defensive security-tool behaviors such as process/file monitoring, anti-tamper logic, and threat-response workflows. Even if framed as defensive engineering, publishing reusable implementation details for endpoint monitoring and counteraction can be repurposed by malware authors to harden malicious tooling and evade interruption.

Context-Inappropriate Capability

High
Confidence
98% confidence
Finding
This portion explicitly documents persistence and self-protection techniques, including registry Run-key startup, watchdog behavior, DACL protection, and related anti-termination patterns. Those are dual-use tradecraft elements commonly used by malware for persistence and resilience, so embedding them in a broadly scoped 'script dev' skill materially increases misuse risk.

Session Persistence

Medium
Category
Rogue Agent
Content
**场景**: 给第三方 GUI 程序(安装路径含空格, 如 `%LOCALAPPDATA%\Programs\<应用>\<名称 app>.exe`)写"开机启动管理"bat 工具(菜单: 添加/取消/查状态)。

- **A. Run 键值必须"自带引号"落盘(核心坑)**: `reg add "%KEY%" /v Name /t REG_SZ /d "%APP_PATH%" /f` 只保证 bat/cmd 解析层不炸, **写进注册表的值没有引号**——登录时 Explorer 执行 Run 键值按空格切分, 空格后的部分被当参数 → 启动失败或弹"找不到文件"。正确写法 **`/d "\"%APP_PATH%\""`**: `\"` 经 cmd 解析 + `CommandLineToArgvW` 双层处理后以**字面引号**落盘, 最终值为 `"C:\...\my app.exe"`(整体带引号)。可用 `reg query` 回读验证值首尾确有引号。
- **B. 注册表 HKCU Run 优于启动文件夹**: 启动文件夹放 bat 每次登录闪 conhost 黑框; **Run 键直接指向 exe 无窗口**。且 HKCU 当前用户可写**无需管理员权限**(HKLM 才需要), 工具通用性最好。若目标软件自带"开机启动"官方设置则优先用官方的, 注册表方案作兜底/批量管理。
- **C. `set /p` 残留值(菜单循环隐患)**: `set /p` 在用户**直接回车(空输入)时不修改变量**, 上一轮输入残留 → 菜单 `goto menu` 循环里必须先 `set "choice="` 清空再 `set /p choice=`, 否则一次有效输入被永久复用(误触同一菜单项/死循环)。**交互变量每次读取前先清空是通用规则**。
- **D. Run 项存在性判断与取消**: `reg query "%KEY%" /v Name 2>nul` + `if errorlevel 1` 判断是否存在(普通行的 `2>nul` 无需转义; 仅 `for /f` 内才要 `2^>nul`); 取消用 `reg delete ... >nul 2>&1`, 对不存在的键也无害, 无需前置判断。
Confidence
96% confidence
Finding
This section provides actionable instructions for creating persistence via the HKCU Run registry key. Even though framed as startup management for legitimate software, registry autorun is a classic persistence mechanism used by malware, and a reusable recipe in a general-purpose skill substantially lowers the barrier to abuse.

Session Persistence

Medium
Category
Rogue Agent
Content
**脱敏**: 本条不承载机器路径/签名/密钥/账号; 示例路径用 `%LOCALAPPDATA%`/`%APP_PATH%` 范式泛指, 应用名以 `<应用>` 泛指。

更新日志(倒序):
- **v1.71.0 (2026-09-01)**:**新增「开机启动管理 bat」实战(§39)**:① **Run 键值必须"自带引号"落盘**: `reg add /d "%PATH%"` 只保证 cmd 层不炸, 注册表里存的值无引号, Run 键执行时带空格路径被截断 → 必须 `/d "\"%PATH%\""`(`\"` 双层解析后字面引号落盘, `reg query` 回读验证); ② **HKCU Run 优于启动文件夹**(直接指 exe 无黑框 + 无需管理员权限); ③ **`set /p` 空输入不修改变量**→菜单循环交互变量必须读取前 `set "var="` 清空, 防上一轮输入残留误触; ④ `reg query 2>nul + if errorlevel 1` 判存在性, `reg delete >nul 2>&1` 幂等取消; ⑤ §0.1 索引补 1 行 + 实战范围 §14-§38→§14-§39; ⑥ **版本链漂移修正**: frontmatter 停在 1.69.0 而日志已到 v1.70.0(v1.70.0 发布时漏 bump), 本次一并修正; ⑦ 脱敏: 不承载机器路径/签名/密钥/账号。
- **v1.70.0 (2026-08-29)**:**第三次双副本分叉合流——新增 Windows 桌面端 Flutter 适配两章**:用户侧副本(2026-08-28 迭代)新增两章, 原编号 §35/§36 与主线已发布 tag 链的 §35(转码幂等)/§36(合并工具箱)冲突, 合流重编号为 §37/§38, 用户侧原版本号 v1.68.0/v1.69.0 让位主线(以 ClawHub tag 链为准, §29 版本链漂移原则): ① **§37 Flutter 响应式双端**(原§35): 移动端 MethodChannel 独占功能在桌面端"静默不可用"(PlatformException 被 catch 降级空值)的识别与纯 Dart 适配——症状识别(页面能开但永远空)/排查法(grep MethodChannel 定位 service 层 + 两端入口清单对照, 复用 isSupported 守卫范本)/适配手法(目录定位 %LOCALAPPDATA%+前缀扫描兜底 / Directory 流式扫描 / ZipFileEncoder 流式打包 / UI 平台分流 / 图标 content:// 与本地路径正则判别)/教训(显式 pubspec 声明传递依赖 / 分支全隔离在 Platform.isX 后防 Android 回归); ② **§38 Windows 桌面端确定性漏洞审计与修复清单**(原§36): A MethodChannel 桌面静默降级三分法(桌面分支/隐藏/占位)、B zip 条目分隔符 replaceAll('\\','/')、C wmic→PowerShell CIM、D Java 加载器四连坑(argfile 引号包裹+JVM UTF-8+runInShell 恒 false+-javaagent 去预引号)、E WindowsApps 0字节 java 跳板过滤、F reg query 正则取数据段、G 服务器动态类型 tryParse+clamp、H substring 先判长(共享 safeDate10); ③ **§0.1 索引补 3 行**(桌面空数据/zip 嵌套丢失/中文路径 Java 挂), 实战章节范围 §14-§36→§14-§38; ④ **合流要点**: 主线的 §0.1 索引/§17 证伪引导/§28.1 撞脸提醒/双语 description 为用户侧副本所缺, 两侧互补无覆盖冲突(除编号); ⑤ 脱敏: 不承载机器路径/签名/密钥/账号。
- **v1.69.0 (2026-08-27)**:**新增「合并大工具箱方法论」实战 + 二次分叉副本合流**:① **新增 §36**(正文展开): 合并前置三步(备份原件→UTF-8 工作副本→**标签对照检查**: goto 目标/标签定义 comm -23 求差集唯一豁免 :eof, §29 goto 坑的主动预防版); **辅助转码 ps1 必须纯 ASCII**(PS 5.1 按 ANSI936 读无 BOM ps1, 中文注释致变量定义行被吞/变量 null); 合并原则尊重旧风格不强改(goto 标签段插入新引擎入口、缺引擎明确报错、choice /C 扩展同步
...[truncated 25 chars]
Confidence
95% confidence
Finding
The changelog reiterates the same persistence recipe and normalizes use of Run-key startup as a recommended pattern. Repetition in summary form makes the persistence mechanism more discoverable and reusable, increasing dual-use risk.

Tool Parameter Abuse

High
Category
Tool Misuse
Content
- **v1.6.0 (2026-08-17)**:§8/§5 新增辅助脚本审查与重构经验: ① **正则 `^(.*)$` 贪婪匹配会吞入行尾后缀** → 清单解析必须精确锚定可选后缀: `(.*?)(?:\s+\[[^\]]*\])?(?:\s*\|\s*原隔离区:\s*.*)?$` (防恢复落错文件名/回滚失败); ② **`"" | Out-File -Append` 默认 UTF-16, 后续 Add-Content 按 ANSI/UTF8 追加 → 日志中文乱码混排** → 首行必须显式 `-Encoding UTF8`; ③ 辅助脚本与主引擎的**路径回退必须一致** (Clear-Cache 的 LOCALAPPDATA 回退曾与引擎不同, 清不干净); ④ 多脚本复用的"交互序号选择"逻辑抽公共函数 `Get-Selection` (返回 @(-1) 表示取消), 收敛 8 处重复代码, 注意各处块文本细微差异(变量初始化位置/多行 all 分支/文案不同), 需逐处核对; ⑤ 大工程整块替换用**先 dump repr 对比再替换**, 别猜格式(曾因 LF/CRLF、尾随空格、变量初始化顺序差异匹配失败 3 次)。
- **v1.5.0 (2026-08-17)**:§7 新增自查方法论 + §2/§5 补坑: ① **多 agent 并行代码审查** + 逐个复验(不轻信结论, 用 grep/sed 验证每个发现) 是发现隐蔽 bug 的高效方式; ② **`foreach ($a in $args)` 循环内 `$_` 是空**(foreach 不设 `$_`, 只有 ForEach-Object 管道才设)→ 循环内必须用 `$a`(曾致 /threads=N 永不生效); ③ **cmd 里 `goto 未定义标签` 直接终止整个 bat** → 所有 goto 目标必须存在, 自查时 grep 全部 goto 与标签对比; ④ **SYSTEM 计划任务 cmd /c 拼接路径**: cmd 在双引号内仍展开 `%VAR%`, 必须先 `[Environment]::ExpandEnvironmentVariables` 并拒绝残留 `%` 的路径; ⑤ **可预测 /tmp 文件名 + symlink = root 任意文件写**: 写临时文件用 `[IO.File]::Open(path, CreateNew,...)` (O_EXCL 语义) 防符号链接; ⑥ `Move-Item` 等关键操作在全局 `SilentlyContinue` 下**必须显式 `-ErrorAction Stop` + Test-Path 复核**, 否则假成功; ⑦ 前缀匹配 `StartsWith($dir)` 必须补分隔符防 `FooEvil` 绕过; ⑧ 路径提取用 `(\S+)` 遇空格截断 → 改行末 `(.+)$`; ⑨ 关机守护按进程名 kill 会误杀系统/自身触发的合法 shutdown → **系统路径只记录不 kill**, 非系统路径才拦。
- **v1.4.4 (2026-08-17)**:§5 新增网络封锁实战经验: ① Windows 防火墙封禁: `New-NetFirewallRule -Direction Outbound -Action Block` 按 `-RemoteAddress`(IP) 或 `-Program`(进程路径), 需管理员; 查重用 `Get-NetFirewallRule -DisplayName`; ② Linux iptables: `iptables -C OUTPUT -d IP -j DROP` 查重(退出码0=已存在), `-A` 添加 `-D` 删除; **容器默认有 CAP_NET_ADMIN 可真实测试**, 但规则重启即失(未持久化, 工具定位是实时阻断); ③ Linux iptables 无法按进程过滤(需 owner/cgroup match), 进程路径封锁仅记录清单; ④ 规则名用 IP 转义(`-replace '[.:]','_'`)防重名, 进程规则用路径 MD5 前12位; ⑤ 封锁清单同样用「管道符分隔」+ 去重(查重 key 用目标值); ⑥ `/xxx` 管理模式的通用交互(查看清单→序号选择→解除)已复用第 4 处。
- **v1.4.3 (2026-08-17)**:§5 新增威胁锁定实战经验: ① **PowerShell 管道 0 对象不会触发 Set-Content** → 清空文件用 `Clear-Content`, 否则 `$lines | Set-Content` 空数组时文件保持原样(清
...[truncated 26 chars]
Confidence
88% confidence
Finding
This section contains instructions for using file immutability and permission changes as a 'threat lock' mechanism, including chattr +i and chmod-based locking. While presented as defensive containment, these controls are also commonly abused by malware to make files harder to remove or modify, making the content materially dual-use.

VirusTotal

VirusTotal findings are pending for this skill version.

View on VirusTotal

Static analysis

No suspicious patterns detected.