Skip to content

Commit 997da39

Browse files
committed
Added new stringArrayWrappers options
1 parent c51728e commit 997da39

File tree

5 files changed

+119
-12
lines changed

5 files changed

+119
-12
lines changed

App/actions/index.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,16 @@ export const setStringArrayEncoding = (encoding) => ({
139139
encoding
140140
});
141141

142+
export const setStringArrayWrappersCount = (stringArrayWrappersCount) => ({
143+
'type': types.SET_STRING_ARRAY_WRAPPERS_COUNT,
144+
stringArrayWrappersCount
145+
});
146+
147+
export const setStringArrayWrappersType = (stringArrayWrappersType) => ({
148+
'type': types.SET_STRING_ARRAY_WRAPPERS_TYPE,
149+
stringArrayWrappersType
150+
});
151+
142152
export const setSourceMapMode = (mode) => ({
143153
'type': types.SET_SOURCEMAP_MODE,
144154
mode

App/constants/ActionTypes.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ export const TOGGLE_ROTATE_STRING_ARRAY = 'TOGGLE_ROTATE_STRING_ARRAY';
3333
export const TOGGLE_SHUFFLE_STRING_ARRAY = 'TOGGLE_SHUFFLE_STRING_ARRAY';
3434
export const SET_STRING_ARRAY_ENCODING = 'SET_STRING_ARRAY_ENCODING';
3535

36+
export const SET_STRING_ARRAY_WRAPPERS_COUNT = 'SET_STRING_ARRAY_WRAPPERS_COUNT';
37+
export const TOGGLE_STRING_ARRAY_WRAPPERS_CHAINED_CALLS = 'TOGGLE_STRING_ARRAY_WRAPPERS_CHAINED_CALLS';
38+
export const SET_STRING_ARRAY_WRAPPERS_TYPE = 'SET_STRING_ARRAY_WRAPPERS_TYPE';
39+
3640
export const ADD_DOMAIN_LOCK = 'ADD_DOMAIN_LOCK';
3741
export const REMOVE_DOMAIN_LOCK = 'REMOVE_DOMAIN_LOCK';
3842

App/containers/OptionsContainer.js

Lines changed: 43 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@ const STRING_ARRAY_ENCODING_OPTIONS = [
4040
{text: 'RC4', value: STRING_ARRAY_ENCODING_RC4},
4141
];
4242

43+
export const STRING_ARRAY_WRAPPERS_TYPE_VARIABLE = 'variable';
44+
export const STRING_ARRAY_WRAPPERS_TYPE_FUNCTION = 'function';
45+
46+
const STRING_ARRAY_WRAPPERS_TYPE_OPTIONS = [
47+
{text: 'Variable', value: STRING_ARRAY_WRAPPERS_TYPE_VARIABLE},
48+
{text: 'Function', value: STRING_ARRAY_WRAPPERS_TYPE_FUNCTION},
49+
];
50+
4351
export const TARGET_BROWSER = 'browser';
4452
export const TARGET_BROWSER_NO_EVAL = 'browser-no-eval';
4553
export const TARGET_NODE = 'node';
@@ -196,16 +204,6 @@ const Options = ({dispatch, options}) => {
196204
disabled={!options.shuffleStringArrayEnabled}
197205
onChange={() => dispatch(actions.toggleOption(types.TOGGLE_SHUFFLE_STRING_ARRAY))}/>
198206

199-
<Form.Select
200-
disabled={!options.stringArrayEncodingEnabled}
201-
label='String Array Encoding'
202-
fluid
203-
multiple
204-
placeholder={STRING_ARRAY_ENCODING_NONE}
205-
value={options.stringArrayEncoding}
206-
onChange={(event, {value}) => dispatch(actions.setStringArrayEncoding(value))}
207-
options={STRING_ARRAY_ENCODING_OPTIONS}/>
208-
209207
<Form.Input
210208
type='number'
211209
label='String Array Threshold'
@@ -216,6 +214,41 @@ const Options = ({dispatch, options}) => {
216214
onChange={(event, {value}) => dispatch(actions.setStringArrayThreshold(parseFloat(value)))}
217215
disabled={!options.stringArrayThresholdEnabled}/>
218216

217+
<Form.Input
218+
type='number'
219+
label='String Array Wrappers Count'
220+
value={options.stringArrayWrappersCount}
221+
min="0"
222+
step="1"
223+
onChange={(event, {value}) => dispatch(actions.setStringArrayWrappersCount(parseInt(value)))}
224+
disabled={!options.stringArray}/>
225+
226+
<Form.Select
227+
label='String Array Wrappers Type'
228+
fluid
229+
placeholder={STRING_ARRAY_WRAPPERS_TYPE_VARIABLE}
230+
value={options.stringArrayWrappersType}
231+
onChange={(event, {value}) => dispatch(actions.setStringArrayWrappersType(value))}
232+
options={STRING_ARRAY_WRAPPERS_TYPE_OPTIONS}
233+
disabled={!options.stringArray || !options.stringArrayWrappersCount}
234+
/>
235+
236+
<Form.Checkbox
237+
label='String Array Wrappers Chained Calls'
238+
checked={options.stringArrayWrappersChainedCalls}
239+
disabled={!options.stringArray || !options.stringArrayWrappersCount}
240+
onChange={() => dispatch(actions.toggleOption(types.TOGGLE_STRING_ARRAY_WRAPPERS_CHAINED_CALLS))}/>
241+
242+
<Form.Select
243+
disabled={!options.stringArrayEncodingEnabled}
244+
label='String Array Encoding'
245+
fluid
246+
multiple
247+
placeholder={STRING_ARRAY_ENCODING_NONE}
248+
value={options.stringArrayEncoding}
249+
onChange={(event, {value}) => dispatch(actions.setStringArrayEncoding(value))}
250+
options={STRING_ARRAY_ENCODING_OPTIONS}/>
251+
219252
<Divider/>
220253

221254
<Form.Checkbox

App/reducers/options.js

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ import * as types from '../constants/ActionTypes';
22

33
import {
44
SOURCEMAP_SEPARATE,
5-
SOURCEMAP_OFF,
65
OPTIONS_PRESET_DEFAULT,
76
IDENTIFIER_NAMES_GENERATOR_HEXADECIMAL,
87
TARGET_BROWSER,
98
STRING_ARRAY_ENCODING_NONE,
109
STRING_ARRAY_ENCODING_BASE64,
11-
STRING_ARRAY_ENCODING_RC4
10+
STRING_ARRAY_ENCODING_RC4,
11+
STRING_ARRAY_WRAPPERS_TYPE_VARIABLE
1212
} from '../containers/OptionsContainer';
1313

1414
const initialState = {
@@ -44,6 +44,10 @@ const initialState = {
4444
],
4545
stringArrayEncodingEnabled: true,
4646

47+
stringArrayWrappersCount: 1,
48+
stringArrayWrappersChainedCalls: true,
49+
stringArrayWrappersType: STRING_ARRAY_WRAPPERS_TYPE_VARIABLE,
50+
4751
numbersToExpressions: false,
4852

4953
sourceMap: false,
@@ -202,6 +206,24 @@ export const options = (state = initialState, action) => {
202206
stringArrayThreshold: action.threshold
203207
};
204208

209+
case types.SET_STRING_ARRAY_WRAPPERS_COUNT:
210+
return {
211+
...state,
212+
stringArrayWrappersCount: action.stringArrayWrappersCount
213+
};
214+
215+
case types.TOGGLE_STRING_ARRAY_WRAPPERS_CHAINED_CALLS:
216+
return {
217+
...state,
218+
stringArrayWrappersChainedCalls: !state.stringArrayWrappersChainedCalls
219+
};
220+
221+
case types.SET_STRING_ARRAY_WRAPPERS_TYPE:
222+
return {
223+
...state,
224+
stringArrayWrappersType: action.stringArrayWrappersType
225+
};
226+
205227
case types.TOGGLE_SOURCEMAP: {
206228
return {
207229
...state,

templates/index.html

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,44 @@ <h3>Sounds great!</h3>
367367
</td>
368368
</tr>
369369

370+
<tr>
371+
<td class="collapsing">String Array Wrappers Count</td>
372+
<td>
373+
<p>
374+
Sets the count of wrappers for the <code>stringArray</code> inside each root or function scope.
375+
</p>
376+
<p>
377+
The actual count of wrappers inside each scope is limited by a count of `literal` nodes within this scope.
378+
</p>
379+
</td>
380+
</tr>
381+
382+
<tr>
383+
<td class="collapsing">String Array Wrappers Type</td>
384+
<td>
385+
<p>
386+
Allows to select a type of the wrappers that are appending by the <code>stringArrayWrappersCount</code> option.
387+
</p>
388+
<p>Available values:</p>
389+
<ul>
390+
<li><strong>Variable</strong></li>
391+
<li><strong>Function</strong></li>
392+
</ul>
393+
<p>
394+
Highly recommended to use <code>function</code> wrappers for higher obfuscation when a performance loss doesn't have a high impact on an obfuscated application.
395+
</p>
396+
</td>
397+
</tr>
398+
399+
<tr>
400+
<td class="collapsing">String Array Wrappers Chained Calls</td>
401+
<td>
402+
<p>
403+
Enables the chained calls between <code>stringArray</code> wrappers.
404+
</p>
405+
</td>
406+
</tr>
407+
370408
<tr>
371409
<td class="collapsing">Encode String Literals</td>
372410
<td>

0 commit comments

Comments
 (0)