JavaScript 混淆器

458 阅读1分钟

官网: obfuscator.io/

开源地址:github

配置参数

{
    compact: true, //代码压缩
    controlFlowFlattening: false,  //控制流平坦化,让代码执行逻辑混淆。基本思想是将一些逻辑处理快都统一加上前驱逻辑块,每个逻辑块都由前驱逻辑块进行条件判断和分发,构成一个个闭环逻辑
    controlFlowFlatteningThreshold: 0.75, //比例
    deadCodeInjection: false, //无用代码注入
    deadCodeInjectionThreshold: 0.4, //无用代码注入比例
    debugProtection: false,  //调试保护
    debugProtectionInterval: false, //无限调试
    disableConsoleOutput: false, //禁用控制台输出
    domainLock: [], //域名锁定
    domainLockRedirectUrl: 'about:blank',
    forceTransformStrings: [],
    identifierNamesCache: null, 
    identifierNamesGenerator: 'hexadecimal', //变量名混淆,hexadecimal 替换为十六进制字符串, mangled 替换为 a,b,c
    identifiersDictionary: [],
    identifiersPrefix: '',  //变量名前缀
    ignoreRequireImports: false,
    inputFileName: '',
    log: false,
    numbersToExpressions: false,
    optionsPreset: 'default',
    renameGlobals: false,  //是否混淆全局变量和函数名称
    renameProperties: false,
    renamePropertiesMode: 'safe',
    reservedNames: [],
    reservedStrings: [],
    seed: 0,
    selfDefending: false, //代码自我保护,开启后会强制已一行显示,如果进行代码格式化 就无法执行了。
    simplify: true,
    sourceMap: false,
    sourceMapBaseUrl: '',
    sourceMapFileName: '',
    sourceMapMode: 'separate',
    sourceMapSourcesMode: 'sources-content',
    splitStrings: false,
    splitStringsChunkLength: 10,
    stringArray: true,  //字符串混淆,把一个字符串放到一个数组里 无法被搜索
    stringArrayIndexesType: [
        'hexadecimal-number'
    ],
    stringArrayEncoding: [], //控制数组的编码形式 'base64',rc4
    stringArrayIndexShift: true,
    stringArrayRotate: true,
    stringArrayShuffle: true,
    stringArrayWrappersCount: 1,
    stringArrayWrappersChainedCalls: true,
    stringArrayWrappersParametersMaxCount: 2,
    stringArrayWrappersType: 'variable',
    stringArrayThreshold: 0.75, //控制启用编码的概率
    target: 'browser',
    transformObjectKeys: false,  //对象键名替换
    unicodeEscapeSequence: false //对字符串unicode转码
}