一款JavaScript 混淆(Obfuscator)工具(Tool)的研究(一)

1.研究使用的工具及网站

https://obfuscator.io   主要研究对象,主要是研究此网站的各种混淆方法及**办法。

http://jsnice.org/          用来格式化代码,方便调试。

notepad++                  编辑代码。

某浏览器                    具有谷歌内核的浏览器,主要用来调试JS代码。

2.网站功能选项翻译

Compact Code

紧凑代码

Removes line breaks from the output obfuscated code. 从输出的混淆代码中删除换行符。

Identifier Names Generator

标识符名称生成器

Use this option to control how identifiers (variable names, functions names, etc) will be obfuscated.

使用此选项来控制如何混淆标识符(变量名,函数名等)。

dictionary    字典

Generates identifier names using names from identifiersDictionary list  通过查字典来获取标识符名称

hexadecimal 16进制

Generates random identifier names using a hexadecimal pattern (e.g: 0xabc123) 使用十六进制模式生成随机标识符名称(例如:0xabc123)

mangled 单字母变量

Uses short identifier names (e.g: abc, etc.) 使用简短的标识符名称(例如:a,b,c等)

Identifiers Dictionary

标识符字典

This options sets identifiers list for identifierNamesGenerator: dictionary option

此选项设置identifierNamesGenerator的标识符列表:dictionary选项。简单的说所有的标识符(常量,变量函数名等)都不可见了,只能通过查字典来获取标识符。

Identifiers Prefix

标识符前缀

This options makes all global identifiers have a specific prefix. 此选项使所有全局标识符具有特定的前缀。

Use this option when obfuscating multiple files that are loaded on the same page. This option helps to avoid conflicts between global identifiers of these files. Use a different prefix for each file.当混淆同一页面上加载的多个文件时,请使用此选项。此选项有助于避免这些文件的全局标识符之间的冲突。为每个文件使用不同的前缀。

Rename Globals

全局变量重命名

 This option can break your code. Only enable it if you know what it does.

Enables the obfuscation of global variables and function names with declaration.

此选项可能会破坏您的代码。仅在知道它的功能时启用它。

Self Defending

自我保护

This option makes the output code resilient against formating and variable renaming. 此选项使输出代码可抵抗格式设置和变量重命名。

If one tries to use a JavaScript beautifier on the obfuscated code, the code won't work anymore, making it harder to understand and modify it.如果尝试在混淆后的代码上使用JavaScript美化器,则该代码将无法再使用,从而使其难以理解和修改。

requires the Compact Code setting.

Control Flow Flattening

平坦控制流

 This option greatly affects the performance up to 1.5x slower runtime speed.此选项对性能的影响最大为运行速度降低1.5倍。

Enables code control flow flattening. Control flow flattening is a structure transformation of the source code that hinders program comprehension. See the docs on JavaScript's obfuscator GH page for an example of how the transformation works.

启用代码控制流平坦。控制流扁平化是源代码的结构转换,它阻碍了程序的理解。有关转换如何工作的示例,请参见JavaScript的混淆器GH页面上的文档。
 

Control Flow Flattening Threshold

控制流展平阈值

You can use this setting to adjust the probability (from 0 to 1) that a controlFlowFlattening transformation will be applied to a node.您可以使用此设置来调整将controlFlowFlattening转换应用于节点的可能性(从0到1)。

In larger codebases it's advised to lower this value, because larger amounts of control flow transformations can increase the size of your code and slow it down.在较大的代码库中,建议降低此值,因为大量的控制流转换会增加代码的大小并减慢其速度。

Dead Code Injection

加入花指令

 This option increases the size of the obfuscated code greatly (up to 200%).此选项极大地增加了混淆代码的大小(最多200%)。

