javascript混淆工具javascript-obfuscator的环境搭建
<p>javascript-obfuscator的项目和文档地址:https://github.com/javascript-obfuscator/javascript-obfuscator</p><h1 id="windows端">windows端</h1>
<h2 id="安装nodejs环境">安装nodejs环境</h2>
<p>打开nodejs安装包,一直点NEXT,默认设置安装即可。安装后:</p>
<pre><code class="language-shell">#测试nodejs和npm是否已安装
npm -v
#如果有输出版本号,例如输出9.5.0,表示安装成功
#查看npm安装模块的路径
npm config list
#输出部分的“prefix =”后面的路径是npm模块路径,下面以C:\\User\\admin\\AppData\\Roaming\\npm为例子
#进入npm模块路径
cd C:\\User\\admin\\AppData\\Roaming\\npm
</code></pre>
<h2 id="测试js混淆">测试js混淆</h2>
<pre><code class="language-shell">#安装javascript-obfuscator
npm install -g --save-dev javascript-obfuscator
#混淆js文件,参数的含义参考https://obfuscator.io
javascript-obfuscator [输入js文件路径] --output [输出js文件路径] --self-defending true --disable-console-output true --debug-protection true --control-flow-flattening true --dead-code-injection ture --string-array true --string-array-rotate true --string-array-shuffle true --string-array-index-shift true
#--control-flow-flattening true:混淆效果好,但是此选项会极大地影响性能,运行时速度会降低 1.5 倍。用于controlFlowFlatteningThreshold设置受控制流扁平化影响的节点百分比。启用代码控制流扁平化。控制流扁平化是一种阻碍程序理解的源代码结构转换。
#--dead-code-injection:使用此选项,随机的死代码块将添加到混淆代码中。显着增加混淆代码的大小(高达 200%),仅在混淆代码的大小无关紧要时使用。
#debugProtection:这个选项使得几乎不可能使用debugger开发者工具的功能
#--disable-console-output:禁止console输出
#--string-array等:对常量字符串和变量名等做特殊处理
</code></pre>
<h1 id="linux端">linux端</h1>
<h2 id="js混淆步骤">js混淆步骤</h2>
<p>系统环境:Ubuntu20.04</p>
<pre><code class="language-shell">#安装npm包管理
sudo apt install npm
#升级nodejs到最新版,解决依赖的问题
sudo npm install -g n
sudo n stable
#安装javascript-obfuscator
sudo npm install -g --save-dev javascript-obfuscator
#混淆js文件,参数的含义参考https://obfuscator.io
javascript-obfuscator [输入js文件路径] --output [输出js文件路径] --self-defending true --disable-console-output true --debug-protection true --control-flow-flattening true --dead-code-injection ture --string-array true --string-array-rotate true --string-array-shuffle true --string-array-index-shift true
#--control-flow-flattening true:混淆效果好,但是此选项会极大地影响性能,运行时速度会降低 1.5 倍。用于controlFlowFlatteningThreshold设置受控制流扁平化影响的节点百分比。启用代码控制流扁平化。控制流扁平化是一种阻碍程序理解的源代码结构转换。
#--dead-code-injection:使用此选项,随机的死代码块将添加到混淆代码中。显着增加混淆代码的大小(高达 200%),仅在混淆代码的大小无关紧要时使用。
#debugProtection:这个选项使得几乎不可能使用debugger开发者工具的功能
#--disable-console-output:禁止console输出
#--string-array等:对常量字符串和变量名等做特殊处理
</code></pre>
<h1 id="js解混淆测试">js解混淆测试</h1>
<p>混淆后,可以使用这个工具测试解混淆的效果</p>
<p>项目和文档地址:https://github.com/relative/synchrony</p>
<pre><code class="language-shell">#安装javascript解混淆工具
sudo npm install -g deobfuscator
synchrony deobfuscate [要解混淆的js文件路径]
#解混淆后,新生成的文件是在同一目录下的xxxx.clean.js
</code></pre><br><br>
来源:https://www.cnblogs.com/Ping697/p/17477639.html
頁:
[1]