This commit is contained in:
sanex3339
2016-06-01 13:43:37 +03:00
parent 8e6bd2527d
commit 39f3741d0d
5 changed files with 29 additions and 12 deletions
@@ -31,6 +31,9 @@ class UnicodeArrayNode extends Node_1.Node {
this.updateNode();
return super.getNode();
}
updateNodeData(data) {
this.unicodeArray.push(data);
}
getNodeStructure() {
return {
'type': NodeType_1.NodeType.VariableDeclaration,
+6 -6
View File
@@ -41,19 +41,19 @@ class NodeObfuscator {
return this.replaceLiteralValueByUnicodeArrayCall(value);
}
replaceLiteralValueByUnicodeArrayCall(value) {
let unicodeArray = this.nodes.get('unicodeArrayNode').getNodeData(), sameIndex = unicodeArray.indexOf(value), index, hexadecimalIndex;
if (sameIndex < 0) {
index = unicodeArray.length;
unicodeArray.push(value);
let unicodeArrayNode = this.nodes.get('unicodeArrayNode'), unicodeArray = unicodeArrayNode.getNodeData(), sameIndex = unicodeArray.indexOf(value), index, hexadecimalIndex;
if (sameIndex >= 0) {
index = sameIndex;
}
else {
index = sameIndex;
index = unicodeArray.length;
unicodeArrayNode.updateNodeData(value);
}
hexadecimalIndex = this.replaceLiteralNumberByHexadecimalValue(index);
if (this.options['wrapUnicodeArrayCalls']) {
return `${this.nodes.get('unicodeArrayCallsWrapper').getNodeIdentifier()}('${hexadecimalIndex}')`;
}
return `${this.nodes.get('unicodeArrayNode').getNodeIdentifier()}[${hexadecimalIndex}]`;
return `${unicodeArrayNode.getNodeIdentifier()}[${hexadecimalIndex}]`;
}
}
exports.NodeObfuscator = NodeObfuscator;
@@ -87,6 +87,13 @@ export class UnicodeArrayNode extends Node {
return super.getNode();
}
/**
* @param data
*/
public updateNodeData (data: string): void {
this.unicodeArray.push(data);
}
/**
* @returns {INode}
*/
+5
View File
@@ -34,4 +34,9 @@ export interface ICustomNode {
setNode (node: INode): void;
updateNode (): void;
/**
* @param data
*/
updateNodeData ? (data: any): void;
}
+8 -6
View File
@@ -7,6 +7,7 @@ import { JSFuck } from "../enums/JSFuck";
import { NodeUtils } from "../NodeUtils";
import { Utils } from '../Utils';
import {UnicodeArrayNode} from "../custom-nodes/unicode-array-nodes/UnicodeArrayNode";
export abstract class NodeObfuscator implements INodeObfuscator {
/**
@@ -106,16 +107,17 @@ export abstract class NodeObfuscator implements INodeObfuscator {
* @returns {string}
*/
protected replaceLiteralValueByUnicodeArrayCall (value: string): string {
let unicodeArray: string[] = this.nodes.get('unicodeArrayNode').getNodeData(),
let unicodeArrayNode: UnicodeArrayNode = <UnicodeArrayNode> this.nodes.get('unicodeArrayNode'),
unicodeArray: string[] = unicodeArrayNode.getNodeData(),
sameIndex: number = unicodeArray.indexOf(value),
index: number,
hexadecimalIndex: string;
if (sameIndex < 0) {
index = unicodeArray.length;
unicodeArray.push(value);
} else {
if (sameIndex >= 0) {
index = sameIndex;
} else {
index = unicodeArray.length;
unicodeArrayNode.updateNodeData(value);
}
hexadecimalIndex = this.replaceLiteralNumberByHexadecimalValue(index);
@@ -124,6 +126,6 @@ export abstract class NodeObfuscator implements INodeObfuscator {
return `${this.nodes.get('unicodeArrayCallsWrapper').getNodeIdentifier()}('${hexadecimalIndex}')`;
}
return `${this.nodes.get('unicodeArrayNode').getNodeIdentifier()}[${hexadecimalIndex}]`;
return `${unicodeArrayNode.getNodeIdentifier()}[${hexadecimalIndex}]`;
}
}