This feature adds random blocks of dead code (i.e: code that won't be executed) to the obfuscated output, making it harder to be reverserd-engineered. See the docs on JavaScript Obfuscator's GH page for an example of how this feature works.

此功能将混淆代码的随机块(即将不会执行的代码)添加到混淆后的输出中,从而更难进行反向工程。有关此功能如何工作的示例,请参见JavaScript Obfuscator的GH页面上的文档。

 

Dead Code Injection Threshold

花指令注入阈值

You can use this setting to adjust the probability (from 0 to 1) that a node will be affected by the deadCodeInjection option.

您可以使用此设置调整节点受deadCodeInjection选项影响的概率(从0到1)。

requires the String Array option.需要“字符串数组”选项。

Split Strings

分割字符串

 This option increases the size of the obfuscated code.此选项增加了混淆代码的大小。

This feature splits literal strings into chunks with length of the splitStringsChunkLength option value.

此功能将文字字符串拆分为具有splitStringsChunkLength选项值长度的块。

Split Strings Chunk Length

分叉弦块长度

You can use this setting to set chunk length of the splitStrings option.

您可以使用此设置来设置splitStrings选项的块长度。

String Array

字符串数组

Removes string literals and place them in a special array. For instance the string "Hello World" in var m = "Hello World"; will be replaced to a call to a function that will retrieve its value at runtime, e.g: var m = _0xb0c3('0x1');

删除字符串文字并将其放置在特殊数组中。例如,在var m =“ Hello World”中的字符串“ Hello World”;将替换为对将在运行时检索其值的函数的调用,例如:var m = _0xb0c3('0x1');

See the options below on how to configure this feature be more or less resilient.

请参阅以下有关如何配置此功能或多或少具有弹性的选项。

Rotate String Array

旋转字符串数组

Shift the stringArray array by a fixed and random (generated at the code obfuscation) places. This makes it harder to match the order of the removed strings to their original place.

将stringArray数组移动一个在混淆代码中随机生成的固定位置。这使得将删除的字符串的顺序与其原始位置匹配变得更加困难。

作者注:例如数组[1,2,4,6,7],代码随机生成一个偏移2,则数组变成[6,7,1,2,4]

This option is recommended if your original source code isn't small, as the helper function can attract attention.

如果原始源代码不小,则建议使用此选项,因为辅助功能会引起注意。

Shuffle String Array

随机字符串数组

Randomly shuffles the stringArray array items.

随机改组stringArray数组项。
 

Encode String Literals

加密字符串

 This option can slightly slow down your script.此选项会稍微降低脚本速度。

Encode all string literals of the stringArray using either Base64 or RC4 and inserts a special function that it's used to decode it back at runtime.使用Base64或RC4对stringArray的所有字符串文字进行编码,并插入一个特殊的函数,用于在运行时对其进行解码。

Beware that the RC4 option is about 30-35% slower than the Base64 option, but it's more difficult to retrieve the strings back.请注意,RC4选项比​​Base64选项慢大约30-35%,但更难找回字符串。

String Array Threshold

字符串数组阈值

You can use this setting to adjust the probability (from 0 to 1) that a string literal will be inserted into the stringArray.您可以使用此设置来调整将字符串文字插入到stringArray中的比例(从0到1)。

This setting is useful in large codebases as repeatdely calls to the stringArray function can slow down your code.此选项在大型代码库中很有用,因为反复调用stringArray函数会降低代码速度。

Transform Object Keys

转换对象键

Transforms (obfuscates) object keys.转换(混淆)对象键。

For instance, this code var a = {enabled: true}; when obfuscated with this option will hide the enabled object key: var a = {}; a[_0x2ae0[('0x0')] = true;.例如,这段代码var a = {enabled:true}; 当对此选项进行混淆时,将隐藏启用的对象键:var a = {}; a [_0x2ae0 [('0x0')] = true;。

See the official documentation of the JavaScript Obfuscator on GitHub for a full example.有关完整示例,请参见GitHub上的JavaScript Obfuscator的官方文档。

ideally used with the String Array setting. 此最想通常跟字符数据选项一起使用。

Escape Unicode Sequence

转义Unicode序列

Converts all the strings to their unicode representation. For instance, the string "Hello World!" will be converted to "'\x48\x65\x6c\x6c\x6f\x20\x57\x6f\x72\x6c\x64\x21".

将所有字符串转换为它们的unicode表示形式。 例如,字符串“ Hello World!”。 将被转换为“'\ x48 \ x65 \ x6c \ x6c \ x6f \ x20 \ x57 \ x6f \ x72 \ x6c \ x64 \ x21”。

This convertion is pretty easy to revert, and will increase the obfuscated code size greatly. It's not recommended on larger code bases.此转换非常容易还原,并且将大大增加混淆的代码大小。 不建议在较大的代码库中使用。

Disable Console Output

禁用控制台输出

Disables the use of console.logconsole.infoconsole.error and console.warn by replacing them with empty functions. This makes the use of the debugger harder.

禁用控制台输出通过将它们替换为空函数来禁用对console.log,console.info,console.error和console.warn的使用。 这使得调试器的使用更加困难。

Debug Protection

反调试

 Can freeze your browser if you open the Developer Tools.如果打开开发人员工具,则可以卡死浏览器。

This option makes it almost impossible to use the Console tab of the Developer Tools (both on Google Chrome and Mozilla Firefox).

使用此选项几乎无法使用开发人员工具的控制台选项卡(在Google Chrome和Mozilla Firefox上)。

Debug Protection Interval

调试保护间隔

If checked, an interval is used to force the debug mode on the Console tab, making it harder to use other features of the Developer Tools.如果选中该选项,则会使用一个时间间隔强制在“控制台”选项卡上启用调试模式,这使得使用开发人员工具的其他功能更加困难。

How does it works? A special code that calls debugger; repeatedly is inserted throughout the obfuscated source code.如何运作?调用调试器的特殊代码;重复地被插入到混淆的源代码中。

Domain Lock

域锁

Locks the obfuscated source code so it only runs on specific domains and/or sub-domains. This makes really hard for someone just copy and paste your source code and run elsewhere.锁定混淆的源代码,使其仅在特定的域和/或子域上运行。对于仅复制并粘贴源代码并在其他地方运行的人来说,这真的很难。

Multiple domains and sub-domains 多个域和子域

It's possible to lock your code to more than one domain or sub-domain. For instance, to lock it so the code only runs on www.example.com add www.example.com, to make it work on any sub-domain from example.com, use .example.com.

可以将代码锁定到多个域或子域。例如,要对其进行锁定以使代码仅在www.example.com上运行,请添加www.example.com,以使其在example.com的任何子域中均可使用,请使用.example.com。

Reserved Names

保留名称

Disables obfuscation and generation of identifiers, which being matched by passed RegExp patterns.

禁用混淆和标识符的生成,这些标识符与通过的RegExp模式匹配。

For instance, if you add ^someName, the obfuscator will ensure that all variables, function names and function arguments that starts with someName will not get mangled.

例如,如果添加^ someName,混淆器将确保不会破坏以someName开头的所有变量,函数名称和函数参数。

Reserved Strings

保留字串

Disables transformation of string literals, which being matched by passed RegExp patterns.

禁用字符串文字的转换,该文字与通过的RegExp模式匹配。

For instance, if you add ^some *string, the obfuscator will ensure that all strings that starts with some string will not get moved to the `stringArray`.

例如,如果添加^ some * string,混淆器将确保所有以某个字符串开头的字符串都不会移到`stringArray`中。

Source Map

源图

 Be sure not to upload the obfuscated source code with the inline source map embedded on it, as it contains your original source code.确保不要上传嵌入了嵌入式源代码映射的混淆后的源代码,因为它包含原始源代码。

Source maps can be useful to help you debug your obfuscated Java Script source code. If you want or need to debug in production, you can upload the separate source map file to a secret location and then point your browser there. Read more about source maps on the Google Chrome Developer Tools website.

源映射可以帮助您调试混淆的Java Script源代码。如果要在生产中进行调试,可以将单独的源映射文件上载到秘密位置,然后将浏览器指向该位置。在Google Chrome开发者工具网站上详细了解源地图。

Inline Source Map内联源地图

This embeds the source map of your source in the result of the obfuscated code. Useful if you just want to debug locally on your machine.这会将源代码的源映射嵌入到混淆代码的结果中。如果只想在计算机上进行本地调试,则很有用。

Separate Source Map单独的源地图

This generates a separate file with the source map. Useful to debug code in production, as this enables you to upload the source map to a secret location on your server and then point your browser to use it.

这将与源映射一起生成一个单独的文件。这对于调试生产中的代码很有用,因为这使您可以将源映射上载到服务器上的秘密位置,然后指向浏览器使用它。

Use the Source Map Base URL and Source Map File Name to customize the sourceMappingURL property that will get appended to the end of your obfuscated code.

使用Source Map Base URL和Source Map File Name来定制sourceMappingURL属性,该属性将附加到混淆代码的末尾。

For instance, if you set the Base URL to "http://localhost:9000" and File Name to "example", you'll get: //# sourceMappingURL=http://localhost:9000/example.js.map. appended to the end of your obfuscated code.

例如,如果将基本URL设置为“ http:// localhost:9000”,文件名设置为“ example”,则将得到://#sourceMappingURL = http:// localhost:9000 / example.js.map 。附加到混淆代码的末尾。

Seed

种子

By default (seed = 0), each time you obfuscate your code you'll get a new result (i.e: different variable names, different variables inserted into the stringArray, etc). If you want repeatable results, set the seed to a specific integer.

默认情况下(seed = 0),每次混淆代码时,您都会得到一个新结果(即:不同的变量名,插入stringArray中的变量不同,等等)。 如果要获得可重复的结果,请将种子设置为特定的整数。

Target

目标

You can set the target environment of the obfuscated code to one of the following:您可以将混淆代码的目标环境设置为以下之一:

  • Browser
  • Browser No Eval
  • Node

Currently the output of browser and node is identical.当前,浏览器和节点的输出是相同的。

网站功能区截图:

一款JavaScript 混淆(Obfuscator)工具(Tool)的研究(一)