
Security News
The Hidden Blast Radius of the Axios Compromise
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.
output-obfuscator-plugin
Advanced tools
CLI 工具,用于混淆 JavaScript/TypeScript 文件中的 URL 字符串。
直接运行:
npx -y output-obfuscator-plugin@latest ./dist
在 package.json 的 scripts 中添加 postbuild 脚本,构建完成后自动执行混淆:
{
"scripts": {
"build": "vite build",
"postbuild": "npx -y output-obfuscator-plugin@latest ./dist"
}
}
提示:
-y参数让 npx 自动同意安装,适用于 CI/CD 环境(GitHub Actions、GitLab CI 等)。
在项目根目录创建 output_obfuscator.ts 或 output_obfuscator.js:
// output_obfuscator.ts
import type { CLIConfig } from 'output-obfuscator-plugin'
export default {
mode: 'simple',
extensions: ['.js'],
exclude: ['**/vendor/**'],
logLevel: 'info'
} satisfies CLIConfig
| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
mode | 'simple' | 'advanced' | 'simple' | 混淆模式 |
extensions | string[] | ['.js', '.ts', '.jsx', '.tsx'] | 处理的文件扩展名 |
exclude | string[] | ['**/node_modules/**'] | 排除的文件 Glob 模式 |
urlPattern | RegExp | 见下方 | URL 匹配正则 |
obfuscatorOptions | ObfuscatorOptions | - | Advanced 模式配置 |
logLevel | 'silent' | 'info' | 'debug' | 'info' | 日志级别 |
/(?:https?|wss?):\/\/[^\s"'`\)]+/g
专注于 URL 字符串混淆,随机使用以下三种方式之一:
| 方式 | 示例 |
|---|---|
| Base64 | atob("aHR0cHM6Ly9leGFtcGxlLmNvbQ==") |
| Unicode | "\u0068\u0074\u0074\u0070\u0073..." |
| CharCodes | String.fromCharCode(104, 116, 116, 112, ...) |
优点:轻量、快速、对代码体积影响小
基于 javascript-obfuscator,提供完整的代码混淆功能。
预设级别
| 预设 | 特性 |
|---|---|
low | 字符串数组(50%),紧凑格式 |
medium | 控制流扁平化(50%),字符串数组+Base64(75%) |
high | 控制流扁平化(75%),死代码注入(40%),对象键转换,Unicode 转义 |
// output_obfuscator.ts
export default {
mode: 'simple',
extensions: ['.js'],
logLevel: 'info'
}
// output_obfuscator.ts
export default {
mode: 'advanced',
extensions: ['.js'],
exclude: ['**/vendor/**', '**/lib/**'],
obfuscatorOptions: {
preset: 'medium'
}
}
// output_obfuscator.ts
export default {
mode: 'advanced',
obfuscatorOptions: {
compact: true,
controlFlowFlattening: true,
controlFlowFlatteningThreshold: 0.5,
stringArray: true,
stringArrayEncoding: ['base64']
}
}
完整配置项参考 javascript-obfuscator 文档
// output_obfuscator.ts
export default {
mode: 'simple',
urlPattern: /https:\/\/api\.[^\s"']+/g // 只匹配 api. 开头的 URL
}
| 环境 | 版本要求 |
|---|---|
| Node.js | >= 18 |
浏览器环境
atob() 支持(IE10+)high 预设会显著增加代码体积和执行时间low 或 medium 测试,再根据需要提升本工具仅供学习和测试使用,可能存在未知问题。
使用前请务必:
作者不对因使用本工具导致的任何问题承担责任。
MIT
FAQs
CLI tool for obfuscating URLs in JavaScript/TypeScript files
We found that output-obfuscator-plugin demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.

Research
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.

Research
Malicious versions of the Telnyx Python SDK on PyPI delivered credential-stealing malware via a multi-stage supply chain attack.