Merge branch 'dev'

This commit is contained in:
sanex3339
2017-01-03 15:34:57 +03:00
6 changed files with 24 additions and 18 deletions
+4 -1
View File
@@ -1977,9 +1977,12 @@ var AbstractControlFlowReplacer = AbstractControlFlowReplacer_1 = function () {
if (RandomGeneratorUtils_1.RandomGeneratorUtils.getRandomFloat(0, 1) > usingExistingIdentifierChance && storageKeysForCurrentId && storageKeysForCurrentId.length) {
return RandomGeneratorUtils_1.RandomGeneratorUtils.getRandomGenerator().pickone(storageKeysForCurrentId);
}
var storageKey = RandomGeneratorUtils_1.RandomGeneratorUtils.getRandomString(3);
var storageKey = RandomGeneratorUtils_1.RandomGeneratorUtils.getRandomString(4);
storageKeysById.set(replacerId, [storageKey]);
this.replacerDataByControlFlowStorageId.set(controlFlowStorageId, storageKeysById);
if (controlFlowStorage.getStorage().has(storageKey)) {
console.log(1);
}
controlFlowStorage.set(storageKey, customNode);
return storageKey;
}
@@ -95,10 +95,13 @@ export abstract class AbstractControlFlowReplacer implements IControlFlowReplace
return RandomGeneratorUtils.getRandomGenerator().pickone(storageKeysForCurrentId);
}
const storageKey: string = RandomGeneratorUtils.getRandomString(3);
const storageKey: string = RandomGeneratorUtils.getRandomString(4);
storageKeysById.set(replacerId, [storageKey]);
this.replacerDataByControlFlowStorageId.set(controlFlowStorageId, storageKeysById);
if (controlFlowStorage.getStorage().has(storageKey)) {
console.log(1);
}
controlFlowStorage.set(storageKey, customNode);
return storageKey;
@@ -12,15 +12,15 @@ describe('FunctionControlFlowTransformer', () => {
const variableMatch: string = '_0x([a-z0-9]){4,6}';
const rootControlFlowStorageNodeMatch: string = `` +
`var *${variableMatch} *= *\\{` +
`'(\\\\x[a-f0-9]*){3}' *: *function *${variableMatch} *\\(${variableMatch}, *${variableMatch}\\) *\\{` +
`'(\\\\x[a-f0-9]*){4}' *: *function *${variableMatch} *\\(${variableMatch}, *${variableMatch}\\) *\\{` +
`return *${variableMatch} *\\+ *${variableMatch};` +
`\\}` +
`\\};` +
``;
const innerControlFlowStorageNodeMatch: string = `` +
`var *${variableMatch} *= *\\{` +
`'(\\\\x[a-f0-9]*){3}' *: *function *${variableMatch} *\\(${variableMatch}, *${variableMatch}\\) *\\{` +
`return *${variableMatch}\\['(\\\\x[a-f0-9]*){3}'\\]\\(${variableMatch}, *${variableMatch}\\);` +
`'(\\\\x[a-f0-9]*){4}' *: *function *${variableMatch} *\\(${variableMatch}, *${variableMatch}\\) *\\{` +
`return *${variableMatch}\\['(\\\\x[a-f0-9]*){4}'\\]\\(${variableMatch}, *${variableMatch}\\);` +
`\\}` +
`\\};` +
``;
@@ -101,10 +101,10 @@ describe('FunctionControlFlowTransformer', () => {
const obfuscatedCode: string = obfuscationResult.getObfuscatedCode();
const regexp: RegExp = new RegExp(
`var *${variableMatch} *= *\\{` +
`'(\\\\x[a-f0-9]*){3}' *: *function *${variableMatch} *\\(${variableMatch}, *${variableMatch}\\) *\\{` +
`'(\\\\x[a-f0-9]*){4}' *: *function *${variableMatch} *\\(${variableMatch}, *${variableMatch}\\) *\\{` +
`return *${variableMatch} *\\+ *${variableMatch};` +
`\\}, *` +
`'(\\\\x[a-f0-9]*){3}' *: *function *${variableMatch} *\\(${variableMatch}, *${variableMatch}\\) *\\{` +
`'(\\\\x[a-f0-9]*){4}' *: *function *${variableMatch} *\\(${variableMatch}, *${variableMatch}\\) *\\{` +
`return *${variableMatch} *- *${variableMatch};` +
`\\}` +
`\\};`
@@ -138,7 +138,7 @@ describe('FunctionControlFlowTransformer', () => {
const expectedValue: number = 0;
const regExp: RegExp = new RegExp(
`var *[a-zA-Z]{6} *= *\\{` +
`'(\\\\x[a-f0-9]*){3}' *: *function *_0x[0-9] *\\(${variableMatch}, *${variableMatch}\\) *\\{` +
`'(\\\\x[a-f0-9]*){4}' *: *function *_0x[0-9] *\\(${variableMatch}, *${variableMatch}\\) *\\{` +
`return *${variableMatch} *\\+ *${variableMatch};` +
`\\}` +
`\\};`
@@ -22,7 +22,7 @@ describe('BinaryExpressionControlFlowReplacer', () => {
}
);
const obfuscatedCode: string = obfuscationResult.getObfuscatedCode();
const controlFlowStorageCallRegExp: RegExp = /var *_0x([a-z0-9]){4,6} *= *_0x([a-z0-9]){4,6}\['(\\x[a-f0-9]*){3}'\]\(0x1, *0x2\);/;
const controlFlowStorageCallRegExp: RegExp = /var *_0x([a-z0-9]){4,6} *= *_0x([a-z0-9]){4,6}\['(\\x[a-f0-9]*){4}'\]\(0x1, *0x2\);/;
it('should replace binary expression node by call to control flow storage node', () => {
assert.match(obfuscatedCode, controlFlowStorageCallRegExp);
@@ -51,8 +51,8 @@ describe('BinaryExpressionControlFlowReplacer', () => {
}
);
const obfuscatedCode: string = obfuscationResult.getObfuscatedCode();
const controlFlowStorageCallRegExp1: RegExp = /var *_0x([a-z0-9]){4,6} *= *(_0x([a-z0-9]){4,6}\['(\\x[a-f0-9]*){3}'\])\(0x1, *0x2\);/;
const controlFlowStorageCallRegExp2: RegExp = /var *_0x([a-z0-9]){4,6} *= *(_0x([a-z0-9]){4,6}\['(\\x[a-f0-9]*){3}'\])\(0x2, *0x3\);/;
const controlFlowStorageCallRegExp1: RegExp = /var *_0x([a-z0-9]){4,6} *= *(_0x([a-z0-9]){4,6}\['(\\x[a-f0-9]*){4}'\])\(0x1, *0x2\);/;
const controlFlowStorageCallRegExp2: RegExp = /var *_0x([a-z0-9]){4,6} *= *(_0x([a-z0-9]){4,6}\['(\\x[a-f0-9]*){4}'\])\(0x2, *0x3\);/;
const firstMatchArray: RegExpMatchArray | null = obfuscatedCode.match(controlFlowStorageCallRegExp1);
const secondMatchArray: RegExpMatchArray | null = obfuscatedCode.match(controlFlowStorageCallRegExp2);
@@ -22,7 +22,7 @@ describe('CallExpressionControlFlowReplacer', () => {
}
);
const obfuscatedCode: string = obfuscationResult.getObfuscatedCode();
const controlFlowStorageCallRegExp: RegExp = /var *_0x([a-z0-9]){4,6} *= *_0x([a-z0-9]){4,6}\['(\\x[a-f0-9]*){3}'\]\(_0x([a-z0-9]){4,6}, *0x1, *0x2\);/;
const controlFlowStorageCallRegExp: RegExp = /var *_0x([a-z0-9]){4,6} *= *_0x([a-z0-9]){4,6}\['(\\x[a-f0-9]*){4}'\]\(_0x([a-z0-9]){4,6}, *0x1, *0x2\);/;
it('should replace call expression node by call to control flow storage node', () => {
assert.match(obfuscatedCode, controlFlowStorageCallRegExp);
@@ -51,8 +51,8 @@ describe('CallExpressionControlFlowReplacer', () => {
}
);
const obfuscatedCode: string = obfuscationResult.getObfuscatedCode();
const controlFlowStorageCallRegExp1: RegExp = /var *_0x([a-z0-9]){4,6} *= *(_0x([a-z0-9]){4,6}\['(\\x[a-f0-9]*){3}'\])\(_0x([a-z0-9]){4,6}, *0x1, *0x2\);/;
const controlFlowStorageCallRegExp2: RegExp = /var *_0x([a-z0-9]){4,6} *= *(_0x([a-z0-9]){4,6}\['(\\x[a-f0-9]*){3}'\])\(_0x([a-z0-9]){4,6}, *0x2, *0x3\);/;
const controlFlowStorageCallRegExp1: RegExp = /var *_0x([a-z0-9]){4,6} *= *(_0x([a-z0-9]){4,6}\['(\\x[a-f0-9]*){4}'\])\(_0x([a-z0-9]){4,6}, *0x1, *0x2\);/;
const controlFlowStorageCallRegExp2: RegExp = /var *_0x([a-z0-9]){4,6} *= *(_0x([a-z0-9]){4,6}\['(\\x[a-f0-9]*){4}'\])\(_0x([a-z0-9]){4,6}, *0x2, *0x3\);/;
const firstMatchArray: RegExpMatchArray | null = obfuscatedCode.match(controlFlowStorageCallRegExp1);
const secondMatchArray: RegExpMatchArray | null = obfuscatedCode.match(controlFlowStorageCallRegExp2);
@@ -22,7 +22,7 @@ describe('LogicalExpressionControlFlowReplacer', () => {
}
);
const obfuscatedCode: string = obfuscationResult.getObfuscatedCode();
const controlFlowStorageCallRegExp: RegExp = /var *_0x([a-z0-9]){4,6} *= *_0x([a-z0-9]){4,6}\['(\\x[a-f0-9]*){3}'\]\(!!\[\], *!\[\]\);/;
const controlFlowStorageCallRegExp: RegExp = /var *_0x([a-z0-9]){4,6} *= *_0x([a-z0-9]){4,6}\['(\\x[a-f0-9]*){4}'\]\(!!\[\], *!\[\]\);/;
it('should replace logical expression node by call to control flow storage node', () => {
assert.match(obfuscatedCode, controlFlowStorageCallRegExp);
@@ -51,8 +51,8 @@ describe('LogicalExpressionControlFlowReplacer', () => {
}
);
const obfuscatedCode: string = obfuscationResult.getObfuscatedCode();
const controlFlowStorageCallRegExp1: RegExp = /var *_0x([a-z0-9]){4,6} *= *(_0x([a-z0-9]){4,6}\['(\\x[a-f0-9]*){3}'\])\(!!\[\], *!\[\]\);/;
const controlFlowStorageCallRegExp2: RegExp = /var *_0x([a-z0-9]){4,6} *= *(_0x([a-z0-9]){4,6}\['(\\x[a-f0-9]*){3}'\])\(!\[\], *!!\[\]\);/;
const controlFlowStorageCallRegExp1: RegExp = /var *_0x([a-z0-9]){4,6} *= *(_0x([a-z0-9]){4,6}\['(\\x[a-f0-9]*){4}'\])\(!!\[\], *!\[\]\);/;
const controlFlowStorageCallRegExp2: RegExp = /var *_0x([a-z0-9]){4,6} *= *(_0x([a-z0-9]){4,6}\['(\\x[a-f0-9]*){4}'\])\(!\[\], *!!\[\]\);/;
const firstMatchArray: RegExpMatchArray | null = obfuscatedCode.match(controlFlowStorageCallRegExp1);
const secondMatchArray: RegExpMatchArray | null = obfuscatedCode.match(controlFlowStorageCallRegExp2);
@@ -86,7 +86,7 @@ describe('LogicalExpressionControlFlowReplacer', () => {
}
);
const obfuscatedCode: string = obfuscationResult.getObfuscatedCode();
const controlFlowStorageCallRegExp: RegExp = /var *_0x([a-z0-9]){4,6} *= *_0x([a-z0-9]){4,6}\['(\\x[a-f0-9]*){3}'\]\(!_0x([a-z0-9]){4,6}, *!_0x([a-z0-9]){4,6}\);/;
const controlFlowStorageCallRegExp: RegExp = /var *_0x([a-z0-9]){4,6} *= *_0x([a-z0-9]){4,6}\['(\\x[a-f0-9]*){4}'\]\(!_0x([a-z0-9]){4,6}, *!_0x([a-z0-9]){4,6}\);/;
it('should replace logical expression node with unary expression by call to control flow storage node', () => {
assert.match(obfuscatedCode, controlFlowStorageCallRegExp);