Skip to content

Commit

Permalink
feat: add js-obfuscator options.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed Oct 29, 2022
1 parent 3fed619 commit ab3f349
Show file tree
Hide file tree
Showing 4 changed files with 115 additions and 8 deletions.
73 changes: 72 additions & 1 deletion packages/js-obfuscator/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,77 @@ export default function JSObfuscator() {
setOptions({ ...options, ...{ stringArrayCallsTransform: target.checked } });
},
},
{
disabled: !options.stringArray,
checked: !!options.stringArrayRotate,
children: (
<Fragment>
stringArrayRotate <br />
<Info>{t<string>('stringArrayRotate')}</Info>
</Fragment>
),
onChange: ({ target }) => {
setOptions({ ...options, ...{ stringArrayRotate: target.checked } });
},
},
{
disabled: !options.stringArray,
checked: !!options.stringArrayShuffle,
children: (
<Fragment>
stringArrayShuffle <br />
<Info>{t<string>('stringArrayShuffle')}</Info>
</Fragment>
),
onChange: ({ target }) => {
setOptions({ ...options, ...{ stringArrayShuffle: target.checked } });
},
},
{
disabled: !options.stringArray && !options.stringArrayWrappersCount,
checked: !!options.stringArrayWrappersChainedCalls,
children: (
<Fragment>
stringArrayWrappersChainedCalls <br />
<Info>{t<string>('stringArrayWrappersChainedCalls')}</Info>
</Fragment>
),
onChange: ({ target }) => {
setOptions({ ...options, ...{ stringArrayWrappersChainedCalls: target.checked } });
},
},
{
disabled: !options.stringArray,
type: 'number',
value: options.stringArrayWrappersCount,
children: (
<Fragment>
stringArrayWrappersCount <br />
<Info>{t<string>('stringArrayWrappersCount')}</Info>
</Fragment>
),
onChange: ({ target }) => {
setOptions({ ...options, ...{ stringArrayWrappersCount: target.checked } });
},
},
{
type: 'range',
max: '5',
min: '2',
step: '1',
disabled: !options.stringArray,
value: options.stringArrayWrappersParametersMaxCount,
children: (
<Fragment>
{options.stringArrayWrappersParametersMaxCount} <br />
stringArrayWrappersParametersMaxCount <br />
<Info>{t<string>('stringArrayWrappersParametersMaxCount')}</Info>
</Fragment>
),
onChange: ({ target }) => {
setOptions({ ...options, ...{ stringArrayWrappersParametersMaxCount: Number(target.value) } });
},
},
{
type: 'range',
max: '1',
Expand All @@ -416,7 +487,7 @@ export default function JSObfuscator() {
children: (
<Fragment>
{options.stringArrayCallsTransformThreshold} <br />
stringArrayCallsTransformThreshold
stringArrayCallsTransformThreshold <br />
<Info>{t<string>('stringArrayCallsTransformThreshold')}</Info>
</Fragment>
),
Expand Down
34 changes: 29 additions & 5 deletions packages/js-obfuscator/src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,35 @@ export const allOptions: ObfuscatorOptions = {
// stringArrayEncoding: TStringArrayEncoding[];
// stringArrayIndexesType: TStringArrayIndexesType[];
// stringArrayIndexShift: boolean;
// stringArrayRotate: boolean;
// stringArrayShuffle: boolean;
// stringArrayWrappersChainedCalls: boolean;
// stringArrayWrappersCount: number;
// stringArrayWrappersParametersMaxCount: number;
/**
* ⚠️ stringArray must be enabled
* 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.
*/
stringArrayRotate: true,
/**
* ⚠️ stringArray must be enabled
*
* 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.
*/
stringArrayShuffle: true,
/**
* ⚠️ stringArray and stringArrayWrappersCount options must be enabled
*
* Enables the chained calls between string array wrappers.
*/
stringArrayWrappersChainedCalls: true,
/**
* ⚠️ stringArray option must be enabled
*
* Sets the count of wrappers for the string array inside each root or function scope. The actual count of wrappers inside each scope is limited by a count of literal nodes within this scope.
*/
stringArrayWrappersCount: 1,
/**
* ⚠️ stringArray option must be enabled
* ⚠️ Currently this option affects only wrappers added by stringArrayWrappersType function option value
* Allows to control the maximum number of string array wrappers parameters. Default and minimum value is 2. Recommended value between 2 and 5.
*/
stringArrayWrappersParametersMaxCount: 2,
// stringArrayWrappersType: TStringArrayWrappersType;
// stringArrayThreshold: number;
target: 'browser',
Expand Down
10 changes: 8 additions & 2 deletions website/public/locales/cn/js-obfuscator.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,14 @@
"splitStrings": "将文字字符串拆分为长度为 splitStringsChunkLength 选项值的块",
"splitStringsChunkLength": "设置 splitStrings 选项的块长度",
"stringArray": "删除字符串文字并将其放置在特殊数组中。例如,var m=“Hello World”中的字符串“Hello World”;将替换为类似var m=_0x12c456[0x1]的内容;",
"stringArrayCallsTransform": "⚠️ 必须启用stringArray选项启用对stringArray的调用转换。根据stringArrayCallsTransformThreshold值,可以将这些调用的所有参数提取到不同的对象。因此,自动查找对字符串数组的调用变得更加困难。",
"stringArrayCallsTransformThreshold": " ⚠️ 必须启用stringArray和stringArrayCallsTransformThreshold选项您可以使用此设置调整对字符串数组的调用将被转换的概率(从0到1)。",
"stringArrayCallsTransform": "⚠️ 必须启用stringArray选项启用对stringArray的调用转换。根据stringArrayCallsTransformThreshold值,可以将这些调用的所有参数提取到不同的对象。因此,自动查找对字符串数组的调用变得更加困难",
"stringArrayCallsTransformThreshold": " ⚠️ 必须启用stringArray和stringArrayCallsTransformThreshold选项您可以使用此设置调整对字符串数组的调用将被转换的概率(从0到1)",

"stringArrayRotate": "⚠️ 必须启用stringArray。将 stringArray 数组移位固定和随机(在代码混淆时生成)位置。这使得很难将移除的字符串的顺序与其原始位置相匹配",
"stringArrayShuffle": "⚠️ 必须启用stringArray。随机移动 stringArray 数组项",
"stringArrayWrappersChainedCalls": "⚠️ 必须启用stringArray和stringArrayWrappersCount选项。启用字符串数组包装器之间的链接调用",
"stringArrayWrappersCount": "⚠️ 必须启用stringArray选项。设置每个根或函数范围内字符串数组的包装器计数。每个作用域内包装器的实际数量受此作用域内文本节点的数量限制",
"stringArrayWrappersParametersMaxCount": "⚠️ 必须启用stringArray选项。⚠️ 当前,此选项仅影响stringArrayWrappersType函数选项值添加的包装器。允许控制字符串数组包装器参数的最大数量。默认值和最小值为2。建议值介于2和5之间",

"target": "允许为模糊代码设置目标环境。可用值:`browser`,`browser-no-eval`,`node`。当前 `browser` 和`node`目标的输出代码是相同的,但某些特定于`browser`的选项不允许与`node`目标一起使用。`browser-no-eval`目标的输出代码未使用eval",
"transformObjectKeys": "启用对象关键点的变换",
Expand Down
6 changes: 6 additions & 0 deletions website/public/locales/en/js-obfuscator.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@
"stringArrayCallsTransform": "⚠️ stringArray option must be enabled Enables the transformation of calls to the stringArray. All arguments of these calls may be extracted to a different object depending on stringArrayCallsTransformThreshold value. So it makes it even harder to automatically find calls to the string array.",
"stringArrayCallsTransformThreshold": "⚠️ stringArray and stringArrayCallsTransformThreshold options must be enabled You can use this setting to adjust the probability (from 0 to 1) that calls to the string array will be transformed.",

"stringArrayRotate": "⚠️ stringArray must be enabled. 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.",
"stringArrayShuffle": "⚠️ stringArray must be enabled. Randomly shuffles the stringArray array items.",
"stringArrayWrappersChainedCalls": "⚠️ stringArray and stringArrayWrappersCount options must be enabled. Enables the chained calls between string array wrappers.",
"stringArrayWrappersCount": "⚠️ stringArray option must be enabled. Sets the count of wrappers for the string array inside each root or function scope. The actual count of wrappers inside each scope is limited by a count of literal nodes within this scope.",
"stringArrayWrappersParametersMaxCount": "⚠️ stringArray option must be enabled. ⚠️ Currently this option affects only wrappers added by stringArrayWrappersType function option value. Allows to control the maximum number of string array wrappers parameters. Default and minimum value is 2. Recommended value between 2 and 5.",

"target": "Allows to set target environment for obfuscated code. Available values: `browser` `browser-no-eval` `node`. Currently output code for browser and node targets is identical, but some browser-specific options are not allowed to use with node target. Output code for browser-no-eval target is not using eval.",
"transformObjectKeys": "Enables transformation of object keys.",
"unicodeEscapeSequence": "Allows to enable/disable string conversion to unicode escape sequence. Unicode escape sequence increases code size greatly and strings easily can be reverted to their original view. Recommended to enable this option only for small source code."
Expand Down

0 comments on commit ab3f349

Please sign in to comment.