|
@@ -85,6 +85,7 @@ describe('BlockStatementControlFlowTransformer', function () {
|
|
|
|
|
|
describe('switch-case map', () => {
|
|
describe('switch-case map', () => {
|
|
const switchCaseMapVariableRegExp: RegExp = /var *_0x(?:[a-f0-9]){4,6} *= *_0x(?:[a-f0-9]){4,6}\['.*'\]\['split'\]\('\|'\)/;
|
|
const switchCaseMapVariableRegExp: RegExp = /var *_0x(?:[a-f0-9]){4,6} *= *_0x(?:[a-f0-9]){4,6}\['.*'\]\['split'\]\('\|'\)/;
|
|
|
|
+ const switchCaseMapIndexVariableRegExp: RegExp = /var *_0x(?:[a-f0-9]){4,6} *= *0x0;/;
|
|
const switchCaseMapStringRegExp: RegExp = /var *_0x(?:[a-f0-9]){4,6} *= *\{'.*' *: *'(.*)'\};/;
|
|
const switchCaseMapStringRegExp: RegExp = /var *_0x(?:[a-f0-9]){4,6} *= *\{'.*' *: *'(.*)'\};/;
|
|
const expectedSwitchCasesSequence: string[] = ['0', '1', '2', '3', '4'];
|
|
const expectedSwitchCasesSequence: string[] = ['0', '1', '2', '3', '4'];
|
|
|
|
|
|
@@ -100,6 +101,10 @@ describe('BlockStatementControlFlowTransformer', function () {
|
|
assert.match(obfuscatedCode, switchCaseMapVariableRegExp);
|
|
assert.match(obfuscatedCode, switchCaseMapVariableRegExp);
|
|
});
|
|
});
|
|
|
|
|
|
|
|
+ it('should use correct kind of index variable for switch-case map', () => {
|
|
|
|
+ assert.match(obfuscatedCode, switchCaseMapIndexVariableRegExp);
|
|
|
|
+ });
|
|
|
|
+
|
|
it('should create valid switch-case map variable with order of switch cases sequence', () => {
|
|
it('should create valid switch-case map variable with order of switch cases sequence', () => {
|
|
assert.deepEqual(switchCaseMap, expectedSwitchCasesSequence);
|
|
assert.deepEqual(switchCaseMap, expectedSwitchCasesSequence);
|
|
});
|
|
});
|
|
@@ -669,7 +674,8 @@ describe('BlockStatementControlFlowTransformer', function () {
|
|
});
|
|
});
|
|
|
|
|
|
describe('switch-case map', () => {
|
|
describe('switch-case map', () => {
|
|
- const switchCaseMapVariableRegExp: RegExp = /var *_0x(?:[a-f0-9]){4,6} *= *_0x(?:[a-f0-9]){4,6}\['.*'\]\['split'\]\('\|'\)/;
|
|
|
|
|
|
+ const switchCaseMapVariableRegExp: RegExp = /var *_0x(?:[a-f0-9]){4,6} *= *_0x(?:[a-f0-9]){4,6}\['.*'\]\['split'\]\('\|'\);/;
|
|
|
|
+ const switchCaseMapIndexVariableRegExp: RegExp = /var *_0x(?:[a-f0-9]){4,6} *= *0x0;/;
|
|
const switchCaseMapStringRegExp: RegExp = /var *_0x(?:[a-f0-9]){4,6} *= *\{'.*' *: *'(.*)'\};/;
|
|
const switchCaseMapStringRegExp: RegExp = /var *_0x(?:[a-f0-9]){4,6} *= *\{'.*' *: *'(.*)'\};/;
|
|
const expectedSwitchCasesSequence: string[] = ['0', '1', '2', '3', '4'];
|
|
const expectedSwitchCasesSequence: string[] = ['0', '1', '2', '3', '4'];
|
|
|
|
|
|
@@ -685,6 +691,10 @@ describe('BlockStatementControlFlowTransformer', function () {
|
|
assert.match(obfuscatedCode, switchCaseMapVariableRegExp);
|
|
assert.match(obfuscatedCode, switchCaseMapVariableRegExp);
|
|
});
|
|
});
|
|
|
|
|
|
|
|
+ it('should use correct kind of index variable for switch-case map', () => {
|
|
|
|
+ assert.match(obfuscatedCode, switchCaseMapIndexVariableRegExp);
|
|
|
|
+ });
|
|
|
|
+
|
|
it('should use correct kind of variable for switch cases sequence', () => {
|
|
it('should use correct kind of variable for switch cases sequence', () => {
|
|
assert.deepEqual(switchCaseMap, expectedSwitchCasesSequence);
|
|
assert.deepEqual(switchCaseMap, expectedSwitchCasesSequence);
|
|
});
|
|
});
|
|
@@ -708,7 +718,8 @@ describe('BlockStatementControlFlowTransformer', function () {
|
|
});
|
|
});
|
|
|
|
|
|
describe('switch-case map', () => {
|
|
describe('switch-case map', () => {
|
|
- const switchCaseMapVariableRegExp: RegExp = /const *_0x(?:[a-f0-9]){4,6} *= *_0x(?:[a-f0-9]){4,6}\['.*'\]\['split'\]\('\|'\)/;
|
|
|
|
|
|
+ const switchCaseMapVariableRegExp: RegExp = /const *_0x(?:[a-f0-9]){4,6} *= *_0x(?:[a-f0-9]){4,6}\['.*'\]\['split'\]\('\|'\);/;
|
|
|
|
+ const switchCaseMapIndexVariableRegExp: RegExp = /let *_0x(?:[a-f0-9]){4,6} *= *0x0;/;
|
|
const switchCaseMapStringRegExp: RegExp = /const *_0x(?:[a-f0-9]){4,6} *= *\{'.*' *: *'(.*)'\};/;
|
|
const switchCaseMapStringRegExp: RegExp = /const *_0x(?:[a-f0-9]){4,6} *= *\{'.*' *: *'(.*)'\};/;
|
|
const expectedSwitchCasesSequence: string[] = ['0', '1', '2', '3', '4'];
|
|
const expectedSwitchCasesSequence: string[] = ['0', '1', '2', '3', '4'];
|
|
|
|
|
|
@@ -724,6 +735,10 @@ describe('BlockStatementControlFlowTransformer', function () {
|
|
assert.match(obfuscatedCode, switchCaseMapVariableRegExp);
|
|
assert.match(obfuscatedCode, switchCaseMapVariableRegExp);
|
|
});
|
|
});
|
|
|
|
|
|
|
|
+ it('should use correct kind of index variable for switch-case map', () => {
|
|
|
|
+ assert.match(obfuscatedCode, switchCaseMapIndexVariableRegExp);
|
|
|
|
+ });
|
|
|
|
+
|
|
it('should use correct kind of variable for switch cases sequence', () => {
|
|
it('should use correct kind of variable for switch cases sequence', () => {
|
|
assert.deepEqual(switchCaseMap, expectedSwitchCasesSequence);
|
|
assert.deepEqual(switchCaseMap, expectedSwitchCasesSequence);
|
|
});
|
|
});
|
|
@@ -747,8 +762,9 @@ describe('BlockStatementControlFlowTransformer', function () {
|
|
});
|
|
});
|
|
|
|
|
|
describe('switch-case map', () => {
|
|
describe('switch-case map', () => {
|
|
- const switchCaseMapVariableRegExp: RegExp = /let *_0x(?:[a-f0-9]){4,6} *= *_0x(?:[a-f0-9]){4,6}\['.*'\]\['split'\]\('\|'\)/;
|
|
|
|
- const switchCaseMapStringRegExp: RegExp = /let *_0x(?:[a-f0-9]){4,6} *= *\{'.*' *: *'(.*)'\};/;
|
|
|
|
|
|
+ const switchCaseMapVariableRegExp: RegExp = /const *_0x(?:[a-f0-9]){4,6} *= *_0x(?:[a-f0-9]){4,6}\['.*'\]\['split'\]\('\|'\)/;
|
|
|
|
+ const switchCaseMapIndexVariableRegExp: RegExp = /let *_0x(?:[a-f0-9]){4,6} *= *0x0;/;
|
|
|
|
+ const switchCaseMapStringRegExp: RegExp = /const *_0x(?:[a-f0-9]){4,6} *= *\{'.*' *: *'(.*)'\};/;
|
|
const expectedSwitchCasesSequence: string[] = ['0', '1', '2', '3', '4'];
|
|
const expectedSwitchCasesSequence: string[] = ['0', '1', '2', '3', '4'];
|
|
|
|
|
|
let switchCaseMap: string[];
|
|
let switchCaseMap: string[];
|
|
@@ -763,6 +779,10 @@ describe('BlockStatementControlFlowTransformer', function () {
|
|
assert.match(obfuscatedCode, switchCaseMapVariableRegExp);
|
|
assert.match(obfuscatedCode, switchCaseMapVariableRegExp);
|
|
});
|
|
});
|
|
|
|
|
|
|
|
+ it('should use correct kind of index variable for switch-case map', () => {
|
|
|
|
+ assert.match(obfuscatedCode, switchCaseMapIndexVariableRegExp);
|
|
|
|
+ });
|
|
|
|
+
|
|
it('should use correct kind of variable for switch cases sequence', () => {
|
|
it('should use correct kind of variable for switch cases sequence', () => {
|
|
assert.deepEqual(switchCaseMap, expectedSwitchCasesSequence);
|
|
assert.deepEqual(switchCaseMap, expectedSwitchCasesSequence);
|
|
});
|
|
});
|