|
@@ -1,11 +1,8 @@
|
|
-/* tslint:disable:max-line-length */
|
|
|
|
-
|
|
|
|
|
|
+import * as esprima from 'esprima';
|
|
import * as estraverse from 'estraverse';
|
|
import * as estraverse from 'estraverse';
|
|
|
|
|
|
import { ITreeNode } from '../interfaces/nodes/ITreeNode';
|
|
import { ITreeNode } from '../interfaces/nodes/ITreeNode';
|
|
|
|
|
|
-import { NodeType } from "../enums/NodeType";
|
|
|
|
-
|
|
|
|
import { Node } from './Node';
|
|
import { Node } from './Node';
|
|
import { NodeUtils } from "../NodeUtils";
|
|
import { NodeUtils } from "../NodeUtils";
|
|
|
|
|
|
@@ -45,110 +42,33 @@ export class ConsoleOutputDisableExpressionNode extends Node {
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
|
|
+ * JSCrush version of following code
|
|
|
|
+ *
|
|
|
|
+ * (function () {
|
|
|
|
+ * var _console = []["filter"]["constructor"]("return this")().console;
|
|
|
|
+ * var _function = function () {};
|
|
|
|
+ *
|
|
|
|
+ * _console.log = _function;
|
|
|
|
+ * _console.info = _function;
|
|
|
|
+ * _console.warn = _function;
|
|
|
|
+ * _console.error = _function;
|
|
|
|
+ * _console
|
|
|
|
+ * })();
|
|
|
|
+ *
|
|
* @returns any
|
|
* @returns any
|
|
*/
|
|
*/
|
|
protected getNodeStructure (): any {
|
|
protected getNodeStructure (): any {
|
|
- return {
|
|
|
|
- "type": NodeType.ExpressionStatement,
|
|
|
|
- "expression": {
|
|
|
|
- "type": NodeType.CallExpression,
|
|
|
|
- "callee": {
|
|
|
|
- "type": NodeType.CallExpression,
|
|
|
|
- "callee": {
|
|
|
|
- "type": NodeType.MemberExpression,
|
|
|
|
- "computed": true,
|
|
|
|
- "object": {
|
|
|
|
- "type": NodeType.MemberExpression,
|
|
|
|
- "computed": true,
|
|
|
|
- "object": {
|
|
|
|
- "type": NodeType.ArrayExpression,
|
|
|
|
- "elements": []
|
|
|
|
- },
|
|
|
|
- "property": {
|
|
|
|
- "type": NodeType.Literal,
|
|
|
|
- "value": "filter",
|
|
|
|
- "raw": "\"filter\""
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
- "property": {
|
|
|
|
- "type": NodeType.Literal,
|
|
|
|
- "value": "constructor",
|
|
|
|
- "raw": "\"constructor\""
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
- "arguments": [
|
|
|
|
- {
|
|
|
|
- "type": NodeType.BinaryExpression,
|
|
|
|
- "operator": "+",
|
|
|
|
- "left": {
|
|
|
|
- "type": NodeType.BinaryExpression,
|
|
|
|
- "operator": "+",
|
|
|
|
- "left": {
|
|
|
|
- "type": NodeType.BinaryExpression,
|
|
|
|
- "operator": "+",
|
|
|
|
- "left": {
|
|
|
|
- "type": NodeType.BinaryExpression,
|
|
|
|
- "operator": "+",
|
|
|
|
- "left": {
|
|
|
|
- "type": NodeType.BinaryExpression,
|
|
|
|
- "operator": "+",
|
|
|
|
- "left": {
|
|
|
|
- "type": NodeType.BinaryExpression,
|
|
|
|
- "operator": "+",
|
|
|
|
- "left": {
|
|
|
|
- "type": NodeType.BinaryExpression,
|
|
|
|
- "operator": "+",
|
|
|
|
- "left": {
|
|
|
|
- "type": NodeType.Literal,
|
|
|
|
- "value": "_='(\u0002var \u0004\u0005[][\"filter\"]",
|
|
|
|
- "raw": "\"_='(\\u0002var \\u0004\\u0005[][\\\"filter\\\"]\""
|
|
|
|
- },
|
|
|
|
- "right": {
|
|
|
|
- "type": NodeType.Literal,
|
|
|
|
- "value": "[\"\u0006tructor\"](\"return t",
|
|
|
|
- "raw": "\"[\\\"\\u0006tructor\\\"](\\\"return t\""
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
- "right": {
|
|
|
|
- "type": NodeType.Literal,
|
|
|
|
- "value": "his\")()\u0003log\u0001error\u0001info\u0001warn\u0005\u0002};})()\u0001\u0005\u0002}\u0003\u0002function () {\u0003;\u0004.\u0006ole.\u0004_window\u0005 = \u0006cons';for(Y in $='\u0006\u0005\u0004\u0003\u0002\u0001')with",
|
|
|
|
- "raw": "\"his\\\")()\\u0003log\\u0001error\\u0001info\\u0001warn\\u0005\\u0002};})()\\u0001\\u0005\\u0002}\\u0003\\u0002function () {\\u0003;\\u0004.\\u0006ole.\\u0004_window\\u0005 = \\u0006cons';for(Y in $='\\u0006\\u0005\\u0004\\u0003\\u0002\\u0001')with\""
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
- "right": {
|
|
|
|
- "type": NodeType.Literal,
|
|
|
|
- "value": "(_.",
|
|
|
|
- "raw": "\"(_.\""
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
- "right": {
|
|
|
|
- "type": NodeType.Literal,
|
|
|
|
- "value": "split($[Y]))_=jo",
|
|
|
|
- "raw": "\"split($[Y]))_=jo\""
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
- "right": {
|
|
|
|
- "type": NodeType.Literal,
|
|
|
|
- "value": "in(pop",
|
|
|
|
- "raw": "\"in(pop\""
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
- "right": {
|
|
|
|
- "type": NodeType.Literal,
|
|
|
|
- "value": "());ev",
|
|
|
|
- "raw": "\"());ev\""
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
- "right": {
|
|
|
|
- "type": NodeType.Literal,
|
|
|
|
- "value": "al(_)",
|
|
|
|
- "raw": "\"al(_)\""
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- ]
|
|
|
|
- },
|
|
|
|
- "arguments": []
|
|
|
|
- }
|
|
|
|
- };
|
|
|
|
|
|
+ return NodeUtils.getBlockScopeNodeByIndex(
|
|
|
|
+ esprima.parse(`
|
|
|
|
+ (function () {
|
|
|
|
+ var _ = '(\u0004\u0006\u0003\u0005[]["filter"]["\u0007tructor"]("return this")().\u0003;\u0006\u0002\u0005\u0004};_\u0003.log\u0001.info\u0001.warn\u0001.error\u0001})();\u0001\u0005_\u0002;_\u0003\u0002function\u0003\u0007ole\u0004\u0002 () {\u0005 = \u0006var _\u0007cons', Y, $;
|
|
|
|
+ for (Y in $ = "\u0007\u0006\u0005\u0004\u0003\u0002\u0001") {
|
|
|
|
+ var arr = _.split($[Y]);
|
|
|
|
+ _ = arr.join(arr.pop());
|
|
|
|
+ }
|
|
|
|
+ []["filter"]["constructor"](_)();
|
|
|
|
+ })()
|
|
|
|
+ `)
|
|
|
|
+ );
|
|
}
|
|
}
|
|
}
|
|
}
|