當前位置:
首頁 >
前端技术
> javascript
>内容正文
javascript
JS超好用的免费混淆工具
生活随笔
收集整理的這篇文章主要介紹了
JS超好用的免费混淆工具
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
在線混淆地址:https://obfuscator.io/
也可自己下載源碼本地使用,地址:https://github.com/javascript-obfuscator/javascript-obfuscator
簡單翻譯一下該工具下載到本地后的使用方法:
安裝 npm install --save-dev -g javascript-obfuscator
javascript-obfuscator xx.js 混淆xx.js文件,生成的文件和xx.js同目錄
參數解釋:
-v, --version 當前版本
-h, --help 幫助-o, --output 輸出目錄--compact <boolean=false> 是否壓縮--config <string=''> 包含混淆器選項的JS / JSON配置文件的名稱。這些將被直接傳遞給CLI的選項覆蓋--control-flow-flattening <boolean=false> 此選項極大地影響了運行速度降低1.5倍的性能。--control-flow-flattening-threshold <number=0.75 Min: 0 Max: 1> 使用controlFlowFlatteningThreshold設置將受控制流展平影響的節點百分比。啟用代碼控制流展平。控制流扁平化是源代碼的結構轉換,阻礙了程序理解--dead-code-injection <boolean=false> 顯著增加混淆代碼的大小(最多200%),僅在混淆代碼的大小無關緊要時使用。使用deadCodeInjectionThreshold設置將受死代碼注入影響的節點百分比。??此選項強制啟用stringArray選項。使用此選項,隨機的死代碼塊將添加到混淆代碼中--dead-code-injection-threshold <number=0.4 Min: 0 Max: 1> 允許設置受deadCodeInjection影響的節點百分比--debug-protection <boolean=false> 如果您打開開發者工具,可以凍結您的瀏覽器,用來調試用--debug-protection-interval <boolean=false> 可以凍結你的瀏覽器!使用風險自負--disable-console-output <boolean = false> 通過用空函數替換它們來禁用console.log,console.info,console.error,console.warn,console.debug,console.exception和console.trace。這使得調試器的使用更加困難。--domain-lock '<list>' (Type: string[] Default: []) 鎖定混淆的源代碼,使其僅在特定域和/或子域上運行。這使得有人只需復制并粘貼源代碼并在別處運行就變得非常困難--exclude '<list>' (Type: string[] Default: []) 文件名或globs,表示要從混淆中排除的文件。--identifier-names-generator <string> [hexadecimal, mangled. Default: hexadecimal] 設置標識符名稱生成器--identifiers-prefix <string=''> 設置所有全局標識符的前綴。如果要混淆多個文件,請使用此選項。此選項有助于避免這些文件的全局標識符之間發生沖突。每個文件的前綴應該不同--log <boolean=false> 允許將信息記錄到控制臺。--rename-globals <boolean = false> ??此選項可能會破壞您的代碼。只有在您知道它的作用時才啟用它!使用聲明啟用全局變量和函數名稱的混淆--reserved-names '<list>' (Type: string[] Default: []) 禁用模糊處理和生成標識符,這些標識符與傳遞的RegEx模式匹配--reserved-strings '<list>' (Type: string[] Default: []) 禁用字符串文字的轉換,與傳遞的RegEx模式匹配--rotate-string-array <boolean = true> ??必須啟用StringArray功能先,將stringArray數組移位固定和隨機(在代碼混淆時生成)的位置。這使得將刪除的字符串的順序與其原始位置相匹配變得更加困難--seed <number=0> 此選項為隨機生成器設置種子。這對于創建可重復的結果很有用。如果種子為0 - 隨機生成器將在沒有種子的情況下工作--self-defending <boolean=false> 使用此選項進行模糊處理后,請勿以任何方式更改模糊代碼,因為任何更改代碼都會觸發自我防御,代碼將不再起作用!??此選項強制將緊湊值設置為true此選項使輸出代碼對格式化和變量重命名具有彈性。如果試圖在混淆代碼上使用JavaScript美化器,代碼將不再起作用,使其更難理解和修改--source-map <boolean=false> 為混淆代碼啟用源映射生成。源映射可以幫助您調試混淆的JavaScript源代碼。如果您希望或需要在生產中進行調試,可以將單獨的源映射文件上載到秘密位置,然后將瀏覽器指向該位置--source-map-base-url <string=''> 當sourceMapMode:'separate'時,將基本URL設置為源映射導入URL--source-map-file-name <string=''> 當sourceMapMode:'separate'時設置輸出源映射的文件名--source-map-mode <string> [inline, Default=separate] 指定源映射生成模式--string-array <boolean=true> 刪除字符串文字并將它們放在一個特殊的數組中。例如,var m =“Hello World”中的字符串“Hello World”;將被替換為var m = _0x12c456 [0x1]--string-array-encoding <boolean|string> [true, default=false, default=base64, rc4] 此選項可能會降低腳本速度。使用base64或rc4對stringArray的所有字符串文字進行編碼,并插入用于在運行時對其進行解碼的特殊代碼。--string-array-threshold <number=0.8 Min: 0 Max: 1> 您可以使用此設置調整字符串文字將插入stringArray的概率(從0到1)。此設置對于大型代碼大小特別有用,因為它反復調用字符串數組并可能減慢代碼速度--target <string> [Default=browser, browser-no-eval, node] 允許為混淆代碼設置目標環境--transform-object-keys <boolean=false> 啟用對象鍵的轉換--unicode-escape-sequence <boolean=false> 允許啟用/禁用字符串轉換為unicode轉義序列。Unicode轉義序列大大增加了代碼大小,并且可以輕松地將字符串恢復為原始視圖。建議僅對小型源代碼啟用此選項下面是幾個常用的混淆配置:高度混淆,性能低Performance will 50-100% slower than without obfuscation
{
compact: true,controlFlowFlattening: true,controlFlowFlatteningThreshold: 1,deadCodeInjection: true,deadCodeInjectionThreshold: 1,debugProtection: true,debugProtectionInterval: true,disableConsoleOutput: true,identifierNamesGenerator: 'hexadecimal',log: false,renameGlobals: false,rotateStringArray: true,selfDefending: true,stringArray: true,stringArrayEncoding: 'rc4',stringArrayThreshold: 1,transformObjectKeys: true,unicodeEscapeSequence: false}
中度混淆,性能較好
Performance will 30-35% slower than without obfuscation
{
compact: true,controlFlowFlattening: true,controlFlowFlatteningThreshold: 0.75,deadCodeInjection: true,deadCodeInjectionThreshold: 0.4,debugProtection: false,debugProtectionInterval: false,disableConsoleOutput: true,identifierNamesGenerator: 'hexadecimal',log: false,renameGlobals: false,rotateStringArray: true,selfDefending: true,stringArray: true,stringArrayEncoding: 'base64',stringArrayThreshold: 0.75,transformObjectKeys: true,unicodeEscapeSequence: false}
低度混淆,高性能
Performance will slightly slower than without obfuscation
{
compact: true,controlFlowFlattening: false,deadCodeInjection: false,debugProtection: false,debugProtectionInterval: false,disableConsoleOutput: true,identifierNamesGenerator: 'hexadecimal',log: false,renameGlobals: false,rotateStringArray: true,selfDefending: true,stringArray: true,stringArrayEncoding: false,stringArrayThreshold: 0.75,unicodeEscapeSequence: false}
總結
以上是生活随笔為你收集整理的JS超好用的免费混淆工具的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: JSON - 简介
- 下一篇: 深入理解javascript函数进阶系列