From 71be6ab3b9a4fd33b1a08e7d4f27aa575cf29c87 Mon Sep 17 00:00:00 2001 From: sanex3339 Date: Tue, 20 Jun 2017 00:41:02 +0300 Subject: [PATCH] Fixed https://github.com/javascript-obfuscator/javascript-obfuscator/issues/57 Refactoring --- dist/index.js | 2 +- package.json | 10 +- src/Obfuscator.ts | 4 +- src/cli/sanitizers/SourceMapModeSanitizer.ts | 2 +- .../StringArrayEncodingSanitizer.ts | 6 +- src/custom-nodes/AbstractCustomNodeGroup.ts | 10 +- .../group/ConsoleOutputCustomNodeGroup.ts | 5 +- .../group/DebugProtectionCustomNodeGroup.ts | 5 +- .../group/DomainLockCustomNodeGroup.ts | 5 +- .../NodeCallsControllerFunctionNode.ts | 7 +- .../group/SelfDefendingCustomNodeGroup.ts | 5 +- .../StringArrayCallsWrapper.ts | 4 +- .../group/StringArrayCustomNodeGroup.ts | 5 +- src/enums/JSFuck.ts | 112 +++++------ src/enums/NodeType.ts | 76 ++++---- src/enums/SourceMapMode.ts | 8 +- src/enums/StringArrayEncoding.ts | 8 +- src/enums/VisitorDirection.ts | 10 +- src/enums/event-emitters/ObfuscationEvent.ts | 13 +- .../custom-nodes/ICustomNodeGroup.d.ts | 6 +- .../IObfuscationEventEmitter.d.ts | 6 +- .../IEncodedValue.d.ts | 2 +- .../IStringArrayIndexData.d.ts | 4 + .../StringLiteralObfuscatingReplacer.ts | 99 +++++++--- .../ControlFlowFlatteningThresholdRule.ts | 9 +- .../normalizer-rules/DeadCodeInjectionRule.ts | 17 +- .../DeadCodeInjectionThresholdRule.ts | 9 +- .../normalizer-rules/SelfDefendingRule.ts | 9 +- .../StringArrayEncodingRule.ts | 7 +- .../normalizer-rules/StringArrayRule.ts | 13 +- .../StringArrayThresholdRule.ts | 13 +- .../SelfDefendingTemplate.ts | 8 +- .../SelfDefendingTemplate.ts | 8 +- .../SelfDefendingTemplate.ts | 4 +- .../event-emitters/TObfuscationEvent.d.ts | 1 - src/utils/Utils.ts | 22 +-- .../JavaScriptObfuscator.spec.ts | 2 +- ...ockStatementControlFlowTransformer.spec.ts | 8 +- .../LiteralTransformer.spec.ts | 4 +- test/unit-tests/utils/utils/Utils.spec.ts | 12 +- yarn.lock | 180 +++++++++++++----- 41 files changed, 415 insertions(+), 325 deletions(-) rename src/interfaces/node-transformers/obfuscating-transformers/{ => obfuscating-replacers/literal-obfuscating-replacers}/IEncodedValue.d.ts (73%) create mode 100644 src/interfaces/node-transformers/obfuscating-transformers/obfuscating-replacers/literal-obfuscating-replacers/IStringArrayIndexData.d.ts delete mode 100644 src/types/event-emitters/TObfuscationEvent.d.ts diff --git a/dist/index.js b/dist/index.js index d446ed99..a3320b0a 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1,2 +1,2 @@ -require("source-map-support").install(),module.exports=function(e){function t(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var r={};return t.m=e,t.c=r,t.i=function(e){return e},t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:n})},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=39)}([function(e,t){e.exports=require("inversify")},function(e,t){e.exports=require("tslib")},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ServiceIdentifiers={Factory__ICalleeDataExtractor:Symbol("Factory"),Factory__IControlFlowReplacer:Symbol("Factory"),Factory__ICustomNode:Symbol("Factory"),Factory__ICustomNodeGroup:Symbol("Factory"),Factory__IIdentifierObfuscatingReplacer:Symbol("Factory"),Factory__INodeTransformer:Symbol("Factory"),Factory__IObfuscationResult:Symbol("Factory"),Factory__IObfuscatingReplacer:Symbol("Factory"),Factory__TControlFlowStorage:Symbol("Factory"),ICalleeDataExtractor:Symbol("ICalleeDataExtractor"),ICustomNodeGroup:Symbol("ICustomNodeGroup"),IControlFlowReplacer:Symbol("IControlFlowReplacer"),IDeadCodeInjectionReplacer:Symbol("IDeadCodeInjectionReplacer"),IIdentifierObfuscatingReplacer:Symbol("IIdentifierObfuscatingReplacer"),IJavaScriptObfuscator:Symbol("IJavaScriptObfuscator"),INodeTransformer:Symbol("INodeTransformer"),IObfuscationEventEmitter:Symbol("IObfuscationEventEmitter"),IObfuscationResult:Symbol("IObfuscationResult"),IObfuscator:Symbol("IObfuscator"),IOptions:Symbol("IOptions"),IObfuscatingReplacer:Symbol("IObfuscatingReplacer"),ISourceMapCorrector:Symbol("ISourceMapCorrector"),IStackTraceAnalyzer:Symbol("IStackTraceAnalyzer"),Newable__ICustomNode:Symbol("Newable"),Newable__TControlFlowStorage:Symbol("Newable"),TCustomNodeGroupStorage:Symbol("TCustomNodeGroupStorage"),TStringArrayStorage:Symbol("TStringArrayStorage")}},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},a=function(){function e(e,t){for(var r=0;r1&&void 0!==arguments[1]?arguments[1]:0;if(l.Node.isNodeHasBlockStatement(e)){if(void 0===e.body[t])throw new ReferenceError("Wrong index `"+t+"`. Block-statement body length is `"+e.body.length+"`");return e.body[t]}throw new TypeError("The specified node have no a block-statement")}},{key:"getBlockScopesOfNode",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=t.parentNode;if(!n)throw new ReferenceError("`parentNode` property of given node is `undefined`");if(l.Node.isBlockStatementNode(n)){if(!n.parentNode)throw new ReferenceError("`parentNode` property of `parentNode` of given node is `undefined`");-1!==e.nodesWithBlockScope.indexOf(n.parentNode.type)&&r.push(n)}return l.Node.isProgramNode(n)?(r.push(n),r):e.getBlockScopesOfNode(n,r)}},{key:"getNodeBlockScopeDepth",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=t.parentNode;if(!n)throw new ReferenceError("`parentNode` property of given node is `undefined`");return l.Node.isProgramNode(n)?r:l.Node.isBlockStatementNode(t)&&-1!==e.nodesWithBlockScope.indexOf(n.type)?e.getNodeBlockScopeDepth(n,++r):e.getNodeBlockScopeDepth(n,r)}},{key:"getUnaryExpressionArgumentNode",value:function(t){return l.Node.isUnaryExpressionNode(t.argument)?e.getUnaryExpressionArgumentNode(t.argument):t.argument}},{key:"parentize",value:function(e){var t=!0;return s.traverse(e,{enter:function(e,r){var n=void 0;t?(e.type===u.NodeType.Program?n=e:(n=f.Nodes.getProgramNode([e]),n.parentNode=n),t=!1):n=r||e,e.parentNode=n,e.obfuscatedNode=!1}}),e}},{key:"typedReplace",value:function(t,r,n){e.typedTraverse(t,r,n,"replace")}},{key:"typedTraverse",value:function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"traverse";s[n](e,{enter:function(e,n){if(e.type===t&&r.enter)return r.enter(e,n)},leave:function(e,n){if(e.type===t&&r.leave)return r.leave(e,n)}})}}]),e}();d.nodesWithBlockScope=[u.NodeType.ArrowFunctionExpression,u.NodeType.FunctionDeclaration,u.NodeType.FunctionExpression,u.NodeType.MethodDefinition,u.NodeType.Program],t.NodeUtils=d},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var o=function(){function e(e,t){for(var r=0;r1&&void 0!==arguments[1]?arguments[1]:e.randomGeneratorPool;return e.getRandomGenerator().string({length:t,pool:r})}},{key:"getRandomVariableName",value:function(t){var r="_"+i.Utils.hexadecimalPrefix,n=""+r+i.Utils.decToHex(e.getRandomInteger(1e4,99999999)).substr(0,t);return e.randomVariableNameSet.has(n)?e.getRandomVariableName(t):(e.randomVariableNameSet.add(n),n)}}]),e}();c.randomGeneratorPool="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",c.randomGeneratorPoolNumbers="0123456789",c.randomGeneratorPoolHexadecimal="abcdef"+c.randomGeneratorPoolNumbers,c.randomGeneratorPoolWithNumbers=""+c.randomGeneratorPool+c.randomGeneratorPoolNumbers,c.randomVariableNameSet=new Set,t.RandomGeneratorUtils=c},function(e,t,r){"use strict";function n(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"initialize",t=Object.keys(this)[0];return function(r,n){var o={configurable:!0,enumerable:!0},a=r[e];if(!a||"function"!=typeof a)throw new Error("`"+e+"` method with initialization logic not found. `@"+t+"` decorator requires `"+e+"` method");var i="_"+n,c=Object.getOwnPropertyDescriptor(r,i)||o,s=Object.getOwnPropertyDescriptor(r,e)||o,u=s.value;return Object.defineProperty(r,n,Object.assign({},c,{get:function(){if(void 0===this[i])throw new Error("Property `"+n+"` is not initialized! Initialize it first!");return this[i]},set:function(e){this[i]=e}})),Object.defineProperty(r,e,Object.assign({},s,{value:function(){u.apply(this,arguments),this[n]}})),c}}Object.defineProperty(t,"__esModule",{value:!0}),t.initializable=n},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var o=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:[];return{type:i.NodeType.Program,body:e,sourceType:"script",obfuscatedNode:!1}}},{key:"getArrayExpressionNode",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return{type:i.NodeType.ArrayExpression,elements:e}}},{key:"getAssignmentExpressionNode",value:function(e,t,r){return{type:i.NodeType.AssignmentExpression,operator:e,left:t,right:r,obfuscatedNode:!1}}},{key:"getBinaryExpressionNode",value:function(e,t,r){return{type:i.NodeType.BinaryExpression,operator:e,left:t,right:r,obfuscatedNode:!1}}},{key:"getBlockStatementNode",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return{type:i.NodeType.BlockStatement,body:e,obfuscatedNode:!1}}},{key:"getBreakStatement",value:function(e){var t={type:i.NodeType.BreakStatement,obfuscatedNode:!1};return e&&(t.label=e),t}},{key:"getCatchClauseNode",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return{type:i.NodeType.CatchClause,param:e.getIdentifierNode("err"),body:e.getBlockStatementNode(t),obfuscatedNode:!1}}},{key:"getCallExpressionNode",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return{type:i.NodeType.CallExpression,callee:e,arguments:t,obfuscatedNode:!1}}},{key:"getContinueStatement",value:function(e){var t={type:i.NodeType.ContinueStatement,obfuscatedNode:!1};return e&&(t.label=e),t}},{key:"getExpressionStatementNode",value:function(e){return{type:i.NodeType.ExpressionStatement,expression:e,obfuscatedNode:!1}}},{key:"getFunctionDeclarationNode",value:function(t,r,n){return{type:i.NodeType.FunctionDeclaration,id:e.getIdentifierNode(t),params:r,body:n,generator:!1,obfuscatedNode:!1}}},{key:"getFunctionExpressionNode",value:function(e,t){return{type:i.NodeType.FunctionExpression,params:e,body:t,generator:!1,obfuscatedNode:!1}}},{key:"getIfStatementNode",value:function(e,t,r){return Object.assign({type:i.NodeType.IfStatement,test:e,consequent:t},r&&{alternate:r},{obfuscatedNode:!1})}},{key:"getIdentifierNode",value:function(e){return{type:i.NodeType.Identifier,name:e,obfuscatedNode:!1}}},{key:"getLabeledStatement",value:function(e,t){return{type:i.NodeType.LabeledStatement,label:e,body:t,obfuscatedNode:!1}}},{key:"getLiteralNode",value:function(e,t){return t=void 0!==t?t:"'"+e+"'",{type:i.NodeType.Literal,value:e,raw:t,"x-verbatim-property":{content:t,precedence:a.Precedence.Primary},obfuscatedNode:!1}}},{key:"getLogicalExpressionNode",value:function(e,t,r){return{type:i.NodeType.LogicalExpression,operator:e,left:t,right:r,obfuscatedNode:!1}}},{key:"getMemberExpressionNode",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return{type:i.NodeType.MemberExpression,computed:r,object:e,property:t,obfuscatedNode:!1}}},{key:"getObjectExpressionNode",value:function(e){return{type:i.NodeType.ObjectExpression,properties:e,obfuscatedNode:!1}}},{key:"getPropertyNode",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return{type:i.NodeType.Property,key:e,value:t,kind:"init",method:!1,shorthand:!1,computed:r,obfuscatedNode:!1}}},{key:"getUnaryExpressionNode",value:function(e,t){var r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];return{type:i.NodeType.UnaryExpression,operator:e,argument:t,prefix:r,obfuscatedNode:!1}}},{key:"getReturnStatementNode",value:function(e){return{type:i.NodeType.ReturnStatement,argument:e,obfuscatedNode:!1}}},{key:"getSwitchStatementNode",value:function(e,t){return{type:i.NodeType.SwitchStatement,discriminant:e,cases:t,obfuscatedNode:!1}}},{key:"getSwitchCaseNode",value:function(e,t){return{type:i.NodeType.SwitchCase,test:e,consequent:t,obfuscatedNode:!1}}},{key:"getUpdateExpressionNode",value:function(e,t){return{type:i.NodeType.UpdateExpression,operator:e,argument:t,prefix:!1,obfuscatedNode:!1}}},{key:"getVariableDeclarationNode",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"var";return{type:i.NodeType.VariableDeclaration,declarations:e,kind:t,obfuscatedNode:!1}}},{key:"getVariableDeclaratorNode",value:function(e,t){return{type:i.NodeType.VariableDeclarator,id:e,init:t,obfuscatedNode:!1}}},{key:"getWhileStatementNode",value:function(e,t){return{type:i.NodeType.WhileStatement,test:e,body:t,obfuscatedNode:!1}}}]),e}();t.Nodes=c},function(e,t,r){"use strict";function n(e){if(Array.isArray(e)){for(var t=0,r=Array(e.length);t-1||0===e.indexOf("//")?e.split("/")[2]:e.split("/")[0],t=t.split(":")[0]}},{key:"isCeilNumber",value:function(e){return e%1==0}},{key:"strEnumify",value:function(e){return e}},{key:"stringRotate",value:function(e,t){if(!e)throw new ReferenceError("Cannot rotate empty string.");for(var r=0;r1&&void 0!==arguments[1]&&arguments[1],n=t+"-"+String(r);if(e.stringToUnicodeEscapeSequenceCache.has(n))return e.stringToUnicodeEscapeSequenceCache.get(n);var o=new RegExp("[\\s\\S]","g"),a=new RegExp("[^a-zA-Z0-9]"),i=new RegExp("[\\x00-\\x7F]"),c=void 0,s=void 0,u=t.replace(o,function(e){return r&&!a.exec(e)?e:(i.exec(e)?(c="\\x",s="00"):(c="\\u",s="0000"),""+c+(s+e.charCodeAt(0).toString(16)).slice(-s.length))});return e.stringToUnicodeEscapeSequenceCache.set(n,u),u}}]),e}();s.hexadecimalPrefix="0x",s.stringToUnicodeEscapeSequenceCache=new Map,t.Utils=s},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});!function(e){e[e.BinaryExpressionFunctionNode=0]="BinaryExpressionFunctionNode",e[e.BlockStatementControlFlowFlatteningNode=1]="BlockStatementControlFlowFlatteningNode",e[e.CallExpressionControlFlowStorageCallNode=2]="CallExpressionControlFlowStorageCallNode",e[e.CallExpressionFunctionNode=3]="CallExpressionFunctionNode",e[e.ControlFlowStorageNode=4]="ControlFlowStorageNode",e[e.ConsoleOutputDisableExpressionNode=5]="ConsoleOutputDisableExpressionNode",e[e.DebugProtectionFunctionCallNode=6]="DebugProtectionFunctionCallNode",e[e.DebugProtectionFunctionIntervalNode=7]="DebugProtectionFunctionIntervalNode",e[e.DebugProtectionFunctionNode=8]="DebugProtectionFunctionNode",e[e.DomainLockNode=9]="DomainLockNode",e[e.ExpressionWithOperatorControlFlowStorageCallNode=10]="ExpressionWithOperatorControlFlowStorageCallNode",e[e.LogicalExpressionFunctionNode=11]="LogicalExpressionFunctionNode",e[e.NodeCallsControllerFunctionNode=12]="NodeCallsControllerFunctionNode",e[e.SelfDefendingUnicodeNode=13]="SelfDefendingUnicodeNode",e[e.StringArrayCallsWrapper=14]="StringArrayCallsWrapper",e[e.StringArrayNode=15]="StringArrayNode",e[e.StringArrayRotateFunctionNode=16]="StringArrayRotateFunctionNode",e[e.StringLiteralControlFlowStorageCallNode=17]="StringLiteralControlFlowStorageCallNode",e[e.StringLiteralNode=18]="StringLiteralNode"}(t.CustomNode||(t.CustomNode={}))},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var o=r(1),a=r(0),i=r(2),c=r(4),s=function e(t){n(this,e),this.nodeIdentifier=c.RandomGeneratorUtils.getRandomInteger(0,1e4),this.options=t};s=o.__decorate([a.injectable(),o.__param(0,a.inject(i.ServiceIdentifiers.IOptions)),o.__metadata("design:paramtypes",[Object])],s),t.AbstractNodeTransformer=s},function(e,t){e.exports=require("estraverse")},function(e,t){e.exports=require("string-template")},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(9);t.NodeType=n.Utils.strEnumify({ArrayExpression:"ArrayExpression",ArrowFunctionExpression:"ArrowFunctionExpression",AssignmentExpression:"AssignmentExpression",AssignmentPattern:"AssignmentPattern",BinaryExpression:"BinaryExpression",BlockStatement:"BlockStatement",BreakStatement:"BreakStatement",CallExpression:"CallExpression",CatchClause:"CatchClause",ClassDeclaration:"ClassDeclaration",ContinueStatement:"ContinueStatement",ExpressionStatement:"ExpressionStatement",FunctionDeclaration:"FunctionDeclaration",FunctionExpression:"FunctionExpression",Identifier:"Identifier",IfStatement:"IfStatement",LabeledStatement:"LabeledStatement",Literal:"Literal",LogicalExpression:"LogicalExpression",MemberExpression:"MemberExpression",MethodDefinition:"MethodDefinition",ObjectExpression:"ObjectExpression",ObjectPattern:"ObjectPattern",Program:"Program",Property:"Property",ReturnStatement:"ReturnStatement",SwitchCase:"SwitchCase",SwitchStatement:"SwitchStatement",TemplateLiteral:"TemplateLiteral",TryStatement:"TryStatement",UnaryExpression:"UnaryExpression",UpdateExpression:"UpdateExpression",VariableDeclaration:"VariableDeclaration",VariableDeclarator:"VariableDeclarator",WhileStatement:"WhileStatement"})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ObfuscationEvent={AfterObfuscation:"afterObfuscation",BeforeObfuscation:"beforeObfuscation"}},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var o=function(){function e(e,t){for(var r=0;r1&&void 0!==arguments[1]?arguments[1]:{},r=new i.InversifyContainerFacade(t),n=r.get(a.ServiceIdentifiers.IOptions);s.RandomGeneratorUtils.initializeRandomGenerator(n.seed);var o=r.get(a.ServiceIdentifiers.IJavaScriptObfuscator),c=o.obfuscate(e);return s.RandomGeneratorUtils.clearRandomGenerator(),c}},{key:"runCLI",value:function(e){new c.JavaScriptObfuscatorCLI(e).run()}}]),e}();t.JavaScriptObfuscator=u},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var o=function(){function e(e,t){for(var r=0;r3&&void 0!==arguments[3]?arguments[3]:0,a=void 0;a=t.length?e.getOptimalBlockScope(t,o):r,e.prependNode(a,n)}},{key:"getOptimalBlockScope",value:function(t,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1/0,o=t[r];if(n<=0)throw new Error("Invalid `deep` argument value. Value should be bigger then 0.");return n>1&&o.stackTrace.length?e.getOptimalBlockScope(o.stackTrace,0,--n):o.callee}},{key:"getRandomStackTraceIndex",value:function(e){return i.RandomGeneratorUtils.getRandomInteger(0,Math.max(0,Math.round(e-1)))}},{key:"insertNodeAtIndex",value:function(t,r,o){e.validateBodyStatements(r)||(r=[]),r=e.parentizeBodyStatementsBeforeAppend(t,r),t.body=[].concat(n(t.body.slice(0,o)),n(r),n(t.body.slice(o)))}},{key:"prependNode",value:function(t,r){e.validateBodyStatements(r)||(r=[]),r=e.parentizeBodyStatementsBeforeAppend(t,r),t.body=[].concat(n(r),n(t.body))}},{key:"parentizeBodyStatementsBeforeAppend",value:function(e,t){return t.forEach(function(t){t.parentNode=e}),t}},{key:"validateBodyStatements",value:function(e){return e.every(function(e){return!!e&&e.hasOwnProperty("type")})}}]),e}();t.NodeAppender=c},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var o=function(){function e(e,t){for(var r=0;r>8-o%1*8)){if((n=e.charCodeAt(o+=.75))>255)throw new Error("'btoa' failed: The string to be encoded contains characters outside of the Latin1 range.");r=r<<8|n}return t}},{key:"hideString",value:function(e,t){var r=a.RandomGeneratorUtils.getRandomGenerator().string({length:t,pool:a.RandomGeneratorUtils.randomGeneratorPool}),n=r.replace(new RegExp("["+function(e){return e.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")}(e)+"]","g"),""),o=n.split("");return a.RandomGeneratorUtils.getRandomGenerator().shuffle(o),n=o.join(""),[function(e,t){for(var r=-1,n=-1,o="";r1&&void 0!==arguments[1]&&arguments[1];this.storage=new Map([].concat(n(this.storage),n(e.getStorage()))),t&&(this.storageId=e.getStorageId())}},{key:"set",value:function(e,t){this.storage.set(e,t)}}]),e}();c.__decorate([u.initializable(),c.__metadata("design:type",String)],f.prototype,"storageId",void 0),c.__decorate([u.initializable(),c.__metadata("design:type",Map)],f.prototype,"storage",void 0),f=c.__decorate([s.injectable()],f),t.MapStorage=f},function(e,t){e.exports=require("esprima")},function(e,t){e.exports=require("path")},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(16);e.exports=n.JavaScriptObfuscator},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var o=function(){function e(e,t){for(var r=0;r [options]").option("-o, --output ","Output path for obfuscated code").option("--compact ","Disable one line output code compacting",s.BooleanSanitizer).option("--controlFlowFlattening ","Enables control flow flattening",s.BooleanSanitizer).option("--controlFlowFlatteningThreshold ","The probability that the control flow flattening transformation will be applied to the node",parseFloat).option("--deadCodeInjection ","Enables dead code injection",s.BooleanSanitizer).option("--deadCodeInjectionThreshold ","The probability that the dead code injection transformation will be applied to the node",parseFloat).option("--debugProtection ","Disable browser Debug panel (can cause DevTools enabled browser freeze)",s.BooleanSanitizer).option("--debugProtectionInterval ","Disable browser Debug panel even after page was loaded (can cause DevTools enabled browser freeze)",s.BooleanSanitizer).option("--disableConsoleOutput ","Allow console.log, console.info, console.error and console.warn messages output into browser console",s.BooleanSanitizer).option("--domainLock ","Blocks the execution of the code in domains that do not match the passed RegExp patterns (comma separated)",function(e){return e.split(",")}).option("--mangle ","Enables mangling of variable names",s.BooleanSanitizer).option("--reservedNames ","Disable obfuscation of variable names, function names and names of function parameters that match the passed RegExp patterns (comma separated)",function(e){return e.split(",")}).option("--rotateStringArray ","Disable rotation of unicode array values during obfuscation",s.BooleanSanitizer).option("--seed ","Sets seed for random generator. This is useful for creating repeatable results.",parseFloat).option("--selfDefending ","Disables self-defending for obfuscated code",s.BooleanSanitizer).option("--sourceMap ","Enables source map generation",s.BooleanSanitizer).option("--sourceMapBaseUrl ","Sets base url to the source map import url when `--sourceMapMode=separate`").option("--sourceMapFileName ","Sets file name for output source map when `--sourceMapMode=separate`").option("--sourceMapMode [inline, separate]","Specify source map output mode",u.SourceMapModeSanitizer).option("--stringArray ","Disables gathering of all literal strings into an array and replacing every literal string with an array call",s.BooleanSanitizer).option("--stringArrayEncoding [true, false, base64, rc4]","Encodes all strings in strings array using base64 or rc4 (this option can slow down your code speed",l.StringArrayEncodingSanitizer).option("--stringArrayThreshold ","The probability that the literal string will be inserted into stringArray (Default: 0.8, Min: 0, Max: 1)",parseFloat).option("--unicodeEscapeSequence ","Allows to enable/disable string conversion to unicode escape sequence",s.BooleanSanitizer).parse(this.rawArguments)}},{key:"configureHelp",value:function(){this.commands.on("--help",function(){console.log(" Examples:\n"),console.log(" %> javascript-obfuscator in.js --compact true --selfDefending false"),console.log(" %> javascript-obfuscator in.js --output out.js --compact true --selfDefending false"),console.log("")})}},{key:"getData",value:function(){this.sourceCode=f.CLIUtils.readFile(this.inputPath)}},{key:"processData",value:function(){var e=this.buildOptions(),t=f.CLIUtils.getOutputCodePath(this.commands.output,this.inputPath);e.sourceMap?this.processDataWithSourceMap(t,e):this.processDataWithoutSourceMap(t,e)}},{key:"processDataWithoutSourceMap",value:function(e,t){var r=d.JavaScriptObfuscator.obfuscate(this.sourceCode,t).getObfuscatedCode();f.CLIUtils.writeFile(e,r)}},{key:"processDataWithSourceMap",value:function(e,t){var r=f.CLIUtils.getOutputSourceMapPath(e,t.sourceMapFileName||"");t=Object.assign({},t,{sourceMapFileName:i.basename(r)});var n=d.JavaScriptObfuscator.obfuscate(this.sourceCode,t);f.CLIUtils.writeFile(e,n.getObfuscatedCode()),"separate"===t.sourceMapMode&&n.getSourceMap()&&f.CLIUtils.writeFile(r,n.getSourceMap())}}]),e}();t.JavaScriptObfuscatorCLI=p},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BooleanSanitizer=function(e){return"true"===e||"1"===e}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(21);t.SourceMapModeSanitizer=function(e){if(!Object.keys(n.SourceMapMode).some(function(t){return n.SourceMapMode[t]===e}))throw new ReferenceError("Invalid value of `--sourceMapMode` option");return e}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(24);t.StringArrayEncodingSanitizer=function(e){switch(e){case"true":case"1":case n.StringArrayEncoding.base64:return!0;case n.StringArrayEncoding.rc4:return n.StringArrayEncoding.rc4;default:return!1}}},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var o=function(){function e(e,t){for(var r=0;r1&&void 0!==arguments[1]?arguments[1]:"";return t&&(e=e.substring(0,e.lastIndexOf("/"))+"/"+t),/\.js\.map$/.test(e)?/\.js$/.test(e)&&(e+=".map"):e=e.split(".")[0]+".js.map",e}},{key:"getPackageConfig",value:function(){return JSON.parse(a.readFileSync(c.join(c.dirname(a.realpathSync(process.argv[1])),"../package.json"),e.encoding))}},{key:"isFilePath",value:function(e){try{return a.statSync(e).isFile()}catch(e){return!1}}},{key:"readFile",value:function(t){return a.readFileSync(t,e.encoding)}},{key:"validateInputPath",value:function(t){if(!e.isFilePath(t))throw new ReferenceError("Given input path must be a valid file path");if(-1===e.availableInputExtensions.indexOf(c.extname(t)))throw new ReferenceError("Input file must have .js extension")}},{key:"writeFile",value:function(t,r){i.sync(c.dirname(t)),a.writeFileSync(t,r,{encoding:e.encoding})}}]),e}();s.availableInputExtensions=[".js"],s.encoding="utf8",t.CLIUtils=s},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(17),o=r(0),a=r(2),i=r(10),c=r(30),s=r(56),u=r(69),l=r(71),f=r(74),d=r(78),p=r(57),y=r(58),b=r(62),m=r(59),g=r(63),v=r(55),h=r(66),_=r(67),N=r(68),O=r(70),S=r(64),C=r(60),w=r(72),j=r(73),I=r(75),E=r(76),T=r(77),F=r(65),k=r(61);t.customNodesModule=new o.ContainerModule(function(e){e(a.ServiceIdentifiers.Newable__ICustomNode).toConstructor(p.BinaryExpressionFunctionNode).whenTargetNamed(i.CustomNode.BinaryExpressionFunctionNode),e(a.ServiceIdentifiers.Newable__ICustomNode).toConstructor(y.BlockStatementControlFlowFlatteningNode).whenTargetNamed(i.CustomNode.BlockStatementControlFlowFlatteningNode),e(a.ServiceIdentifiers.Newable__ICustomNode).toConstructor(b.CallExpressionControlFlowStorageCallNode).whenTargetNamed(i.CustomNode.CallExpressionControlFlowStorageCallNode),e(a.ServiceIdentifiers.Newable__ICustomNode).toConstructor(m.CallExpressionFunctionNode).whenTargetNamed(i.CustomNode.CallExpressionFunctionNode),e(a.ServiceIdentifiers.Newable__ICustomNode).toConstructor(g.ControlFlowStorageNode).whenTargetNamed(i.CustomNode.ControlFlowStorageNode),e(a.ServiceIdentifiers.Newable__ICustomNode).toConstructor(v.ConsoleOutputDisableExpressionNode).whenTargetNamed(i.CustomNode.ConsoleOutputDisableExpressionNode),e(a.ServiceIdentifiers.Newable__ICustomNode).toConstructor(h.DebugProtectionFunctionCallNode).whenTargetNamed(i.CustomNode.DebugProtectionFunctionCallNode),e(a.ServiceIdentifiers.Newable__ICustomNode).toConstructor(_.DebugProtectionFunctionIntervalNode).whenTargetNamed(i.CustomNode.DebugProtectionFunctionIntervalNode),e(a.ServiceIdentifiers.Newable__ICustomNode).toConstructor(N.DebugProtectionFunctionNode).whenTargetNamed(i.CustomNode.DebugProtectionFunctionNode),e(a.ServiceIdentifiers.Newable__ICustomNode).toConstructor(O.DomainLockNode).whenTargetNamed(i.CustomNode.DomainLockNode),e(a.ServiceIdentifiers.Newable__ICustomNode).toConstructor(S.ExpressionWithOperatorControlFlowStorageCallNode).whenTargetNamed(i.CustomNode.ExpressionWithOperatorControlFlowStorageCallNode),e(a.ServiceIdentifiers.Newable__ICustomNode).toConstructor(C.LogicalExpressionFunctionNode).whenTargetNamed(i.CustomNode.LogicalExpressionFunctionNode),e(a.ServiceIdentifiers.Newable__ICustomNode).toConstructor(w.NodeCallsControllerFunctionNode).whenTargetNamed(i.CustomNode.NodeCallsControllerFunctionNode),e(a.ServiceIdentifiers.Newable__ICustomNode).toConstructor(j.SelfDefendingUnicodeNode).whenTargetNamed(i.CustomNode.SelfDefendingUnicodeNode),e(a.ServiceIdentifiers.Newable__ICustomNode).toConstructor(I.StringArrayCallsWrapper).whenTargetNamed(i.CustomNode.StringArrayCallsWrapper),e(a.ServiceIdentifiers.Newable__ICustomNode).toConstructor(E.StringArrayNode).whenTargetNamed(i.CustomNode.StringArrayNode),e(a.ServiceIdentifiers.Newable__ICustomNode).toConstructor(T.StringArrayRotateFunctionNode).whenTargetNamed(i.CustomNode.StringArrayRotateFunctionNode),e(a.ServiceIdentifiers.Newable__ICustomNode).toConstructor(F.StringLiteralControlFlowStorageCallNode).whenTargetNamed(i.CustomNode.StringLiteralControlFlowStorageCallNode),e(a.ServiceIdentifiers.Newable__ICustomNode).toConstructor(k.StringLiteralNode).whenTargetNamed(i.CustomNode.StringLiteralNode),e(a.ServiceIdentifiers.ICustomNodeGroup).to(s.ConsoleOutputCustomNodeGroup).whenTargetNamed(c.CustomNodeGroup.ConsoleOutputCustomNodeGroup),e(a.ServiceIdentifiers.ICustomNodeGroup).to(u.DebugProtectionCustomNodeGroup).whenTargetNamed(c.CustomNodeGroup.DebugProtectionCustomNodeGroup),e(a.ServiceIdentifiers.ICustomNodeGroup).to(l.DomainLockCustomNodeGroup).whenTargetNamed(c.CustomNodeGroup.DomainLockCustomNodeGroup),e(a.ServiceIdentifiers.ICustomNodeGroup).to(f.SelfDefendingCustomNodeGroup).whenTargetNamed(c.CustomNodeGroup.SelfDefendingCustomNodeGroup),e(a.ServiceIdentifiers.ICustomNodeGroup).to(d.StringArrayCustomNodeGroup).whenTargetNamed(c.CustomNodeGroup.StringArrayCustomNodeGroup),e(a.ServiceIdentifiers.Factory__ICustomNode).toFactory(function(e){var t=new Map,r=void 0;return function(n){if(r||(r=e.container.get(a.ServiceIdentifiers.IOptions)),t.has(n))return new(t.get(n));var o=e.container.getNamed(a.ServiceIdentifiers.Newable__ICustomNode,n);return t.set(n,o),new o(r)}}),e(a.ServiceIdentifiers.Factory__ICustomNodeGroup).toFactory(n.InversifyContainerFacade.getFactory(a.ServiceIdentifiers.ICustomNodeGroup))})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(17),o=r(0),a=r(2),i=r(31),c=r(84),s=r(85),u=r(86),l=r(87);t.controlFlowTransformersModule=new o.ContainerModule(function(e){e(a.ServiceIdentifiers.IControlFlowReplacer).to(c.BinaryExpressionControlFlowReplacer).whenTargetNamed(i.ControlFlowReplacer.BinaryExpressionControlFlowReplacer),e(a.ServiceIdentifiers.IControlFlowReplacer).to(s.CallExpressionControlFlowReplacer).whenTargetNamed(i.ControlFlowReplacer.CallExpressionControlFlowReplacer),e(a.ServiceIdentifiers.IControlFlowReplacer).to(u.LogicalExpressionControlFlowReplacer).whenTargetNamed(i.ControlFlowReplacer.LogicalExpressionControlFlowReplacer),e(a.ServiceIdentifiers.IControlFlowReplacer).to(l.StringLiteralControlFlowReplacer).whenTargetNamed(i.ControlFlowReplacer.StringLiteralControlFlowReplacer),e(a.ServiceIdentifiers.Factory__IControlFlowReplacer).toFactory(n.InversifyContainerFacade.getCacheFactory(a.ServiceIdentifiers.IControlFlowReplacer))})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(17),o=r(0),a=r(2),i=r(33),c=r(83),s=r(82),u=r(91),l=r(92),f=r(93),d=r(94),p=r(95),y=r(96),b=r(88),m=r(89),g=r(97),v=r(90),h=r(98);t.nodeTransformersModule=new o.ContainerModule(function(e){e(a.ServiceIdentifiers.INodeTransformer).to(s.BlockStatementControlFlowTransformer).whenTargetNamed(i.NodeTransformer.BlockStatementControlFlowTransformer),e(a.ServiceIdentifiers.INodeTransformer).to(u.DeadCodeInjectionTransformer).whenTargetNamed(i.NodeTransformer.DeadCodeInjectionTransformer),e(a.ServiceIdentifiers.INodeTransformer).to(c.FunctionControlFlowTransformer).whenTargetNamed(i.NodeTransformer.FunctionControlFlowTransformer),e(a.ServiceIdentifiers.INodeTransformer).to(b.MemberExpressionTransformer).whenTargetNamed(i.NodeTransformer.MemberExpressionTransformer),e(a.ServiceIdentifiers.INodeTransformer).to(m.MethodDefinitionTransformer).whenTargetNamed(i.NodeTransformer.MethodDefinitionTransformer),e(a.ServiceIdentifiers.INodeTransformer).to(v.TemplateLiteralTransformer).whenTargetNamed(i.NodeTransformer.TemplateLiteralTransformer),e(a.ServiceIdentifiers.INodeTransformer).to(l.CatchClauseTransformer).whenTargetNamed(i.NodeTransformer.CatchClauseTransformer),e(a.ServiceIdentifiers.INodeTransformer).to(f.FunctionDeclarationTransformer).whenTargetNamed(i.NodeTransformer.FunctionDeclarationTransformer),e(a.ServiceIdentifiers.INodeTransformer).to(d.FunctionTransformer).whenTargetNamed(i.NodeTransformer.FunctionTransformer),e(a.ServiceIdentifiers.INodeTransformer).to(p.LabeledStatementTransformer).whenTargetNamed(i.NodeTransformer.LabeledStatementTransformer),e(a.ServiceIdentifiers.INodeTransformer).to(y.LiteralTransformer).whenTargetNamed(i.NodeTransformer.LiteralTransformer),e(a.ServiceIdentifiers.INodeTransformer).to(g.ObjectExpressionTransformer).whenTargetNamed(i.NodeTransformer.ObjectExpressionTransformer),e(a.ServiceIdentifiers.INodeTransformer).to(h.VariableDeclarationTransformer).whenTargetNamed(i.NodeTransformer.VariableDeclarationTransformer),e(a.ServiceIdentifiers.Factory__INodeTransformer).toFactory(n.InversifyContainerFacade.getCacheFactory(a.ServiceIdentifiers.INodeTransformer))})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(17),o=r(0),a=r(2),i=r(18),c=r(32),s=r(99),u=r(100),l=r(101),f=r(102);t.obfuscatingTransformersModule=new o.ContainerModule(function(e){e(a.ServiceIdentifiers.IObfuscatingReplacer).to(u.BooleanLiteralObfuscatingReplacer).whenTargetNamed(c.LiteralObfuscatingReplacer.BooleanLiteralObfuscatingReplacer),e(a.ServiceIdentifiers.IObfuscatingReplacer).to(l.NumberLiteralObfuscatingReplacer).whenTargetNamed(c.LiteralObfuscatingReplacer.NumberLiteralObfuscatingReplacer),e(a.ServiceIdentifiers.IObfuscatingReplacer).to(f.StringLiteralObfuscatingReplacer).whenTargetNamed(c.LiteralObfuscatingReplacer.StringLiteralObfuscatingReplacer),e(a.ServiceIdentifiers.IIdentifierObfuscatingReplacer).to(s.BaseIdentifierObfuscatingReplacer).whenTargetNamed(i.IdentifierObfuscatingReplacer.BaseIdentifierObfuscatingReplacer),e(a.ServiceIdentifiers.Factory__IObfuscatingReplacer).toFactory(n.InversifyContainerFacade.getCacheFactory(a.ServiceIdentifiers.IObfuscatingReplacer)),e(a.ServiceIdentifiers.Factory__IIdentifierObfuscatingReplacer).toFactory(n.InversifyContainerFacade.getCacheFactory(a.ServiceIdentifiers.IIdentifierObfuscatingReplacer))})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(17),o=r(0),a=r(2),i=r(34),c=r(117),s=r(118),u=r(119),l=r(116);t.stackTraceAnalyzerModule=new o.ContainerModule(function(e){e(a.ServiceIdentifiers.IStackTraceAnalyzer).to(l.StackTraceAnalyzer).inSingletonScope(),e(a.ServiceIdentifiers.ICalleeDataExtractor).to(c.FunctionDeclarationCalleeDataExtractor).whenTargetNamed(i.CalleeDataExtractor.FunctionDeclarationCalleeDataExtractor),e(a.ServiceIdentifiers.ICalleeDataExtractor).to(s.FunctionExpressionCalleeDataExtractor).whenTargetNamed(i.CalleeDataExtractor.FunctionExpressionCalleeDataExtractor),e(a.ServiceIdentifiers.ICalleeDataExtractor).to(u.ObjectExpressionCalleeDataExtractor).whenTargetNamed(i.CalleeDataExtractor.ObjectExpressionCalleeDataExtractor),e(a.ServiceIdentifiers.Factory__ICalleeDataExtractor).toFactory(n.InversifyContainerFacade.getCacheFactory(a.ServiceIdentifiers.ICalleeDataExtractor))})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(0),o=r(2),a=r(121),i=r(122),c=r(123);t.storagesModule=new n.ContainerModule(function(e){e(o.ServiceIdentifiers.TCustomNodeGroupStorage).to(i.CustomNodeGroupStorage).inSingletonScope(),e(o.ServiceIdentifiers.TStringArrayStorage).to(c.StringArrayStorage).inSingletonScope(),e(o.ServiceIdentifiers.Newable__TControlFlowStorage).toConstructor(a.ControlFlowStorage),e(o.ServiceIdentifiers.Factory__TControlFlowStorage).toFactory(function(e){return function(){var t=e.container.get(o.ServiceIdentifiers.Newable__TControlFlowStorage);return new t}})})},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var i=function(){function e(e,t){for(var r=0;rthis.options.controlFlowFlatteningThreshold||m.blockStatementHasProhibitedStatements(e))return e;var r=e.body;if(r.length<=4)return e;var n=y.Utils.arrayRange(r.length),o=y.Utils.arrayShuffle(n),a=n.map(function(e){return o.indexOf(e)}),i=this.customNodeFactory(l.CustomNode.BlockStatementControlFlowFlatteningNode);return i.initialize(r,o,a),i.getNode()[0]}}],[{key:"blockStatementHasProhibitedStatements",value:function(e){return e.body.some(function(e){var t=d.Node.isBreakStatementNode(e)||d.Node.isContinueStatementNode(e),r=d.Node.isVariableDeclarationNode(e)&&("const"===e.kind||"let"===e.kind);return d.Node.isFunctionDeclarationNode(e)||t||r})}}]),t}(f.AbstractNodeTransformer);b=m=c.__decorate([s.injectable(),c.__param(0,s.inject(u.ServiceIdentifiers.Factory__ICustomNode)),c.__param(1,s.inject(u.ServiceIdentifiers.IOptions)),c.__metadata("design:paramtypes",[Function,Object])],b),t.BlockStatementControlFlowTransformer=b;var m},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var i=function(){function e(e,t){for(var r=0;rr.options.controlFlowFlatteningThreshold)return e;var o=_.controlFlowReplacersMap.get(e.type);return void 0===o?e:Object.assign({},r.controlFlowReplacerFactory(o).replace(e,n,t),{parentNode:n})}})}}],[{key:"getHostNode",value:function(e){var t=g.NodeUtils.getBlockScopesOfNode(e);return 1===t.length?e:(t.pop(),t.length>_.hostNodeSearchMinDepth&&t.splice(0,_.hostNodeSearchMinDepth),t.length>_.hostNodeSearchMaxDepth&&(t.length=_.hostNodeSearchMaxDepth),v.RandomGeneratorUtils.getRandomGenerator().pickone(t))}}]),t}(p.AbstractNodeTransformer);h.controlFlowReplacersMap=new Map([[d.NodeType.BinaryExpression,m.ControlFlowReplacer.BinaryExpressionControlFlowReplacer],[d.NodeType.CallExpression,m.ControlFlowReplacer.CallExpressionControlFlowReplacer],[d.NodeType.LogicalExpression,m.ControlFlowReplacer.LogicalExpressionControlFlowReplacer],[d.NodeType.Literal,m.ControlFlowReplacer.StringLiteralControlFlowReplacer]]),h.hostNodeSearchMinDepth=0,h.hostNodeSearchMaxDepth=2,h=_=c.__decorate([s.injectable(),c.__param(0,s.inject(u.ServiceIdentifiers.Factory__TControlFlowStorage)),c.__param(1,s.inject(u.ServiceIdentifiers.Factory__IControlFlowReplacer)),c.__param(2,s.inject(u.ServiceIdentifiers.Factory__ICustomNode)),c.__param(3,s.inject(u.ServiceIdentifiers.IOptions)),c.__metadata("design:paramtypes",[Function,Function,Function,Object])],h),t.FunctionControlFlowTransformer=h;var _},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var i=function(){function e(e,t){for(var r=0;r1){var o=d.Nodes.getBinaryExpressionNode("+",n.shift(),n.shift());return n.forEach(function(e){o=d.Nodes.getBinaryExpressionNode("+",o,e)}),o}return n[0]}}],[{key:"isLiteralNodeWithStringValue",value:function(e){return e&&f.Node.isLiteralNode(e)&&"string"==typeof e.value}}]),t}(l.AbstractNodeTransformer);p=y=c.__decorate([s.injectable(),c.__param(0,s.inject(u.ServiceIdentifiers.IOptions)),c.__metadata("design:paramtypes",[Object])],p),t.TemplateLiteralTransformer=p;var y},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var i=function(){function e(e,t){for(var r=0;rt.options.deadCodeInjectionThreshold)return e;var n=b.RandomGeneratorUtils.getRandomInteger(0,t.collectedBlockStatements.length-1),o=t.collectedBlockStatements.splice(n,1)[0];return o===e?e:g.replaceBlockStatementNode(e,o)}})}}],[{key:"collectBlockStatementNodes",value:function(e,t){var r=y.NodeUtils.clone(e),n=0,o=!0;l.replace(r,{enter:function(e,t){return d.Node.isBlockStatementNode(e)&&n++,n>g.maxNestedBlockStatementsCount||d.Node.isBreakStatementNode(e)||d.Node.isContinueStatementNode(e)?(o=!1,l.VisitorOption.Break):(d.Node.isIdentifierNode(e)&&!d.Node.isMemberExpressionNode(t)&&(e.name=b.RandomGeneratorUtils.getRandomVariableName(6)),e)}}),o&&t.push(r)}},{key:"replaceBlockStatementNode",value:function(e,t){var r=b.RandomGeneratorUtils.getMathRandom()>.5,n=b.RandomGeneratorUtils.getMathRandom()>.5,o=r?"===":"!==",a=b.RandomGeneratorUtils.getRandomString(3),i=n?a:b.RandomGeneratorUtils.getRandomString(3),c=void 0,s=void 0;r&&n||!r&&!n?(c=e,s=t):(c=t,s=e);var u=p.Nodes.getBlockStatementNode([p.Nodes.getIfStatementNode(p.Nodes.getBinaryExpressionNode(o,p.Nodes.getLiteralNode(a),p.Nodes.getLiteralNode(i)),c,s)]);return u=y.NodeUtils.parentize(u)}}]),t}(f.AbstractNodeTransformer);m.maxNestedBlockStatementsCount=4,m.minCollectedBlockStatementsCount=5,m=g=c.__decorate([s.injectable(),c.__param(0,s.inject(u.ServiceIdentifiers.IOptions)),c.__metadata("design:paramtypes",[Object])],m),t.DeadCodeInjectionTransformer=m;var g},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var i=function(){function e(e,t){for(var r=0;r=g.minimumLengthForStringArray&&y.RandomGeneratorUtils.getMathRandom()<=this.options.stringArrayThreshold}},{key:"getArrayHexadecimalIndex",value:function(e){if(this.stringLiteralHexadecimalIndexCache.has(e))return this.stringLiteralHexadecimalIndexCache.get(e);var t=this.stringArrayStorage.getLength(),r=""+b.Utils.hexadecimalPrefix+b.Utils.decToHex(t);return this.stringArrayStorage.set(t,e),this.stringLiteralHexadecimalIndexCache.set(e,r),r}},{key:"getEncodedValue",value:function(e){var t=void 0,r=void 0;switch(this.options.stringArrayEncoding){case l.StringArrayEncoding.rc4:r=y.RandomGeneratorUtils.getRandomGenerator().pickone(this.rc4Keys),t=d.CryptUtils.btoa(d.CryptUtils.rc4(e,r));break;case l.StringArrayEncoding.base64:t=d.CryptUtils.btoa(e);break;default:t=e}return t=b.Utils.stringToUnicodeEscapeSequence(t,!this.options.unicodeEscapeSequence),{encodedValue:t,key:r}}},{key:"replaceWithStringArrayCallNode",value:function(e){var t=this.getEncodedValue(e),r=t.encodedValue,n=t.key,o=b.Utils.stringRotate(this.stringArrayStorage.getStorageId(),1),a="_"+b.Utils.hexadecimalPrefix+o,i=[g.getHexadecimalLiteralNode(this.getArrayHexadecimalIndex(r))];return n&&i.push(g.getRc4KeyLiteralNode(b.Utils.stringToUnicodeEscapeSequence(n,!this.options.unicodeEscapeSequence))),p.Nodes.getCallExpressionNode(p.Nodes.getIdentifierNode(a),i)}}],[{key:"getHexadecimalLiteralNode",value:function(e){var t=p.Nodes.getLiteralNode(e);return t.obfuscatedNode=!0,t}},{key:"getRc4KeyLiteralNode",value:function(e){var t=p.Nodes.getLiteralNode(e);return t.obfuscatedNode=!0,t}}]),t}(f.AbstractObfuscatingReplacer);m.minimumLengthForStringArray=3,m=g=c.__decorate([s.injectable(),c.__param(0,s.inject(u.ServiceIdentifiers.TCustomNodeGroupStorage)),c.__param(1,s.inject(u.ServiceIdentifiers.TStringArrayStorage)),c.__param(2,s.inject(u.ServiceIdentifiers.IOptions)),c.__metadata("design:paramtypes",[Object,Object,Object])],m),t.StringLiteralObfuscatingReplacer=m;var g},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var o=r(1),a=r(0),i=r(141),c=r(26),s=r(104),u=r(105),l=f=function e(t){n(this,e),Object.assign(this,c.DEFAULT_PRESET,t);var r=i.validateSync(this,f.validatorOptions);if(r.length)throw new ReferenceError("Validation failed. errors:\n"+u.ValidationErrorsFormatter.format(r));Object.assign(this,s.OptionsNormalizer.normalizeOptions(this))};l.validatorOptions={validationError:{target:!1}},o.__decorate([i.IsBoolean(),o.__metadata("design:type",Boolean)],l.prototype,"compact",void 0),o.__decorate([i.IsBoolean(),o.__metadata("design:type",Boolean)],l.prototype,"controlFlowFlattening",void 0),o.__decorate([i.IsNumber(),i.Min(0),i.Max(1),o.__metadata("design:type",Number)],l.prototype,"controlFlowFlatteningThreshold",void 0),o.__decorate([i.IsBoolean(),o.__metadata("design:type",Boolean)],l.prototype,"deadCodeInjection",void 0),o.__decorate([i.IsNumber(),o.__metadata("design:type",Number)],l.prototype,"deadCodeInjectionThreshold",void 0),o.__decorate([i.IsBoolean(),o.__metadata("design:type",Boolean)],l.prototype,"debugProtection",void 0),o.__decorate([i.IsBoolean(),o.__metadata("design:type",Boolean)],l.prototype,"debugProtectionInterval",void 0),o.__decorate([i.IsBoolean(),o.__metadata("design:type",Boolean)],l.prototype,"disableConsoleOutput",void 0),o.__decorate([i.IsArray(),i.ArrayUnique(),i.IsString({each:!0}),o.__metadata("design:type",Array)],l.prototype,"domainLock",void 0),o.__decorate([i.IsBoolean(),o.__metadata("design:type",Boolean)],l.prototype,"mangle",void 0),o.__decorate([i.IsArray(),i.ArrayUnique(),i.IsString({each:!0}),o.__metadata("design:type",Array)],l.prototype,"reservedNames",void 0),o.__decorate([i.IsBoolean(),o.__metadata("design:type",Boolean)],l.prototype,"rotateStringArray",void 0),o.__decorate([i.IsNumber(),o.__metadata("design:type",Number)],l.prototype,"seed",void 0),o.__decorate([i.IsBoolean(),o.__metadata("design:type",Boolean)],l.prototype,"selfDefending",void 0),o.__decorate([i.IsBoolean(),o.__metadata("design:type",Boolean)],l.prototype,"sourceMap",void 0),o.__decorate([i.IsString(),i.ValidateIf(function(e){return Boolean(e.sourceMapBaseUrl)}),i.IsUrl({require_protocol:!0,require_valid_protocol:!0}),o.__metadata("design:type",String)],l.prototype,"sourceMapBaseUrl",void 0),o.__decorate([i.IsString(),o.__metadata("design:type",String)],l.prototype,"sourceMapFileName",void 0),o.__decorate([i.IsIn(["inline","separate"]),o.__metadata("design:type",String)],l.prototype,"sourceMapMode",void 0),o.__decorate([i.IsBoolean(),o.__metadata("design:type",Boolean)],l.prototype,"stringArray",void 0),o.__decorate([i.IsIn([!0,!1,"base64","rc4"]),o.__metadata("design:type",Object)],l.prototype,"stringArrayEncoding",void 0),o.__decorate([i.IsNumber(),i.Min(0),i.Max(1),o.__metadata("design:type",Number)],l.prototype,"stringArrayThreshold",void 0),o.__decorate([i.IsBoolean(),o.__metadata("design:type",Boolean)],l.prototype,"unicodeEscapeSequence",void 0),l=f=o.__decorate([a.injectable(),o.__metadata("design:paramtypes",[Object])],l),t.Options=l;var f},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var o=function(){function e(e,t){for(var r=0;rr)return"break";var a=e[o];s.traverse(a,{enter:function(r){if(l.Node.isCallExpressionNode(r))return a.parentNode!==f.NodeUtils.getBlockScopesOfNode(r)[0]?s.VisitorOption.Skip:void t.analyzeCallExpressionNode(n,e,r)}})}(a))break}return n}},{key:"analyzeCallExpressionNode",value:function(e,t,r){var n=this;p.calleeDataExtractorsList.forEach(function(o){var a=n.calleeDataExtractorFactory(o).extract(t,r.callee);a&&e.push(Object.assign({},a,{stackTrace:n.analyzeRecursive(a.callee.body)}))})}}],[{key:"getLimitIndex",value:function(e){var t=e-1,r=p.limitThresholdActivationLength-1,n=t;return t>r&&(n=Math.round(r+t*p.limitThreshold))>t&&(n=t),n}}]),e}();d.calleeDataExtractorsList=[u.CalleeDataExtractor.FunctionDeclarationCalleeDataExtractor,u.CalleeDataExtractor.FunctionExpressionCalleeDataExtractor,u.CalleeDataExtractor.ObjectExpressionCalleeDataExtractor],d.limitThresholdActivationLength=25,d.limitThreshold=.002,d=p=a.__decorate([i.injectable(),a.__param(0,i.inject(c.ServiceIdentifiers.Factory__ICalleeDataExtractor)),a.__metadata("design:paramtypes",[Function])],d),t.StackTraceAnalyzer=d;var p},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var i=function(){function e(e,t){for(var r=0;r=0?t:null}},{key:"getLength",value:function(){return this.storageLength}},{key:"getStorage",value:function(){return this.storage}},{key:"getStorageId",value:function(){return this.storageId}},{key:"initialize",value:function(){this.storage=[],this.storageId=u.RandomGeneratorUtils.getRandomString(6)}},{key:"mergeWith",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.storage=[].concat(n(this.storage),n(e.getStorage())),t&&(this.storageId=e.getStorageId())}},{key:"set",value:function(e,t){e===this.storageLength?this.storage.push(t):this.storage.splice(e,0,t),this.storageLength++}}]),e}();i.__decorate([s.initializable(),i.__metadata("design:type",Array)],l.prototype,"storage",void 0),i.__decorate([s.initializable(),i.__metadata("design:type",String)],l.prototype,"storageId",void 0),l=i.__decorate([c.injectable()],l),t.ArrayStorage=l},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var i=r(36),c=function(e){function t(){n(this,t);var e=o(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return e.initialize(),e}return a(t,e),t}(i.MapStorage);t.ControlFlowStorage=c},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var i=function(){function e(e,t){for(var r=0;r> (-2 * bc & 6)) : 0\n ) {\n buffer = chars.indexOf(buffer);\n }\n return output;\n });\n })();\n "}Object.defineProperty(t,"__esModule",{value:!0}),t.AtobTemplate=n},function(e,t,r){"use strict";function n(){return"\n var rc4 = function (str, key) {\n var s = [], j = 0, x, res = '', newStr = '';\n \n str = atob(str);\n \n for (var k = 0, length = str.length; k < length; k++) {\n newStr += '%' + ('00' + str.charCodeAt(k).toString(16)).slice(-2);\n }\n \n str = decodeURIComponent(newStr);\n \t \n\t for (var i = 0; i < 256; i++) {\n s[i] = i;\n }\n \n for (i = 0; i < 256; i++) {\n j = (j + s[i] + key.charCodeAt(i % key.length)) % 256;\n x = s[i];\n s[i] = s[j];\n s[j] = x;\n }\n \n i = 0;\n j = 0;\n \n for (var y = 0; y < str.length; y++) {\n i = (i + 1) % 256;\n j = (j + s[i]) % 256;\n x = s[i];\n s[i] = s[j];\n s[j] = x;\n res += String.fromCharCode(str.charCodeAt(y) ^ s[(s[i] + s[j]) % 256]);\n }\n \n return res;\n }\n "}Object.defineProperty(t,"__esModule",{value:!0}),t.Rc4Template=n},function(e,t,r){"use strict";function n(){return"\n var {singleNodeCallControllerFunctionName} = (function(){\n var firstCall = true;\n \n return function (context, fn){\t\n var rfn = firstCall ? function(){\n if(fn){\n var res = fn.apply(context, arguments);\n fn = null;\n return res;\n }\n } : function(){}\n \n firstCall = false;\n \n return rfn;\n }\n })();\n "}Object.defineProperty(t,"__esModule",{value:!0}),t.SingleNodeCallControllerTemplate=n},function(e,t,r){"use strict";function n(){return"\n var {consoleLogDisableFunctionName} = {singleNodeCallControllerFunctionName}(this, function () {\n var getGlobal = Function('return (function() ' + '{}.constructor(\"return this\")( )' + ');');\n \n var func = function () {};\n var that = getGlobal();\n \n if (!that.console) {\n that.console = (function (func){ \n var c = {}; \n \n c.log = func;\n c.warn = func; \n c.debug = func;\n c.info = func;\n c.error = func;\n c.exception = func;\n c.trace = func;\n \n return c; \n })(func);\n } else {\n that.console.log = func;\n that.console.warn = func; \n that.console.debug = func;\n that.console.info = func;\n that.console.error = func;\n that.console.exception = func;\n that.console.trace = func;\n }\n });\n \n {consoleLogDisableFunctionName}();\n "}Object.defineProperty(t,"__esModule",{value:!0}),t.ConsoleOutputDisableExpressionTemplate=n},function(e,t,r){"use strict";function n(){return"{debugProtectionFunctionName}();"}Object.defineProperty(t,"__esModule",{value:!0}),t.DebugProtectionFunctionCallTemplate=n},function(e,t,r){"use strict";function n(){return"\n setInterval(function () {\n {debugProtectionFunctionName}();\n }, 4000);\n "}Object.defineProperty(t,"__esModule",{value:!0}),t.DebugProtectionFunctionIntervalTemplate=n},function(e,t,r){"use strict";function n(){return"\n var {debugProtectionFunctionName} = function () {\n function debuggerProtection (counter) {\n if (('' + counter / counter)['length'] !== 1 || counter % 20 === 0) {\n (function () {}.constructor('debugger')());\n } else {\n (function () {}.constructor('debugger')());\n }\n \n debuggerProtection(++counter);\n }\n \n try {\n debuggerProtection(0);\n } catch (y) {}\n };\n "}Object.defineProperty(t,"__esModule",{value:!0}),t.DebugProtectionFunctionTemplate=n},function(e,t,r){"use strict";function n(){return'\n var {domainLockFunctionName} = {singleNodeCallControllerFunctionName}(this, function () {\n var getGlobal = Function(\'return (function () \' + \'{}.constructor("return this")()\' + \');\');\n\n var func = function () { \n return {\n key: \'item\',\n value: \'attribute\',\n getAttribute: function () {\n getGlobal()[\'eval\'](\'while(true){}\')();\n }()\n };\n };\n \n var regExp = new RegExp("[{diff}]", "g");\n var domains = "{domains}".replace(regExp, "").split(";");\n var eval = []["forEach"]["constructor"];\n var windowObject = eval("return this")();\n var document;\n var domain;\n \n for (var d in windowObject) {\n if (d.length == 8 && d.charCodeAt(7) == 116 && d.charCodeAt(5) == 101 && d.charCodeAt(3) == 117 && d.charCodeAt(0) == 100) {\n document = d;\n \n break;\n }\n }\n\n for (var d1 in windowObject[document]) {\n if (d1.length == 6 && d1.charCodeAt(5) == 110 && d1.charCodeAt(0) == 100) {\n domain = d1;\n \n break;\n }\n }\n \n if ((!document && !domain) || (!windowObject[document] && !windowObject[document][domain])) {\n return;\n }\n \n var currentDomain = windowObject[document][domain];\n\n var ok = false;\n \n for (var i = 0; i < domains.length; i++) {\n var domain = domains[i];\n var position = currentDomain.length - domain.length;\n var lastIndex = currentDomain.indexOf(domain, position);\n var endsWith = lastIndex !== -1 && lastIndex === position;\n \n if (endsWith) {\n if (currentDomain.length == domain.length || domain.indexOf(".") === 0) {\n ok = true;\n }\n \n break;\n }\n }\n \n if (!ok) {\n data;\n } else {\n return;\n }\n \n func();\n });\n\n {domainLockFunctionName}();\n '}Object.defineProperty(t,"__esModule",{value:!0}),t.DomainLockNodeTemplate=n},function(e,t,r){"use strict";function n(){return"\n var {selfDefendingFunctionName} = {singleNodeCallControllerFunctionName}(this, function () {\n var func1 = function(){return 'dev';},\n func2 = function () {\n return 'window';\n };\n \n var test1 = function () {\n var regExp = new RegExp('"+o.Utils.stringToUnicodeEscapeSequence("\\w+ *\\(\\) *{\\w+ *['|\"].+['|\"];? *}")+"');\n \n return !regExp.test(func1.toString());\n };\n \n var test2 = function () {\n var regExp = new RegExp('"+o.Utils.stringToUnicodeEscapeSequence("(\\\\[x|u](\\w){2,4})+")+"');\n \n return regExp.test(func2.toString());\n };\n \n var recursiveFunc1 = function (string) {\n var i = ~-1 >> 1 + 255 % 0;\n \n if (string.indexOf('i' === i)) {\n recursiveFunc2(string)\n }\n };\n \n var recursiveFunc2 = function (string) {\n var i = ~-4 >> 1 + 255 % 0;\n \n if (string.indexOf((true+\"\")[3]) !== i) {\n recursiveFunc1(string)\n }\n };\n \n if (!test1()) {\n if (!test2()) {\n recursiveFunc1('indеxOf');\n } else {\n recursiveFunc1('indexOf');\n }\n } else {\n recursiveFunc1('indеxOf');\n }\n })\n \n {selfDefendingFunctionName}();\n "}Object.defineProperty(t,"__esModule",{value:!0});var o=r(9);t.SelfDefendingTemplate=n},function(e,t,r){"use strict";function n(){return"\n var StatesClass = function (rc4Bytes) {\n this.rc4Bytes = rc4Bytes;\n this.states = [1, 0, 0];\n this.newState = function(){return 'newState';};\n this.firstState = '"+o.Utils.stringToUnicodeEscapeSequence("\\w+ *\\(\\) *{\\w+ *")+"';\n this.secondState = '"+o.Utils.stringToUnicodeEscapeSequence("['|\"].+['|\"];? *}")+"';\n };\n \n StatesClass.prototype.checkState = function () {\n var regExp = new RegExp(this.firstState + this.secondState);\n\n return this.runState(regExp.test(this.newState.toString()) ? --this.states[1] : --this.states[0]);\n };\n \n StatesClass.prototype.runState = function (stateResult) {\n if (!Boolean(~stateResult)) {\n return stateResult;\n }\n \n return this.getState(this.rc4Bytes);\n };\n\n StatesClass.prototype.getState = function (rc4Bytes) {\n for (var i = 0, len = this.states.length; i < len; i++) {\n this.states.push(Math.round(Math.random()));\n len = this.states.length;\n }\n \n return rc4Bytes(this.states[0]);\n };\n\n new StatesClass({stringArrayCallsWrapperName}).checkState();\n "}Object.defineProperty(t,"__esModule",{value:!0});var o=r(9);t.SelfDefendingTemplate=n},function(e,t,r){"use strict";function n(){return" \n if ({stringArrayCallsWrapperName}.initialized === undefined) {\n {atobPolyfill}\n \n {stringArrayCallsWrapperName}.base64DecodeUnicode = function (str) {\n var string = atob(str);\n var newStringChars = [];\n \n for (var i = 0, length = string.length; i < length; i++) {\n newStringChars += '%' + ('00' + string.charCodeAt(i).toString(16)).slice(-2);\n }\n \n return decodeURIComponent(newStringChars);\n };\n \n {stringArrayCallsWrapperName}.data = {};\n \n {stringArrayCallsWrapperName}.initialized = true;\n }\n \n var cachedValue = {stringArrayCallsWrapperName}.data[index];\n \n if (cachedValue === undefined) {\n {selfDefendingCode}\n \n value = {stringArrayCallsWrapperName}.base64DecodeUnicode(value);\n {stringArrayCallsWrapperName}.data[index] = value;\n } else {\n value = cachedValue;\n } \n "}Object.defineProperty(t,"__esModule",{value:!0}),t.StringArrayBase64DecodeNodeTemplate=n},function(e,t,r){"use strict";function n(){return"\n var {stringArrayCallsWrapperName} = function (index, key) {\n index = index - 0;\n \n var value = {stringArrayName}[index];\n \n {decodeNodeTemplate}\n \n return value;\n };\n "}Object.defineProperty(t,"__esModule",{value:!0}),t.StringArrayCallsWrapperTemplate=n},function(e,t,r){"use strict";function n(){return"\n if ({stringArrayCallsWrapperName}.initialized === undefined) {\n {atobPolyfill}\n \n {rc4Polyfill}\n {stringArrayCallsWrapperName}.rc4 = rc4;\n \n {stringArrayCallsWrapperName}.data = {};\n \n {stringArrayCallsWrapperName}.initialized = true;\n }\n \n var cachedValue = {stringArrayCallsWrapperName}.data[index];\n\n if (cachedValue === undefined) {\n if ({stringArrayCallsWrapperName}.once === undefined) {\n {selfDefendingCode}\n \n {stringArrayCallsWrapperName}.once = true;\n }\n \n value = {stringArrayCallsWrapperName}.rc4(value, key);\n {stringArrayCallsWrapperName}.data[index] = value;\n } else {\n value = cachedValue;\n }\n "}Object.defineProperty(t,"__esModule",{value:!0}),t.StringArrayRc4DecodeNodeTemplate=n},function(e,t,r){"use strict";function n(){return"\n var {stringArrayName} = [{stringArray}];\n "}Object.defineProperty(t,"__esModule",{value:!0}),t.StringArrayTemplate=n},function(e,t,r){"use strict";function n(){return"\n var selfDefendingFunc = function () { \n var object = {\n data: {\n key: 'cookie',\n value: 'timeout'\n },\n setCookie: function (options, name, value, document) {\n document = document || {};\n \n var updatedCookie = name + \"=\" + value;\n\n var i = 0;\n \n for (var i = 0, len = options.length; i < len; i++) { \n var propName = options[i];\n \n updatedCookie += \"; \" + propName;\n \n var propValue = options[propName];\n \n options.push(propValue);\n len = options.length;\n \n if (propValue !== true) {\n updatedCookie += \"=\" + propValue;\n }\n }\n\n document['cookie'] = updatedCookie;\n },\n removeCookie: function(){return 'dev';},\n getCookie: function (document, name) { \n document = document || function (value) { return value };\n var matches = document(new RegExp(\n \"(?:^|; )\" + name.replace(/([.$?*|{}()[]\\/+^])/g, '\\$1') + \"=([^;]*)\"\n ));\n \n var func = function (param1, param2) {\n param1(++param2);\n };\n \n func({whileFunctionName}, {timesName});\n \n return matches ? decodeURIComponent(matches[1]) : undefined;\n }\n };\n \n var test1 = function () {\n var regExp = new RegExp('"+o.Utils.stringToUnicodeEscapeSequence("\\w+ *\\(\\) *{\\w+ *['|\"].+['|\"];? *}")+"');\n \n return regExp.test(object.removeCookie.toString());\n };\n \n object['updateCookie'] = test1;\n \n var cookie = '';\n var result = object['updateCookie']();\n \n if (!result) {\n object['setCookie'](['*'], 'counter', 1);\n } else if (result) {\n cookie = object['getCookie'](null, 'counter'); \n } else {\n object['removeCookie']();\n }\n };\n \n selfDefendingFunc();\n "}Object.defineProperty(t,"__esModule",{value:!0});var o=r(9);t.SelfDefendingTemplate=n},function(e,t,r){"use strict";function n(){return"\n (function (array, {timesName}) {\n var {whileFunctionName} = function (times) {\n while (--times) {\n array['push'](array['shift']());\n }\n };\n \n {code}\n })({stringArrayName}, 0x{stringArrayRotateValue});\n "}Object.defineProperty(t,"__esModule",{value:!0}),t.StringArrayRotateFunctionTemplate=n},function(e,t){e.exports=require("chance")},function(e,t){e.exports=require("class-validator")},function(e,t){e.exports=require("commander")},function(e,t){e.exports=require("esmangle")},function(e,t){e.exports=require("events")},function(e,t){e.exports=require("fs")},function(e,t){e.exports=require("mkdirp")},function(e,t){e.exports=require("reflect-metadata")}]); +require("source-map-support").install(),module.exports=function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var n={};return t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=39)}([function(e,t){e.exports=require("inversify")},function(e,t){e.exports=require("tslib")},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ServiceIdentifiers={Factory__ICalleeDataExtractor:Symbol("Factory"),Factory__IControlFlowReplacer:Symbol("Factory"),Factory__ICustomNode:Symbol("Factory"),Factory__ICustomNodeGroup:Symbol("Factory"),Factory__IIdentifierObfuscatingReplacer:Symbol("Factory"),Factory__INodeTransformer:Symbol("Factory"),Factory__IObfuscationResult:Symbol("Factory"),Factory__IObfuscatingReplacer:Symbol("Factory"),Factory__TControlFlowStorage:Symbol("Factory"),ICalleeDataExtractor:Symbol("ICalleeDataExtractor"),ICustomNodeGroup:Symbol("ICustomNodeGroup"),IControlFlowReplacer:Symbol("IControlFlowReplacer"),IDeadCodeInjectionReplacer:Symbol("IDeadCodeInjectionReplacer"),IIdentifierObfuscatingReplacer:Symbol("IIdentifierObfuscatingReplacer"),IJavaScriptObfuscator:Symbol("IJavaScriptObfuscator"),INodeTransformer:Symbol("INodeTransformer"),IObfuscationEventEmitter:Symbol("IObfuscationEventEmitter"),IObfuscationResult:Symbol("IObfuscationResult"),IObfuscator:Symbol("IObfuscator"),IOptions:Symbol("IOptions"),IObfuscatingReplacer:Symbol("IObfuscatingReplacer"),ISourceMapCorrector:Symbol("ISourceMapCorrector"),IStackTraceAnalyzer:Symbol("IStackTraceAnalyzer"),Newable__ICustomNode:Symbol("Newable"),Newable__TControlFlowStorage:Symbol("Newable"),TCustomNodeGroupStorage:Symbol("TCustomNodeGroupStorage"),TStringArrayStorage:Symbol("TStringArrayStorage")}},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},a=function(){function e(e,t){for(var n=0;n1&&void 0!==arguments[1]?arguments[1]:0;if(l.Node.isNodeHasBlockStatement(e)){if(void 0===e.body[t])throw new ReferenceError("Wrong index `"+t+"`. Block-statement body length is `"+e.body.length+"`");return e.body[t]}throw new TypeError("The specified node have no a block-statement")}},{key:"getBlockScopesOfNode",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],r=t.parentNode;if(!r)throw new ReferenceError("`parentNode` property of given node is `undefined`");if(l.Node.isBlockStatementNode(r)){if(!r.parentNode)throw new ReferenceError("`parentNode` property of `parentNode` of given node is `undefined`");-1!==e.nodesWithBlockScope.indexOf(r.parentNode.type)&&n.push(r)}return l.Node.isProgramNode(r)?(n.push(r),n):e.getBlockScopesOfNode(r,n)}},{key:"getNodeBlockScopeDepth",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=t.parentNode;if(!r)throw new ReferenceError("`parentNode` property of given node is `undefined`");return l.Node.isProgramNode(r)?n:l.Node.isBlockStatementNode(t)&&-1!==e.nodesWithBlockScope.indexOf(r.type)?e.getNodeBlockScopeDepth(r,++n):e.getNodeBlockScopeDepth(r,n)}},{key:"getUnaryExpressionArgumentNode",value:function(t){return l.Node.isUnaryExpressionNode(t.argument)?e.getUnaryExpressionArgumentNode(t.argument):t.argument}},{key:"parentize",value:function(e){var t=!0;return s.traverse(e,{enter:function(e,n){var r=void 0;t?(e.type===u.NodeType.Program?r=e:(r=f.Nodes.getProgramNode([e]),r.parentNode=r),t=!1):r=n||e,e.parentNode=r,e.obfuscatedNode=!1}}),e}},{key:"typedReplace",value:function(t,n,r){e.typedTraverse(t,n,r,"replace")}},{key:"typedTraverse",value:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"traverse";s[r](e,{enter:function(e,r){if(e.type===t&&n.enter)return n.enter(e,r)},leave:function(e,r){if(e.type===t&&n.leave)return n.leave(e,r)}})}}]),e}();d.nodesWithBlockScope=[u.NodeType.ArrowFunctionExpression,u.NodeType.FunctionDeclaration,u.NodeType.FunctionExpression,u.NodeType.MethodDefinition,u.NodeType.Program],t.NodeUtils=d},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var o=function(){function e(e,t){for(var n=0;n1&&void 0!==arguments[1]?arguments[1]:e.randomGeneratorPool;return e.getRandomGenerator().string({length:t,pool:n})}},{key:"getRandomVariableName",value:function(t){var n="_"+i.Utils.hexadecimalPrefix,r=""+n+i.Utils.decToHex(e.getRandomInteger(1e4,99999999)).substr(0,t);return e.randomVariableNameSet.has(r)?e.getRandomVariableName(t):(e.randomVariableNameSet.add(r),r)}}]),e}();c.randomGeneratorPool="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",c.randomGeneratorPoolNumbers="0123456789",c.randomGeneratorPoolHexadecimal="abcdef"+c.randomGeneratorPoolNumbers,c.randomGeneratorPoolWithNumbers=""+c.randomGeneratorPool+c.randomGeneratorPoolNumbers,c.randomVariableNameSet=new Set,t.RandomGeneratorUtils=c},function(e,t,n){"use strict";function r(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"initialize",t=Object.keys(this)[0];return function(n,r){var o={configurable:!0,enumerable:!0},a=n[e];if(!a||"function"!=typeof a)throw new Error("`"+e+"` method with initialization logic not found. `@"+t+"` decorator requires `"+e+"` method");var i="_"+r,c=Object.getOwnPropertyDescriptor(n,i)||o,s=Object.getOwnPropertyDescriptor(n,e)||o,u=s.value;return Object.defineProperty(n,r,Object.assign({},c,{get:function(){if(void 0===this[i])throw new Error("Property `"+r+"` is not initialized! Initialize it first!");return this[i]},set:function(e){this[i]=e}})),Object.defineProperty(n,e,Object.assign({},s,{value:function(){u.apply(this,arguments),this[r]}})),c}}Object.defineProperty(t,"__esModule",{value:!0}),t.initializable=r},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var o=function(){function e(e,t){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:[];return{type:i.NodeType.Program,body:e,sourceType:"script",obfuscatedNode:!1}}},{key:"getArrayExpressionNode",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return{type:i.NodeType.ArrayExpression,elements:e}}},{key:"getAssignmentExpressionNode",value:function(e,t,n){return{type:i.NodeType.AssignmentExpression,operator:e,left:t,right:n,obfuscatedNode:!1}}},{key:"getBinaryExpressionNode",value:function(e,t,n){return{type:i.NodeType.BinaryExpression,operator:e,left:t,right:n,obfuscatedNode:!1}}},{key:"getBlockStatementNode",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return{type:i.NodeType.BlockStatement,body:e,obfuscatedNode:!1}}},{key:"getBreakStatement",value:function(e){var t={type:i.NodeType.BreakStatement,obfuscatedNode:!1};return e&&(t.label=e),t}},{key:"getCatchClauseNode",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return{type:i.NodeType.CatchClause,param:e.getIdentifierNode("err"),body:e.getBlockStatementNode(t),obfuscatedNode:!1}}},{key:"getCallExpressionNode",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return{type:i.NodeType.CallExpression,callee:e,arguments:t,obfuscatedNode:!1}}},{key:"getContinueStatement",value:function(e){var t={type:i.NodeType.ContinueStatement,obfuscatedNode:!1};return e&&(t.label=e),t}},{key:"getExpressionStatementNode",value:function(e){return{type:i.NodeType.ExpressionStatement,expression:e,obfuscatedNode:!1}}},{key:"getFunctionDeclarationNode",value:function(t,n,r){return{type:i.NodeType.FunctionDeclaration,id:e.getIdentifierNode(t),params:n,body:r,generator:!1,obfuscatedNode:!1}}},{key:"getFunctionExpressionNode",value:function(e,t){return{type:i.NodeType.FunctionExpression,params:e,body:t,generator:!1,obfuscatedNode:!1}}},{key:"getIfStatementNode",value:function(e,t,n){return Object.assign({type:i.NodeType.IfStatement,test:e,consequent:t},n&&{alternate:n},{obfuscatedNode:!1})}},{key:"getIdentifierNode",value:function(e){return{type:i.NodeType.Identifier,name:e,obfuscatedNode:!1}}},{key:"getLabeledStatement",value:function(e,t){return{type:i.NodeType.LabeledStatement,label:e,body:t,obfuscatedNode:!1}}},{key:"getLiteralNode",value:function(e,t){return t=void 0!==t?t:"'"+e+"'",{type:i.NodeType.Literal,value:e,raw:t,"x-verbatim-property":{content:t,precedence:a.Precedence.Primary},obfuscatedNode:!1}}},{key:"getLogicalExpressionNode",value:function(e,t,n){return{type:i.NodeType.LogicalExpression,operator:e,left:t,right:n,obfuscatedNode:!1}}},{key:"getMemberExpressionNode",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return{type:i.NodeType.MemberExpression,computed:n,object:e,property:t,obfuscatedNode:!1}}},{key:"getObjectExpressionNode",value:function(e){return{type:i.NodeType.ObjectExpression,properties:e,obfuscatedNode:!1}}},{key:"getPropertyNode",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return{type:i.NodeType.Property,key:e,value:t,kind:"init",method:!1,shorthand:!1,computed:n,obfuscatedNode:!1}}},{key:"getUnaryExpressionNode",value:function(e,t){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];return{type:i.NodeType.UnaryExpression,operator:e,argument:t,prefix:n,obfuscatedNode:!1}}},{key:"getReturnStatementNode",value:function(e){return{type:i.NodeType.ReturnStatement,argument:e,obfuscatedNode:!1}}},{key:"getSwitchStatementNode",value:function(e,t){return{type:i.NodeType.SwitchStatement,discriminant:e,cases:t,obfuscatedNode:!1}}},{key:"getSwitchCaseNode",value:function(e,t){return{type:i.NodeType.SwitchCase,test:e,consequent:t,obfuscatedNode:!1}}},{key:"getUpdateExpressionNode",value:function(e,t){return{type:i.NodeType.UpdateExpression,operator:e,argument:t,prefix:!1,obfuscatedNode:!1}}},{key:"getVariableDeclarationNode",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"var";return{type:i.NodeType.VariableDeclaration,declarations:e,kind:t,obfuscatedNode:!1}}},{key:"getVariableDeclaratorNode",value:function(e,t){return{type:i.NodeType.VariableDeclarator,id:e,init:t,obfuscatedNode:!1}}},{key:"getWhileStatementNode",value:function(e,t){return{type:i.NodeType.WhileStatement,test:e,body:t,obfuscatedNode:!1}}}]),e}();t.Nodes=c},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});!function(e){e[e.BinaryExpressionFunctionNode=0]="BinaryExpressionFunctionNode",e[e.BlockStatementControlFlowFlatteningNode=1]="BlockStatementControlFlowFlatteningNode",e[e.CallExpressionControlFlowStorageCallNode=2]="CallExpressionControlFlowStorageCallNode",e[e.CallExpressionFunctionNode=3]="CallExpressionFunctionNode",e[e.ControlFlowStorageNode=4]="ControlFlowStorageNode",e[e.ConsoleOutputDisableExpressionNode=5]="ConsoleOutputDisableExpressionNode",e[e.DebugProtectionFunctionCallNode=6]="DebugProtectionFunctionCallNode",e[e.DebugProtectionFunctionIntervalNode=7]="DebugProtectionFunctionIntervalNode",e[e.DebugProtectionFunctionNode=8]="DebugProtectionFunctionNode",e[e.DomainLockNode=9]="DomainLockNode",e[e.ExpressionWithOperatorControlFlowStorageCallNode=10]="ExpressionWithOperatorControlFlowStorageCallNode",e[e.LogicalExpressionFunctionNode=11]="LogicalExpressionFunctionNode",e[e.NodeCallsControllerFunctionNode=12]="NodeCallsControllerFunctionNode",e[e.SelfDefendingUnicodeNode=13]="SelfDefendingUnicodeNode",e[e.StringArrayCallsWrapper=14]="StringArrayCallsWrapper",e[e.StringArrayNode=15]="StringArrayNode",e[e.StringArrayRotateFunctionNode=16]="StringArrayRotateFunctionNode",e[e.StringLiteralControlFlowStorageCallNode=17]="StringLiteralControlFlowStorageCallNode",e[e.StringLiteralNode=18]="StringLiteralNode"}(t.CustomNode||(t.CustomNode={}))},function(e,t){e.exports=require("estraverse")},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var o=n(1),a=n(0),i=n(2),c=n(4),s=function e(t){r(this,e),this.nodeIdentifier=c.RandomGeneratorUtils.getRandomInteger(0,1e4),this.options=t};s=o.__decorate([a.injectable(),o.__param(0,a.inject(i.ServiceIdentifiers.IOptions)),o.__metadata("design:paramtypes",[Object])],s),t.AbstractNodeTransformer=s},function(e,t,n){"use strict";function r(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t-1||0===e.indexOf("//")?e.split("/")[2]:e.split("/")[0],t=t.split(":")[0]}},{key:"isCeilNumber",value:function(e){return e%1==0}},{key:"strEnumify",value:function(e){return e}},{key:"stringRotate",value:function(e,t){if(!e)throw new ReferenceError("Cannot rotate empty string.");for(var n=0;n1&&void 0!==arguments[1]?arguments[1]:{},n=new i.InversifyContainerFacade(t),r=n.get(a.ServiceIdentifiers.IOptions);s.RandomGeneratorUtils.initializeRandomGenerator(r.seed);var o=n.get(a.ServiceIdentifiers.IJavaScriptObfuscator),c=o.obfuscate(e);return s.RandomGeneratorUtils.clearRandomGenerator(),c}},{key:"runCLI",value:function(e){new c.JavaScriptObfuscatorCLI(e).run()}}]),e}();t.JavaScriptObfuscator=u},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var o=function(){function e(e,t){for(var n=0;n3&&void 0!==arguments[3]?arguments[3]:0,a=void 0;a=t.length?e.getOptimalBlockScope(t,o):n,e.prependNode(a,r)}},{key:"getOptimalBlockScope",value:function(t,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1/0,o=t[n];if(r<=0)throw new Error("Invalid `deep` argument value. Value should be bigger then 0.");return r>1&&o.stackTrace.length?e.getOptimalBlockScope(o.stackTrace,0,--r):o.callee}},{key:"getRandomStackTraceIndex",value:function(e){return i.RandomGeneratorUtils.getRandomInteger(0,Math.max(0,Math.round(e-1)))}},{key:"insertNodeAtIndex",value:function(t,n,o){e.validateBodyStatements(n)||(n=[]),n=e.parentizeBodyStatementsBeforeAppend(t,n),t.body=[].concat(r(t.body.slice(0,o)),r(n),r(t.body.slice(o)))}},{key:"prependNode",value:function(t,n){e.validateBodyStatements(n)||(n=[]),n=e.parentizeBodyStatementsBeforeAppend(t,n),t.body=[].concat(r(n),r(t.body))}},{key:"parentizeBodyStatementsBeforeAppend",value:function(e,t){return t.forEach(function(t){t.parentNode=e}),t}},{key:"validateBodyStatements",value:function(e){return e.every(function(e){return!!e&&e.hasOwnProperty("type")})}}]),e}();t.NodeAppender=c},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});!function(e){e[e.BaseIdentifierObfuscatingReplacer=0]="BaseIdentifierObfuscatingReplacer"}(t.IdentifierObfuscatingReplacer||(t.IdentifierObfuscatingReplacer={}))},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var o=function(){function e(e,t){for(var n=0;n>8-o%1*8)){if((r=e.charCodeAt(o+=.75))>255)throw new Error("'btoa' failed: The string to be encoded contains characters outside of the Latin1 range.");n=n<<8|r}return t}},{key:"hideString",value:function(e,t){var n=a.RandomGeneratorUtils.getRandomGenerator().string({length:t,pool:a.RandomGeneratorUtils.randomGeneratorPool}),r=n.replace(new RegExp("["+function(e){return e.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")}(e)+"]","g"),""),o=r.split("");return a.RandomGeneratorUtils.getRandomGenerator().shuffle(o),r=o.join(""),[function(e,t){for(var n=-1,r=-1,o="";n1&&void 0!==arguments[1]&&arguments[1];this.storage=new Map([].concat(r(this.storage),r(e.getStorage()))),t&&(this.storageId=e.getStorageId())}},{key:"set",value:function(e,t){this.storage.set(e,t)}}]),e}();c.__decorate([u.initializable(),c.__metadata("design:type",String)],f.prototype,"storageId",void 0),c.__decorate([u.initializable(),c.__metadata("design:type",Map)],f.prototype,"storage",void 0),f=c.__decorate([s.injectable()],f),t.MapStorage=f},function(e,t){e.exports=require("path")},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(16);e.exports=r.JavaScriptObfuscator},function(e,t){e.exports=require("reflect-metadata")},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(17),o=n(0),a=n(2),i=n(30),c=n(42),s=n(45),u=n(46),l=n(47);t.controlFlowTransformersModule=new o.ContainerModule(function(e){e(a.ServiceIdentifiers.IControlFlowReplacer).to(c.BinaryExpressionControlFlowReplacer).whenTargetNamed(i.ControlFlowReplacer.BinaryExpressionControlFlowReplacer),e(a.ServiceIdentifiers.IControlFlowReplacer).to(s.CallExpressionControlFlowReplacer).whenTargetNamed(i.ControlFlowReplacer.CallExpressionControlFlowReplacer),e(a.ServiceIdentifiers.IControlFlowReplacer).to(u.LogicalExpressionControlFlowReplacer).whenTargetNamed(i.ControlFlowReplacer.LogicalExpressionControlFlowReplacer),e(a.ServiceIdentifiers.IControlFlowReplacer).to(l.StringLiteralControlFlowReplacer).whenTargetNamed(i.ControlFlowReplacer.StringLiteralControlFlowReplacer),e(a.ServiceIdentifiers.Factory__IControlFlowReplacer).toFactory(r.InversifyContainerFacade.getCacheFactory(a.ServiceIdentifiers.IControlFlowReplacer))})},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var i=function(){function e(e,t){for(var n=0;n> 1 + 255 % 0;\n \n if (string.indexOf('i' === i)) {\n recursiveFunc2(string)\n }\n };\n \n var recursiveFunc2 = function (string) {\n var i = ~-4 >> 1 + 255 % 0;\n \n if (string.indexOf((true+\"\")[3]) !== i) {\n recursiveFunc1(string)\n }\n };\n \n if (!test1()) {\n if (!test2()) {\n recursiveFunc1('indеxOf');\n } else {\n recursiveFunc1('indexOf');\n }\n } else {\n recursiveFunc1('indеxOf');\n }\n })\n \n {selfDefendingFunctionName}();\n "}Object.defineProperty(t,"__esModule",{value:!0});var o=n(12);t.SelfDefendingTemplate=r},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var i=function(){function e(e,t){for(var n=0;n> (-2 * bc & 6)) : 0\n ) {\n buffer = chars.indexOf(buffer);\n }\n return output;\n });\n })();\n "}Object.defineProperty(t,"__esModule",{value:!0}),t.AtobTemplate=r},function(e,t,n){"use strict";function r(){return"\n var rc4 = function (str, key) {\n var s = [], j = 0, x, res = '', newStr = '';\n \n str = atob(str);\n \n for (var k = 0, length = str.length; k < length; k++) {\n newStr += '%' + ('00' + str.charCodeAt(k).toString(16)).slice(-2);\n }\n \n str = decodeURIComponent(newStr);\n \t \n\t for (var i = 0; i < 256; i++) {\n s[i] = i;\n }\n \n for (i = 0; i < 256; i++) {\n j = (j + s[i] + key.charCodeAt(i % key.length)) % 256;\n x = s[i];\n s[i] = s[j];\n s[j] = x;\n }\n \n i = 0;\n j = 0;\n \n for (var y = 0; y < str.length; y++) {\n i = (i + 1) % 256;\n j = (j + s[i]) % 256;\n x = s[i];\n s[i] = s[j];\n s[j] = x;\n res += String.fromCharCode(str.charCodeAt(y) ^ s[(s[i] + s[j]) % 256]);\n }\n \n return res;\n }\n "}Object.defineProperty(t,"__esModule",{value:!0}),t.Rc4Template=r},function(e,t,n){"use strict";function r(){return"\n var StatesClass = function (rc4Bytes) {\n this.rc4Bytes = rc4Bytes;\n this.states = [1, 0, 0];\n this.newState = function(){return 'newState';};\n this.firstState = '"+o.Utils.stringToUnicodeEscapeSequence("\\w+ *\\(\\) *{\\w+ *",!0)+"';\n this.secondState = '"+o.Utils.stringToUnicodeEscapeSequence("['|\"].+['|\"];? *}",!0)+"';\n };\n \n StatesClass.prototype.checkState = function () {\n var regExp = new RegExp(this.firstState + this.secondState);\n\n return this.runState(regExp.test(this.newState.toString()) ? --this.states[1] : --this.states[0]);\n };\n \n StatesClass.prototype.runState = function (stateResult) {\n if (!Boolean(~stateResult)) {\n return stateResult;\n }\n \n return this.getState(this.rc4Bytes);\n };\n\n StatesClass.prototype.getState = function (rc4Bytes) {\n for (var i = 0, len = this.states.length; i < len; i++) {\n this.states.push(Math.round(Math.random()));\n len = this.states.length;\n }\n \n return rc4Bytes(this.states[0]);\n };\n\n new StatesClass({stringArrayCallsWrapperName}).checkState();\n "}Object.defineProperty(t,"__esModule",{value:!0});var o=n(12);t.SelfDefendingTemplate=r},function(e,t,n){"use strict";function r(){return" \n if ({stringArrayCallsWrapperName}.initialized === undefined) {\n {atobPolyfill}\n \n {stringArrayCallsWrapperName}.base64DecodeUnicode = function (str) {\n var string = atob(str);\n var newStringChars = [];\n \n for (var i = 0, length = string.length; i < length; i++) {\n newStringChars += '%' + ('00' + string.charCodeAt(i).toString(16)).slice(-2);\n }\n \n return decodeURIComponent(newStringChars);\n };\n \n {stringArrayCallsWrapperName}.data = {};\n \n {stringArrayCallsWrapperName}.initialized = true;\n }\n \n var cachedValue = {stringArrayCallsWrapperName}.data[index];\n \n if (cachedValue === undefined) {\n {selfDefendingCode}\n \n value = {stringArrayCallsWrapperName}.base64DecodeUnicode(value);\n {stringArrayCallsWrapperName}.data[index] = value;\n } else {\n value = cachedValue;\n } \n "}Object.defineProperty(t,"__esModule",{value:!0}),t.StringArrayBase64DecodeNodeTemplate=r},function(e,t,n){"use strict";function r(){return"\n var {stringArrayCallsWrapperName} = function (index, key) {\n index = index - 0;\n \n var value = {stringArrayName}[index];\n \n {decodeNodeTemplate}\n \n return value;\n };\n "}Object.defineProperty(t,"__esModule",{value:!0}),t.StringArrayCallsWrapperTemplate=r},function(e,t,n){"use strict";function r(){return"\n if ({stringArrayCallsWrapperName}.initialized === undefined) {\n {atobPolyfill}\n \n {rc4Polyfill}\n {stringArrayCallsWrapperName}.rc4 = rc4;\n \n {stringArrayCallsWrapperName}.data = {};\n \n {stringArrayCallsWrapperName}.initialized = true;\n }\n \n var cachedValue = {stringArrayCallsWrapperName}.data[index];\n\n if (cachedValue === undefined) {\n if ({stringArrayCallsWrapperName}.once === undefined) {\n {selfDefendingCode}\n \n {stringArrayCallsWrapperName}.once = true;\n }\n \n value = {stringArrayCallsWrapperName}.rc4(value, key);\n {stringArrayCallsWrapperName}.data[index] = value;\n } else {\n value = cachedValue;\n }\n "}Object.defineProperty(t,"__esModule",{value:!0}),t.StringArrayRc4DecodeNodeTemplate=r},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var i=function(){function e(e,t){for(var n=0;n=g.minimumLengthForStringArray&&y.RandomGeneratorUtils.getMathRandom()<=this.options.stringArrayThreshold}},{key:"getStringArrayHexadecimalIndex",value:function(e,t){if(this.stringLiteralHexadecimalIndexCache.has(e))return{fromCache:!0,index:this.stringLiteralHexadecimalIndexCache.get(e)};var n=b.Utils.decToHex(t),r=""+b.Utils.hexadecimalPrefix+n;return this.stringLiteralHexadecimalIndexCache.set(e,r),{fromCache:!1,index:r}}},{key:"getEncodedValue",value:function(e){var t=void 0,n=null;switch(this.options.stringArrayEncoding){case l.StringArrayEncoding.Rc4:n=y.RandomGeneratorUtils.getRandomGenerator().pickone(this.rc4Keys),t=d.CryptUtils.btoa(d.CryptUtils.rc4(e,n));break;case l.StringArrayEncoding.Base64:t=d.CryptUtils.btoa(e);break;default:t=e}return{encodedValue:t,key:n}}},{key:"replaceWithLiteralNode",value:function(e){return p.Nodes.getLiteralNode(b.Utils.stringToUnicodeEscapeSequence(e,this.options.unicodeEscapeSequence))}},{key:"replaceWithStringArrayCallNode",value:function(e){var t=this.getEncodedValue(e),n=t.encodedValue,r=t.key,o=b.Utils.stringToUnicodeEscapeSequence(n,this.options.unicodeEscapeSequence),a=this.stringArrayStorage.getLength(),i=b.Utils.stringRotate(this.stringArrayStorage.getStorageId(),1),c="_"+b.Utils.hexadecimalPrefix+i,s=this.getStringArrayHexadecimalIndex(o,a),u=s.fromCache,l=s.index;u||this.stringArrayStorage.set(a,o);var f=[g.getHexadecimalLiteralNode(l)];return r&&f.push(g.getRc4KeyLiteralNode(b.Utils.stringToUnicodeEscapeSequence(r,this.options.unicodeEscapeSequence))),p.Nodes.getCallExpressionNode(p.Nodes.getIdentifierNode(c),f)}}],[{key:"getHexadecimalLiteralNode",value:function(e){var t=p.Nodes.getLiteralNode(e);return t.obfuscatedNode=!0,t}},{key:"getRc4KeyLiteralNode",value:function(e){var t=p.Nodes.getLiteralNode(e);return t.obfuscatedNode=!0,t}}]),t}(f.AbstractObfuscatingReplacer);m.minimumLengthForStringArray=3,m.rc4KeyLength=4,m.rc4KeysCount=50,m=g=c.__decorate([s.injectable(),c.__param(0,s.inject(u.ServiceIdentifiers.TCustomNodeGroupStorage)),c.__param(1,s.inject(u.ServiceIdentifiers.TStringArrayStorage)),c.__param(2,s.inject(u.ServiceIdentifiers.IOptions)),c.__metadata("design:paramtypes",[Object,Object,Object])],m),t.StringLiteralObfuscatingReplacer=m;var g},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(17),o=n(0),a=n(2),i=n(35),c=n(95),s=n(96),u=n(97),l=n(98),f=n(99),d=n(100),p=n(101),y=n(102),b=n(103),m=n(104),g=n(105),h=n(106),v=n(107);t.nodeTransformersModule=new o.ContainerModule(function(e){e(a.ServiceIdentifiers.INodeTransformer).to(s.BlockStatementControlFlowTransformer).whenTargetNamed(i.NodeTransformer.BlockStatementControlFlowTransformer),e(a.ServiceIdentifiers.INodeTransformer).to(u.DeadCodeInjectionTransformer).whenTargetNamed(i.NodeTransformer.DeadCodeInjectionTransformer),e(a.ServiceIdentifiers.INodeTransformer).to(c.FunctionControlFlowTransformer).whenTargetNamed(i.NodeTransformer.FunctionControlFlowTransformer),e(a.ServiceIdentifiers.INodeTransformer).to(b.MemberExpressionTransformer).whenTargetNamed(i.NodeTransformer.MemberExpressionTransformer),e(a.ServiceIdentifiers.INodeTransformer).to(m.MethodDefinitionTransformer).whenTargetNamed(i.NodeTransformer.MethodDefinitionTransformer),e(a.ServiceIdentifiers.INodeTransformer).to(h.TemplateLiteralTransformer).whenTargetNamed(i.NodeTransformer.TemplateLiteralTransformer),e(a.ServiceIdentifiers.INodeTransformer).to(l.CatchClauseTransformer).whenTargetNamed(i.NodeTransformer.CatchClauseTransformer),e(a.ServiceIdentifiers.INodeTransformer).to(f.FunctionDeclarationTransformer).whenTargetNamed(i.NodeTransformer.FunctionDeclarationTransformer),e(a.ServiceIdentifiers.INodeTransformer).to(d.FunctionTransformer).whenTargetNamed(i.NodeTransformer.FunctionTransformer),e(a.ServiceIdentifiers.INodeTransformer).to(p.LabeledStatementTransformer).whenTargetNamed(i.NodeTransformer.LabeledStatementTransformer),e(a.ServiceIdentifiers.INodeTransformer).to(y.LiteralTransformer).whenTargetNamed(i.NodeTransformer.LiteralTransformer),e(a.ServiceIdentifiers.INodeTransformer).to(g.ObjectExpressionTransformer).whenTargetNamed(i.NodeTransformer.ObjectExpressionTransformer),e(a.ServiceIdentifiers.INodeTransformer).to(v.VariableDeclarationTransformer).whenTargetNamed(i.NodeTransformer.VariableDeclarationTransformer),e(a.ServiceIdentifiers.Factory__INodeTransformer).toFactory(r.InversifyContainerFacade.getCacheFactory(a.ServiceIdentifiers.INodeTransformer))})},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var i=function(){function e(e,t){for(var n=0;nn.options.controlFlowFlatteningThreshold)return e;var o=_.controlFlowReplacersMap.get(e.type);return void 0===o?e:Object.assign({},n.controlFlowReplacerFactory(o).replace(e,r,t),{parentNode:r})}})}}],[{key:"getHostNode",value:function(e){var t=g.NodeUtils.getBlockScopesOfNode(e);return 1===t.length?e:(t.pop(),t.length>_.hostNodeSearchMinDepth&&t.splice(0,_.hostNodeSearchMinDepth),t.length>_.hostNodeSearchMaxDepth&&(t.length=_.hostNodeSearchMaxDepth),h.RandomGeneratorUtils.getRandomGenerator().pickone(t))}}]),t}(p.AbstractNodeTransformer);v.controlFlowReplacersMap=new Map([[d.NodeType.BinaryExpression,m.ControlFlowReplacer.BinaryExpressionControlFlowReplacer],[d.NodeType.CallExpression,m.ControlFlowReplacer.CallExpressionControlFlowReplacer],[d.NodeType.LogicalExpression,m.ControlFlowReplacer.LogicalExpressionControlFlowReplacer],[d.NodeType.Literal,m.ControlFlowReplacer.StringLiteralControlFlowReplacer]]),v.hostNodeSearchMinDepth=0,v.hostNodeSearchMaxDepth=2,v=_=c.__decorate([s.injectable(),c.__param(0,s.inject(u.ServiceIdentifiers.Factory__TControlFlowStorage)),c.__param(1,s.inject(u.ServiceIdentifiers.Factory__IControlFlowReplacer)),c.__param(2,s.inject(u.ServiceIdentifiers.Factory__ICustomNode)),c.__param(3,s.inject(u.ServiceIdentifiers.IOptions)),c.__metadata("design:paramtypes",[Function,Function,Function,Object])],v),t.FunctionControlFlowTransformer=v;var _},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var i=function(){function e(e,t){for(var n=0;nthis.options.controlFlowFlatteningThreshold||m.blockStatementHasProhibitedStatements(e))return e;var n=e.body;if(n.length<=4)return e;var r=y.Utils.arrayRange(n.length),o=y.Utils.arrayShuffle(r),a=r.map(function(e){return o.indexOf(e)}),i=this.customNodeFactory(l.CustomNode.BlockStatementControlFlowFlatteningNode);return i.initialize(n,o,a),i.getNode()[0]}}],[{key:"blockStatementHasProhibitedStatements",value:function(e){return e.body.some(function(e){var t=d.Node.isBreakStatementNode(e)||d.Node.isContinueStatementNode(e),n=d.Node.isVariableDeclarationNode(e)&&("const"===e.kind||"let"===e.kind);return d.Node.isFunctionDeclarationNode(e)||t||n})}}]),t}(f.AbstractNodeTransformer);b=m=c.__decorate([s.injectable(),c.__param(0,s.inject(u.ServiceIdentifiers.Factory__ICustomNode)),c.__param(1,s.inject(u.ServiceIdentifiers.IOptions)),c.__metadata("design:paramtypes",[Function,Object])],b),t.BlockStatementControlFlowTransformer=b;var m},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var i=function(){function e(e,t){for(var n=0;nt.options.deadCodeInjectionThreshold)return e;var r=b.RandomGeneratorUtils.getRandomInteger(0,t.collectedBlockStatements.length-1),o=t.collectedBlockStatements.splice(r,1)[0];return o===e?e:g.replaceBlockStatementNode(e,o)}})}}],[{key:"collectBlockStatementNodes",value:function(e,t){var n=y.NodeUtils.clone(e),r=0,o=!0;l.replace(n,{enter:function(e,t){return d.Node.isBlockStatementNode(e)&&r++,r>g.maxNestedBlockStatementsCount||d.Node.isBreakStatementNode(e)||d.Node.isContinueStatementNode(e)?(o=!1,l.VisitorOption.Break):(d.Node.isIdentifierNode(e)&&!d.Node.isMemberExpressionNode(t)&&(e.name=b.RandomGeneratorUtils.getRandomVariableName(6)),e)}}),o&&t.push(n)}},{key:"replaceBlockStatementNode",value:function(e,t){var n=b.RandomGeneratorUtils.getMathRandom()>.5,r=b.RandomGeneratorUtils.getMathRandom()>.5,o=n?"===":"!==",a=b.RandomGeneratorUtils.getRandomString(3),i=r?a:b.RandomGeneratorUtils.getRandomString(3),c=void 0,s=void 0;n&&r||!n&&!r?(c=e,s=t):(c=t,s=e);var u=p.Nodes.getBlockStatementNode([p.Nodes.getIfStatementNode(p.Nodes.getBinaryExpressionNode(o,p.Nodes.getLiteralNode(a),p.Nodes.getLiteralNode(i)),c,s)]);return u=y.NodeUtils.parentize(u)}}]),t}(f.AbstractNodeTransformer);m.maxNestedBlockStatementsCount=4,m.minCollectedBlockStatementsCount=5,m=g=c.__decorate([s.injectable(),c.__param(0,s.inject(u.ServiceIdentifiers.IOptions)),c.__metadata("design:paramtypes",[Object])],m),t.DeadCodeInjectionTransformer=m;var g},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var i=function(){function e(e,t){for(var n=0;n1){var o=d.Nodes.getBinaryExpressionNode("+",r.shift(),r.shift());return r.forEach(function(e){o=d.Nodes.getBinaryExpressionNode("+",o,e)}),o}return r[0]}}],[{key:"isLiteralNodeWithStringValue",value:function(e){return e&&f.Node.isLiteralNode(e)&&"string"==typeof e.value}}]),t}(l.AbstractNodeTransformer);p=y=c.__decorate([s.injectable(),c.__param(0,s.inject(u.ServiceIdentifiers.IOptions)),c.__metadata("design:paramtypes",[Object])],p),t.TemplateLiteralTransformer=p;var y},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var i=function(){function e(e,t){for(var n=0;nn)return"break";var a=e[o];s.traverse(a,{enter:function(n){if(l.Node.isCallExpressionNode(n))return a.parentNode!==f.NodeUtils.getBlockScopesOfNode(n)[0]?s.VisitorOption.Skip:void t.analyzeCallExpressionNode(r,e,n)}})}(a))break}return r}},{key:"analyzeCallExpressionNode",value:function(e,t,n){var r=this;p.calleeDataExtractorsList.forEach(function(o){var a=r.calleeDataExtractorFactory(o).extract(t,n.callee);a&&e.push(Object.assign({},a,{stackTrace:r.analyzeRecursive(a.callee.body)}))})}}],[{key:"getLimitIndex",value:function(e){var t=e-1,n=p.limitThresholdActivationLength-1,r=t;return t>n&&(r=Math.round(n+t*p.limitThreshold))>t&&(r=t),r}}]),e}();d.calleeDataExtractorsList=[u.CalleeDataExtractor.FunctionDeclarationCalleeDataExtractor,u.CalleeDataExtractor.FunctionExpressionCalleeDataExtractor,u.CalleeDataExtractor.ObjectExpressionCalleeDataExtractor],d.limitThresholdActivationLength=25,d.limitThreshold=.002,d=p=a.__decorate([i.injectable(),a.__param(0,i.inject(c.ServiceIdentifiers.Factory__ICalleeDataExtractor)),a.__metadata("design:paramtypes",[Function])],d),t.StackTraceAnalyzer=d;var p},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(0),o=n(2),a=n(114),i=n(115),c=n(116);t.storagesModule=new r.ContainerModule(function(e){e(o.ServiceIdentifiers.TCustomNodeGroupStorage).to(i.CustomNodeGroupStorage).inSingletonScope(),e(o.ServiceIdentifiers.TStringArrayStorage).to(c.StringArrayStorage).inSingletonScope(),e(o.ServiceIdentifiers.Newable__TControlFlowStorage).toConstructor(a.ControlFlowStorage),e(o.ServiceIdentifiers.Factory__TControlFlowStorage).toFactory(function(e){return function(){var t=e.container.get(o.ServiceIdentifiers.Newable__TControlFlowStorage);return new t}})})},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var i=n(37),c=function(e){function t(){r(this,t);var e=o(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return e.initialize(),e}return a(t,e),t}(i.MapStorage);t.ControlFlowStorage=c},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var i=function(){function e(e,t){for(var n=0;n=0?t:null}},{key:"getLength",value:function(){return this.storageLength}},{key:"getStorage",value:function(){return this.storage}},{key:"getStorageId",value:function(){return this.storageId}},{key:"initialize",value:function(){this.storage=[],this.storageId=u.RandomGeneratorUtils.getRandomString(6)}},{key:"mergeWith",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.storage=[].concat(r(this.storage),r(e.getStorage())),t&&(this.storageId=e.getStorageId())}},{key:"set",value:function(e,t){e===this.storageLength?this.storage.push(t):this.storage.splice(e,0,t),this.storageLength++}}]),e}();i.__decorate([s.initializable(),i.__metadata("design:type",Array)],l.prototype,"storage",void 0),i.__decorate([s.initializable(),i.__metadata("design:type",String)],l.prototype,"storageId",void 0),l=i.__decorate([c.injectable()],l),t.ArrayStorage=l},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var o=function(){function e(e,t){for(var n=0;n [options]").option("-o, --output ","Output path for obfuscated code").option("--compact ","Disable one line output code compacting",s.BooleanSanitizer).option("--controlFlowFlattening ","Enables control flow flattening",s.BooleanSanitizer).option("--controlFlowFlatteningThreshold ","The probability that the control flow flattening transformation will be applied to the node",parseFloat).option("--deadCodeInjection ","Enables dead code injection",s.BooleanSanitizer).option("--deadCodeInjectionThreshold ","The probability that the dead code injection transformation will be applied to the node",parseFloat).option("--debugProtection ","Disable browser Debug panel (can cause DevTools enabled browser freeze)",s.BooleanSanitizer).option("--debugProtectionInterval ","Disable browser Debug panel even after page was loaded (can cause DevTools enabled browser freeze)",s.BooleanSanitizer).option("--disableConsoleOutput ","Allow console.log, console.info, console.error and console.warn messages output into browser console",s.BooleanSanitizer).option("--domainLock ","Blocks the execution of the code in domains that do not match the passed RegExp patterns (comma separated)",function(e){return e.split(",")}).option("--mangle ","Enables mangling of variable names",s.BooleanSanitizer).option("--reservedNames ","Disable obfuscation of variable names, function names and names of function parameters that match the passed RegExp patterns (comma separated)",function(e){return e.split(",")}).option("--rotateStringArray ","Disable rotation of unicode array values during obfuscation",s.BooleanSanitizer).option("--seed ","Sets seed for random generator. This is useful for creating repeatable results.",parseFloat).option("--selfDefending ","Disables self-defending for obfuscated code",s.BooleanSanitizer).option("--sourceMap ","Enables source map generation",s.BooleanSanitizer).option("--sourceMapBaseUrl ","Sets base url to the source map import url when `--sourceMapMode=separate`").option("--sourceMapFileName ","Sets file name for output source map when `--sourceMapMode=separate`").option("--sourceMapMode [inline, separate]","Specify source map output mode",u.SourceMapModeSanitizer).option("--stringArray ","Disables gathering of all literal strings into an array and replacing every literal string with an array call",s.BooleanSanitizer).option("--stringArrayEncoding [true, false, base64, rc4]","Encodes all strings in strings array using base64 or rc4 (this option can slow down your code speed",l.StringArrayEncodingSanitizer).option("--stringArrayThreshold ","The probability that the literal string will be inserted into stringArray (Default: 0.8, Min: 0, Max: 1)",parseFloat).option("--unicodeEscapeSequence ","Allows to enable/disable string conversion to unicode escape sequence",s.BooleanSanitizer).parse(this.rawArguments)}},{key:"configureHelp",value:function(){this.commands.on("--help",function(){console.log(" Examples:\n"),console.log(" %> javascript-obfuscator in.js --compact true --selfDefending false"),console.log(" %> javascript-obfuscator in.js --output out.js --compact true --selfDefending false"),console.log("")})}},{key:"getData",value:function(){this.sourceCode=f.CLIUtils.readFile(this.inputPath)}},{key:"processData",value:function(){var e=this.buildOptions(),t=f.CLIUtils.getOutputCodePath(this.commands.output,this.inputPath);e.sourceMap?this.processDataWithSourceMap(t,e):this.processDataWithoutSourceMap(t,e)}},{key:"processDataWithoutSourceMap",value:function(e,t){var n=d.JavaScriptObfuscator.obfuscate(this.sourceCode,t).getObfuscatedCode();f.CLIUtils.writeFile(e,n)}},{key:"processDataWithSourceMap",value:function(e,t){var n=f.CLIUtils.getOutputSourceMapPath(e,t.sourceMapFileName||"");t=Object.assign({},t,{sourceMapFileName:i.basename(n)});var r=d.JavaScriptObfuscator.obfuscate(this.sourceCode,t);f.CLIUtils.writeFile(e,r.getObfuscatedCode()),"separate"===t.sourceMapMode&&r.getSourceMap()&&f.CLIUtils.writeFile(n,r.getSourceMap())}}]),e}();t.JavaScriptObfuscatorCLI=p},function(e,t){e.exports=require("commander")},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BooleanSanitizer=function(e){return"true"===e||"1"===e}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(22);t.SourceMapModeSanitizer=function(e){if(!Object.keys(r.SourceMapMode).some(function(t){return r.SourceMapMode[t]===e}))throw new ReferenceError("Invalid value of `--sourceMapMode` option");return e}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(27);t.StringArrayEncodingSanitizer=function(e){switch(e){case"true":case"1":case r.StringArrayEncoding.Base64:return!0;case r.StringArrayEncoding.Rc4:return r.StringArrayEncoding.Rc4;default:return!1}}},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var o=function(){function e(e,t){for(var n=0;n1&&void 0!==arguments[1]?arguments[1]:"";return t&&(e=e.substring(0,e.lastIndexOf("/"))+"/"+t),/\.js\.map$/.test(e)?/\.js$/.test(e)&&(e+=".map"):e=e.split(".")[0]+".js.map",e}},{key:"getPackageConfig",value:function(){return JSON.parse(a.readFileSync(c.join(c.dirname(a.realpathSync(process.argv[1])),"../package.json"),e.encoding))}},{key:"isFilePath",value:function(e){try{return a.statSync(e).isFile()}catch(e){return!1}}},{key:"readFile",value:function(t){return a.readFileSync(t,e.encoding)}},{key:"validateInputPath",value:function(t){if(!e.isFilePath(t))throw new ReferenceError("Given input path must be a valid file path");if(-1===e.availableInputExtensions.indexOf(c.extname(t)))throw new ReferenceError("Input file must have .js extension")}},{key:"writeFile",value:function(t,n){i.sync(c.dirname(t)),a.writeFileSync(t,n,{encoding:e.encoding})}}]),e}();s.availableInputExtensions=[".js"],s.encoding="utf8",t.CLIUtils=s},function(e,t){e.exports=require("fs")},function(e,t){e.exports=require("mkdirp")}]); //# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/package.json b/package.json index 32e41d05..97c06610 100644 --- a/package.json +++ b/package.json @@ -19,8 +19,8 @@ "javascript-obfuscator": "./bin/javascript-obfuscator.js" }, "dependencies": { - "chance": "1.0.9", - "class-validator": "0.7.0", + "chance": "1.0.10", + "class-validator": "0.7.1", "commander": "2.9.0", "escodegen-wallaby": "1.6.11", "esmangle": "1.0.1", @@ -44,7 +44,7 @@ "@types/estree": "0.0.35", "@types/mkdirp": "0.3.29", "@types/mocha": "2.2.41", - "@types/node": "7.0.31", + "@types/node": "8.0.0", "@types/sinon": "2.3.1", "@types/string-template": "1.0.2", "awesome-typescript-loader": "3.1.3", @@ -61,8 +61,8 @@ "ts-node": "3.0.6", "tslint": "5.4.3", "tslint-loader": "3.5.3", - "typescript": "2.3.4", - "webpack": "2.6.1", + "typescript": "2.4.0", + "webpack": "3.0.0", "webpack-node-externals": "1.6.0" }, "repository": { diff --git a/src/Obfuscator.ts b/src/Obfuscator.ts index 0b422a95..0b3685e4 100644 --- a/src/Obfuscator.ts +++ b/src/Obfuscator.ts @@ -188,8 +188,8 @@ export class Obfuscator implements IObfuscator { } estraverse.replace(astTree, { - enter: this.mergeVisitorsForDirection(enterVisitors, VisitorDirection.enter), - leave: this.mergeVisitorsForDirection(leaveVisitors, VisitorDirection.leave) + enter: this.mergeVisitorsForDirection(enterVisitors, VisitorDirection.Enter), + leave: this.mergeVisitorsForDirection(leaveVisitors, VisitorDirection.Leave) }); return astTree; diff --git a/src/cli/sanitizers/SourceMapModeSanitizer.ts b/src/cli/sanitizers/SourceMapModeSanitizer.ts index 09d9362b..5303a2b3 100644 --- a/src/cli/sanitizers/SourceMapModeSanitizer.ts +++ b/src/cli/sanitizers/SourceMapModeSanitizer.ts @@ -6,7 +6,7 @@ export const SourceMapModeSanitizer: TCLISanitizer = (value: string): string => const availableMode: boolean = Object .keys(SourceMapMode) .some((key: string): boolean => { - return SourceMapMode[key] === value; + return SourceMapMode[key] === value; }); if (!availableMode) { diff --git a/src/cli/sanitizers/StringArrayEncodingSanitizer.ts b/src/cli/sanitizers/StringArrayEncodingSanitizer.ts index 25b66a3e..7b51c415 100644 --- a/src/cli/sanitizers/StringArrayEncodingSanitizer.ts +++ b/src/cli/sanitizers/StringArrayEncodingSanitizer.ts @@ -7,11 +7,11 @@ export const StringArrayEncodingSanitizer: TCLISanitizer = (value: string): TStr switch (value) { case 'true': case '1': - case StringArrayEncoding.base64: + case StringArrayEncoding.Base64: return true; - case StringArrayEncoding.rc4: - return StringArrayEncoding.rc4; + case StringArrayEncoding.Rc4: + return StringArrayEncoding.Rc4; default: return false; diff --git a/src/custom-nodes/AbstractCustomNodeGroup.ts b/src/custom-nodes/AbstractCustomNodeGroup.ts index 656ee906..0231dc83 100644 --- a/src/custom-nodes/AbstractCustomNodeGroup.ts +++ b/src/custom-nodes/AbstractCustomNodeGroup.ts @@ -2,7 +2,6 @@ import { injectable, inject } from 'inversify'; import { ServiceIdentifiers } from '../container/ServiceIdentifiers'; import { TNodeWithBlockStatement } from '../types/node/TNodeWithBlockStatement'; -import { TObfuscationEvent } from '../types/event-emitters/TObfuscationEvent'; import { ICustomNode } from '../interfaces/custom-nodes/ICustomNode'; import { ICustomNodeGroup } from '../interfaces/custom-nodes/ICustomNodeGroup'; @@ -10,13 +9,14 @@ import { IOptions } from '../interfaces/options/IOptions'; import { IStackTraceData } from '../interfaces/stack-trace-analyzer/IStackTraceData'; import { CustomNode } from '../enums/container/custom-nodes/CustomNode'; +import { ObfuscationEvent } from '../enums/event-emitters/ObfuscationEvent'; @injectable() export abstract class AbstractCustomNodeGroup implements ICustomNodeGroup { /** - * @type {TObfuscationEvent} + * @type {ObfuscationEvent} */ - protected abstract readonly appendEvent: TObfuscationEvent; + protected abstract readonly appendEvent: ObfuscationEvent; /** * @type {Map} @@ -49,9 +49,9 @@ export abstract class AbstractCustomNodeGroup implements ICustomNodeGroup { public abstract appendCustomNodes (blockScopeNode: TNodeWithBlockStatement, stackTraceData: IStackTraceData[]): void; /** - * @returns {TObfuscationEvent} + * @returns {ObfuscationEvent} */ - public getAppendEvent (): TObfuscationEvent { + public getAppendEvent (): ObfuscationEvent { return this.appendEvent; } diff --git a/src/custom-nodes/console-output-nodes/group/ConsoleOutputCustomNodeGroup.ts b/src/custom-nodes/console-output-nodes/group/ConsoleOutputCustomNodeGroup.ts index dc169f17..da1c4ca7 100644 --- a/src/custom-nodes/console-output-nodes/group/ConsoleOutputCustomNodeGroup.ts +++ b/src/custom-nodes/console-output-nodes/group/ConsoleOutputCustomNodeGroup.ts @@ -3,7 +3,6 @@ import { ServiceIdentifiers } from '../../../container/ServiceIdentifiers'; import { TCustomNodeFactory } from '../../../types/container/custom-nodes/TCustomNodeFactory'; import { TNodeWithBlockStatement } from '../../../types/node/TNodeWithBlockStatement'; -import { TObfuscationEvent } from '../../../types/event-emitters/TObfuscationEvent'; import { ICustomNode } from '../../../interfaces/custom-nodes/ICustomNode'; import { IObfuscationEventEmitter } from '../../../interfaces/event-emitters/IObfuscationEventEmitter'; @@ -22,9 +21,9 @@ import { RandomGeneratorUtils } from '../../../utils/RandomGeneratorUtils'; @injectable() export class ConsoleOutputCustomNodeGroup extends AbstractCustomNodeGroup { /** - * @type {TObfuscationEvent} + * @type {ObfuscationEvent} */ - protected readonly appendEvent: TObfuscationEvent = ObfuscationEvent.BeforeObfuscation; + protected readonly appendEvent: ObfuscationEvent = ObfuscationEvent.BeforeObfuscation; /** * @type {Map} diff --git a/src/custom-nodes/debug-protection-nodes/group/DebugProtectionCustomNodeGroup.ts b/src/custom-nodes/debug-protection-nodes/group/DebugProtectionCustomNodeGroup.ts index e44094a5..c532b3ab 100644 --- a/src/custom-nodes/debug-protection-nodes/group/DebugProtectionCustomNodeGroup.ts +++ b/src/custom-nodes/debug-protection-nodes/group/DebugProtectionCustomNodeGroup.ts @@ -3,7 +3,6 @@ import { ServiceIdentifiers } from '../../../container/ServiceIdentifiers'; import { TCustomNodeFactory } from '../../../types/container/custom-nodes/TCustomNodeFactory'; import { TNodeWithBlockStatement } from '../../../types/node/TNodeWithBlockStatement'; -import { TObfuscationEvent } from '../../../types/event-emitters/TObfuscationEvent'; import { ICustomNode } from '../../../interfaces/custom-nodes/ICustomNode'; import { IObfuscationEventEmitter } from '../../../interfaces/event-emitters/IObfuscationEventEmitter'; @@ -22,9 +21,9 @@ import { RandomGeneratorUtils } from '../../../utils/RandomGeneratorUtils'; @injectable() export class DebugProtectionCustomNodeGroup extends AbstractCustomNodeGroup { /** - * @type {TObfuscationEvent} + * @type {ObfuscationEvent} */ - protected readonly appendEvent: TObfuscationEvent = ObfuscationEvent.BeforeObfuscation; + protected readonly appendEvent: ObfuscationEvent = ObfuscationEvent.BeforeObfuscation; /** * @type {Map} diff --git a/src/custom-nodes/domain-lock-nodes/group/DomainLockCustomNodeGroup.ts b/src/custom-nodes/domain-lock-nodes/group/DomainLockCustomNodeGroup.ts index 1c225c25..36179cfd 100644 --- a/src/custom-nodes/domain-lock-nodes/group/DomainLockCustomNodeGroup.ts +++ b/src/custom-nodes/domain-lock-nodes/group/DomainLockCustomNodeGroup.ts @@ -3,7 +3,6 @@ import { ServiceIdentifiers } from '../../../container/ServiceIdentifiers'; import { TCustomNodeFactory } from '../../../types/container/custom-nodes/TCustomNodeFactory'; import { TNodeWithBlockStatement } from '../../../types/node/TNodeWithBlockStatement'; -import { TObfuscationEvent } from '../../../types/event-emitters/TObfuscationEvent'; import { ICustomNode } from '../../../interfaces/custom-nodes/ICustomNode'; import { IObfuscationEventEmitter } from '../../../interfaces/event-emitters/IObfuscationEventEmitter'; @@ -22,9 +21,9 @@ import { RandomGeneratorUtils } from '../../../utils/RandomGeneratorUtils'; @injectable() export class DomainLockCustomNodeGroup extends AbstractCustomNodeGroup { /** - * @type {TObfuscationEvent} + * @type {ObfuscationEvent} */ - protected readonly appendEvent: TObfuscationEvent = ObfuscationEvent.BeforeObfuscation; + protected readonly appendEvent: ObfuscationEvent = ObfuscationEvent.BeforeObfuscation; /** * @type {Map} diff --git a/src/custom-nodes/node-calls-controller-nodes/NodeCallsControllerFunctionNode.ts b/src/custom-nodes/node-calls-controller-nodes/NodeCallsControllerFunctionNode.ts index e33ea1c6..c4a5d462 100644 --- a/src/custom-nodes/node-calls-controller-nodes/NodeCallsControllerFunctionNode.ts +++ b/src/custom-nodes/node-calls-controller-nodes/NodeCallsControllerFunctionNode.ts @@ -3,7 +3,6 @@ import { ServiceIdentifiers } from '../../container/ServiceIdentifiers'; import * as format from 'string-template'; -import { TObfuscationEvent } from '../../types/event-emitters/TObfuscationEvent'; import { TStatement } from '../../types/node/TStatement'; import { IOptions } from '../../interfaces/options/IOptions'; @@ -29,10 +28,10 @@ export class NodeCallsControllerFunctionNode extends AbstractCustomNode { protected callsControllerFunctionName: string; /** - * @type {TObfuscationEvent} + * @type {ObfuscationEvent} */ @initializable() - private appendEvent: TObfuscationEvent; + private appendEvent: ObfuscationEvent; /** * @param options @@ -47,7 +46,7 @@ export class NodeCallsControllerFunctionNode extends AbstractCustomNode { * @param appendEvent * @param callsControllerFunctionName */ - public initialize (appendEvent: TObfuscationEvent, callsControllerFunctionName: string): void { + public initialize (appendEvent: ObfuscationEvent, callsControllerFunctionName: string): void { this.appendEvent = appendEvent; this.callsControllerFunctionName = callsControllerFunctionName; } diff --git a/src/custom-nodes/self-defending-nodes/group/SelfDefendingCustomNodeGroup.ts b/src/custom-nodes/self-defending-nodes/group/SelfDefendingCustomNodeGroup.ts index ef97631c..369f3523 100644 --- a/src/custom-nodes/self-defending-nodes/group/SelfDefendingCustomNodeGroup.ts +++ b/src/custom-nodes/self-defending-nodes/group/SelfDefendingCustomNodeGroup.ts @@ -2,7 +2,6 @@ import { injectable, inject } from 'inversify'; import { ServiceIdentifiers } from '../../../container/ServiceIdentifiers'; import { TCustomNodeFactory } from '../../../types/container/custom-nodes/TCustomNodeFactory'; -import { TObfuscationEvent } from '../../../types/event-emitters/TObfuscationEvent'; import { TNodeWithBlockStatement } from '../../../types/node/TNodeWithBlockStatement'; import { ICustomNode } from '../../../interfaces/custom-nodes/ICustomNode'; @@ -22,9 +21,9 @@ import { RandomGeneratorUtils } from '../../../utils/RandomGeneratorUtils'; @injectable() export class SelfDefendingCustomNodeGroup extends AbstractCustomNodeGroup { /** - * @type {TObfuscationEvent} + * @type {ObfuscationEvent} */ - protected appendEvent: TObfuscationEvent = ObfuscationEvent.AfterObfuscation; + protected appendEvent: ObfuscationEvent = ObfuscationEvent.AfterObfuscation; /** * @type {Map} diff --git a/src/custom-nodes/string-array-nodes/StringArrayCallsWrapper.ts b/src/custom-nodes/string-array-nodes/StringArrayCallsWrapper.ts index d2972adb..cb2aefe6 100644 --- a/src/custom-nodes/string-array-nodes/StringArrayCallsWrapper.ts +++ b/src/custom-nodes/string-array-nodes/StringArrayCallsWrapper.ts @@ -110,7 +110,7 @@ export class StringArrayCallsWrapper extends AbstractCustomNode { } switch (this.options.stringArrayEncoding) { - case StringArrayEncoding.rc4: + case StringArrayEncoding.Rc4: decodeStringArrayTemplate = format(StringArrayRc4DecodeNodeTemplate(), { atobPolyfill: AtobTemplate(), rc4Polyfill: Rc4Template(), @@ -120,7 +120,7 @@ export class StringArrayCallsWrapper extends AbstractCustomNode { break; - case StringArrayEncoding.base64: + case StringArrayEncoding.Base64: decodeStringArrayTemplate = format(StringArrayBase64DecodeNodeTemplate(), { atobPolyfill: AtobTemplate(), selfDefendingCode, diff --git a/src/custom-nodes/string-array-nodes/group/StringArrayCustomNodeGroup.ts b/src/custom-nodes/string-array-nodes/group/StringArrayCustomNodeGroup.ts index 41788fc3..63d3fecd 100644 --- a/src/custom-nodes/string-array-nodes/group/StringArrayCustomNodeGroup.ts +++ b/src/custom-nodes/string-array-nodes/group/StringArrayCustomNodeGroup.ts @@ -3,7 +3,6 @@ import { ServiceIdentifiers } from '../../../container/ServiceIdentifiers'; import { TCustomNodeFactory } from '../../../types/container/custom-nodes/TCustomNodeFactory'; import { TNodeWithBlockStatement } from '../../../types/node/TNodeWithBlockStatement'; -import { TObfuscationEvent } from '../../../types/event-emitters/TObfuscationEvent'; import { ICustomNode } from '../../../interfaces/custom-nodes/ICustomNode'; import { IObfuscationEventEmitter } from '../../../interfaces/event-emitters/IObfuscationEventEmitter'; @@ -24,9 +23,9 @@ import { Utils } from '../../../utils/Utils'; @injectable() export class StringArrayCustomNodeGroup extends AbstractCustomNodeGroup { /** - * @type {TObfuscationEvent} + * @type {ObfuscationEvent} */ - protected appendEvent: TObfuscationEvent = ObfuscationEvent.AfterObfuscation; + protected appendEvent: ObfuscationEvent = ObfuscationEvent.AfterObfuscation; /** * @type {Map} diff --git a/src/enums/JSFuck.ts b/src/enums/JSFuck.ts index 6fe31a6c..b1b5021b 100644 --- a/src/enums/JSFuck.ts +++ b/src/enums/JSFuck.ts @@ -1,58 +1,58 @@ -export const JSFuck: any = { - False: '![]', - True: '!![]', +export enum JSFuck { + False = '![]', + True = '!![]', - a: '(false+"")[1]', - b: '([]["entries"]()+"")[2]', - c: '([]["fill"]+"")[3]', - d: '(undefined+"")[2]', - e: '(true+"")[3]', - f: '(false+"")[0]', - g: '(false+[0]+String)[20]', - h: '(+(101))["toString"](21)[1]', - i: '([false]+undefined)[10]', - j: '([]["entries"]()+"")[3]', - k: '(+(20))["toString"](21)', - l: '(false+"")[2]', - m: '(Number+"")[11]', - n: '(undefined+"")[1]', - o: '(true+[]["fill"])[10]', - p: '(+(211))["toString"](31)[1]', - q: '(+(212))["toString"](31)[1]', - r: '(true+"")[1]', - s: '(false+"")[3]', - t: '(true+"")[0]', - u: '(undefined+"")[0]', - v: '(+(31))["toString"](32)', - w: '(+(32))["toString"](33)', - x: '(+(101))["toString"](34)[1]', - y: '(NaN+[Infinity])[10]', - z: '(+(35))["toString"](36)', + a = '(false+"")[1]', + b = '([]["entries"]()+"")[2]', + c = '([]["fill"]+"")[3]', + d = '(undefined+"")[2]', + e = '(true+"")[3]', + f = '(false+"")[0]', + g = '(false+[0]+String)[20]', + h = '(+(101))["toString"](21)[1]', + i = '([false]+undefined)[10]', + j = '([]["entries"]()+"")[3]', + k = '(+(20))["toString"](21)', + l = '(false+"")[2]', + m = '(Number+"")[11]', + n = '(undefined+"")[1]', + o = '(true+[]["fill"])[10]', + p = '(+(211))["toString"](31)[1]', + q = '(+(212))["toString"](31)[1]', + r = '(true+"")[1]', + s = '(false+"")[3]', + t = '(true+"")[0]', + u = '(undefined+"")[0]', + v = '(+(31))["toString"](32)', + w = '(+(32))["toString"](33)', + x = '(+(101))["toString"](34)[1]', + y = '(NaN+[Infinity])[10]', + z = '(+(35))["toString"](36)', - A: '(+[]+Array)[10]', - B: '(+[]+Boolean)[10]', - C: 'Function("return escape")()(("")["italics"]())[2]', - D: 'Function("return escape")()([]["fill"])["slice"]("-1")', - E: '(RegExp+"")[12]', - F: '(+[]+Function)[10]', - G: '(false+Function("return Date")()())[30]', - H: `'H'`, - I: '(Infinity+"")[0]', - J: `'J'`, - K: `'K'`, - L: `'L'`, - M: '(true+Function("return Date")()())[30]', - N: '(NaN+"")[0]', - O: '(NaN+Function("return{}")())[11]', - P: `'P'`, - Q: `'Q'`, - R: '(+[]+RegExp)[10]', - S: '(+[]+String)[10]', - T: '(NaN+Function("return Date")()())[30]', - U: '(NaN+Function("return{}")()["toString"]["call"]())[11]', - V: `'V'`, - W: `'W'`, - X: `'X'`, - Y: `'Y'`, - Z: `'Z'` -}; + A = '(+[]+Array)[10]', + B = '(+[]+Boolean)[10]', + C = 'Function("return escape")()(("")["italics"]())[2]', + D = 'Function("return escape")()([]["fill"])["slice"]("-1")', + E = '(RegExp+"")[12]', + F = '(+[]+Function)[10]', + G = '(false+Function("return Date")()())[30]', + H = '\'H\'', + I = '(Infinity+"")[0]', + J = '\'J\'', + K = '\'K\'', + L = '\'L\'', + M = '(true+Function("return Date")()())[30]', + N = '(NaN+"")[0]', + O = '(NaN+Function("return{}")())[11]', + P = '\'P\'', + Q = '\'Q\'', + R = '(+[]+RegExp)[10]', + S = '(+[]+String)[10]', + T = '(NaN+Function("return Date")()())[30]', + U = '(NaN+Function("return{}")()["toString"]["call"]())[11]', + V = '\'V\'', + W = '\'W\'', + X = '\'X\'', + Y = '\'Y\'', + Z = '\'Z\'', +} diff --git a/src/enums/NodeType.ts b/src/enums/NodeType.ts index 6fea420c..99318f89 100644 --- a/src/enums/NodeType.ts +++ b/src/enums/NodeType.ts @@ -1,39 +1,37 @@ -import { Utils } from '../utils/Utils'; - -export const NodeType: any = Utils.strEnumify({ - ArrayExpression: 'ArrayExpression', - ArrowFunctionExpression: 'ArrowFunctionExpression', - AssignmentExpression: 'AssignmentExpression', - AssignmentPattern: 'AssignmentPattern', - BinaryExpression: 'BinaryExpression', - BlockStatement: 'BlockStatement', - BreakStatement: 'BreakStatement', - CallExpression: 'CallExpression', - CatchClause: 'CatchClause', - ClassDeclaration: 'ClassDeclaration', - ContinueStatement: 'ContinueStatement', - ExpressionStatement: 'ExpressionStatement', - FunctionDeclaration: 'FunctionDeclaration', - FunctionExpression: 'FunctionExpression', - Identifier: 'Identifier', - IfStatement: 'IfStatement', - LabeledStatement: 'LabeledStatement', - Literal: 'Literal', - LogicalExpression: 'LogicalExpression', - MemberExpression: 'MemberExpression', - MethodDefinition: 'MethodDefinition', - ObjectExpression: 'ObjectExpression', - ObjectPattern: 'ObjectPattern', - Program: 'Program', - Property: 'Property', - ReturnStatement: 'ReturnStatement', - SwitchCase: 'SwitchCase', - SwitchStatement: 'SwitchStatement', - TemplateLiteral: 'TemplateLiteral', - TryStatement: 'TryStatement', - UnaryExpression: 'UnaryExpression', - UpdateExpression: 'UpdateExpression', - VariableDeclaration: 'VariableDeclaration', - VariableDeclarator: 'VariableDeclarator', - WhileStatement: 'WhileStatement' -}); +export enum NodeType { + ArrayExpression = 'ArrayExpression', + ArrowFunctionExpression = 'ArrowFunctionExpression', + AssignmentExpression = 'AssignmentExpression', + AssignmentPattern = 'AssignmentPattern', + BinaryExpression = 'BinaryExpression', + BlockStatement = 'BlockStatement', + BreakStatement = 'BreakStatement', + CallExpression = 'CallExpression', + CatchClause = 'CatchClause', + ClassDeclaration = 'ClassDeclaration', + ContinueStatement = 'ContinueStatement', + ExpressionStatement = 'ExpressionStatement', + FunctionDeclaration = 'FunctionDeclaration', + FunctionExpression = 'FunctionExpression', + Identifier = 'Identifier', + IfStatement = 'IfStatement', + LabeledStatement = 'LabeledStatement', + Literal = 'Literal', + LogicalExpression = 'LogicalExpression', + MemberExpression = 'MemberExpression', + MethodDefinition = 'MethodDefinition', + ObjectExpression = 'ObjectExpression', + ObjectPattern = 'ObjectPattern', + Program = 'Program', + Property = 'Property', + ReturnStatement = 'ReturnStatement', + SwitchCase = 'SwitchCase', + SwitchStatement = 'SwitchStatement', + TemplateLiteral = 'TemplateLiteral', + TryStatement = 'TryStatement', + UnaryExpression = 'UnaryExpression', + UpdateExpression = 'UpdateExpression', + VariableDeclaration = 'VariableDeclaration', + VariableDeclarator = 'VariableDeclarator', + WhileStatement = 'WhileStatement' +} diff --git a/src/enums/SourceMapMode.ts b/src/enums/SourceMapMode.ts index 6da0f3a2..1075045c 100644 --- a/src/enums/SourceMapMode.ts +++ b/src/enums/SourceMapMode.ts @@ -1,4 +1,4 @@ -export const SourceMapMode: any = { - Inline: 'inline', - Separate: 'separate' -}; +export enum SourceMapMode { + Inline = 'inline', + Separate = 'separate' +} diff --git a/src/enums/StringArrayEncoding.ts b/src/enums/StringArrayEncoding.ts index e34aa9dd..4fa43beb 100644 --- a/src/enums/StringArrayEncoding.ts +++ b/src/enums/StringArrayEncoding.ts @@ -1,4 +1,4 @@ -export const StringArrayEncoding: any = { - base64: 'base64', - rc4: 'rc4' -}; +export enum StringArrayEncoding { + Base64 = 'base64', + Rc4 = 'rc4' +} diff --git a/src/enums/VisitorDirection.ts b/src/enums/VisitorDirection.ts index 38a1c124..8ea92195 100644 --- a/src/enums/VisitorDirection.ts +++ b/src/enums/VisitorDirection.ts @@ -1,6 +1,4 @@ -import { Utils } from '../utils/Utils'; - -export const VisitorDirection: any = Utils.strEnumify({ - enter: 'enter', - leave: 'leave' -}); +export enum VisitorDirection { + Enter = 'enter', + Leave = 'leave' +} diff --git a/src/enums/event-emitters/ObfuscationEvent.ts b/src/enums/event-emitters/ObfuscationEvent.ts index 0abce513..2a3b8b0e 100644 --- a/src/enums/event-emitters/ObfuscationEvent.ts +++ b/src/enums/event-emitters/ObfuscationEvent.ts @@ -1,9 +1,4 @@ -import { TObfuscationEvent } from '../../types/event-emitters/TObfuscationEvent'; - -export const ObfuscationEvent: { - AfterObfuscation: TObfuscationEvent, - BeforeObfuscation: TObfuscationEvent -} = { - AfterObfuscation: 'afterObfuscation', - BeforeObfuscation: 'beforeObfuscation' -}; +export enum ObfuscationEvent { + AfterObfuscation = 'afterObfuscation', + BeforeObfuscation = 'beforeObfuscation' +} diff --git a/src/interfaces/custom-nodes/ICustomNodeGroup.d.ts b/src/interfaces/custom-nodes/ICustomNodeGroup.d.ts index 9dac9138..22da6ea9 100644 --- a/src/interfaces/custom-nodes/ICustomNodeGroup.d.ts +++ b/src/interfaces/custom-nodes/ICustomNodeGroup.d.ts @@ -1,11 +1,11 @@ import { TNodeWithBlockStatement } from '../../types/node/TNodeWithBlockStatement'; -import { TObfuscationEvent } from '../../types/event-emitters/TObfuscationEvent'; import { ICustomNode } from './ICustomNode'; import { IInitializable } from '../IInitializable'; import { IStackTraceData } from '../stack-trace-analyzer/IStackTraceData'; import { CustomNode } from '../../enums/container/custom-nodes/CustomNode'; +import { ObfuscationEvent } from '../../enums/event-emitters/ObfuscationEvent'; export interface ICustomNodeGroup extends IInitializable { /** @@ -15,9 +15,9 @@ export interface ICustomNodeGroup extends IInitializable { appendCustomNodes (blockScopeNode: TNodeWithBlockStatement, stackTraceData: IStackTraceData[]): void; /** - * @returns {TObfuscationEvent} + * @returns {ObfuscationEvent} */ - getAppendEvent (): TObfuscationEvent; + getAppendEvent (): ObfuscationEvent; /** * @type {Map } diff --git a/src/interfaces/event-emitters/IObfuscationEventEmitter.d.ts b/src/interfaces/event-emitters/IObfuscationEventEmitter.d.ts index 15d8a212..8928516f 100644 --- a/src/interfaces/event-emitters/IObfuscationEventEmitter.d.ts +++ b/src/interfaces/event-emitters/IObfuscationEventEmitter.d.ts @@ -1,6 +1,6 @@ import Events = NodeJS.Events; -import { TObfuscationEvent } from '../../types/event-emitters/TObfuscationEvent'; +import { ObfuscationEvent } from '../../enums/event-emitters/ObfuscationEvent'; export interface IObfuscationEventEmitter extends Events { /** @@ -8,12 +8,12 @@ export interface IObfuscationEventEmitter extends Events { * @param listener * @returns this */ - on(event: TObfuscationEvent, listener: Function): this; + on (event: ObfuscationEvent, listener: Function): this; /** * @param event * @param listener * @returns this */ - once(event: TObfuscationEvent, listener: Function): this; + once (event: ObfuscationEvent, listener: Function): this; } diff --git a/src/interfaces/node-transformers/obfuscating-transformers/IEncodedValue.d.ts b/src/interfaces/node-transformers/obfuscating-transformers/obfuscating-replacers/literal-obfuscating-replacers/IEncodedValue.d.ts similarity index 73% rename from src/interfaces/node-transformers/obfuscating-transformers/IEncodedValue.d.ts rename to src/interfaces/node-transformers/obfuscating-transformers/obfuscating-replacers/literal-obfuscating-replacers/IEncodedValue.d.ts index f6e925cf..03954456 100644 --- a/src/interfaces/node-transformers/obfuscating-transformers/IEncodedValue.d.ts +++ b/src/interfaces/node-transformers/obfuscating-transformers/obfuscating-replacers/literal-obfuscating-replacers/IEncodedValue.d.ts @@ -1,4 +1,4 @@ export interface IEncodedValue { encodedValue: string; - key?: string; + key: string|null; } diff --git a/src/interfaces/node-transformers/obfuscating-transformers/obfuscating-replacers/literal-obfuscating-replacers/IStringArrayIndexData.d.ts b/src/interfaces/node-transformers/obfuscating-transformers/obfuscating-replacers/literal-obfuscating-replacers/IStringArrayIndexData.d.ts new file mode 100644 index 00000000..91feb2fb --- /dev/null +++ b/src/interfaces/node-transformers/obfuscating-transformers/obfuscating-replacers/literal-obfuscating-replacers/IStringArrayIndexData.d.ts @@ -0,0 +1,4 @@ +export interface IStringArrayIndexData { + fromCache: boolean; + index: string; +} diff --git a/src/node-transformers/obfuscating-transformers/obfuscating-replacers/literal-obfuscating-replacers/StringLiteralObfuscatingReplacer.ts b/src/node-transformers/obfuscating-transformers/obfuscating-replacers/literal-obfuscating-replacers/StringLiteralObfuscatingReplacer.ts index a32d3d38..aea9492e 100644 --- a/src/node-transformers/obfuscating-transformers/obfuscating-replacers/literal-obfuscating-replacers/StringLiteralObfuscatingReplacer.ts +++ b/src/node-transformers/obfuscating-transformers/obfuscating-replacers/literal-obfuscating-replacers/StringLiteralObfuscatingReplacer.ts @@ -4,9 +4,10 @@ import { ServiceIdentifiers } from '../../../../container/ServiceIdentifiers'; import * as ESTree from 'estree'; import { ICustomNodeGroup } from '../../../../interfaces/custom-nodes/ICustomNodeGroup'; -import { IEncodedValue } from '../../../../interfaces/node-transformers/obfuscating-transformers/IEncodedValue'; +import { IEncodedValue } from '../../../../interfaces/node-transformers/obfuscating-transformers/obfuscating-replacers/literal-obfuscating-replacers/IEncodedValue'; import { IOptions } from '../../../../interfaces/options/IOptions'; import { IStorage } from '../../../../interfaces/storages/IStorage'; +import { IStringArrayIndexData } from '../../../../interfaces/node-transformers/obfuscating-transformers/obfuscating-replacers/literal-obfuscating-replacers/IStringArrayIndexData'; import { StringArrayEncoding } from '../../../../enums/StringArrayEncoding'; @@ -23,6 +24,16 @@ export class StringLiteralObfuscatingReplacer extends AbstractObfuscatingReplace */ private static readonly minimumLengthForStringArray: number = 3; + /** + * @type {number} + */ + private static rc4KeyLength: number = 4; + + /** + * @type {number} + */ + private static rc4KeysCount: number = 50; + /** * @type {IStorage} */ @@ -64,7 +75,12 @@ export class StringLiteralObfuscatingReplacer extends AbstractObfuscatingReplace this.stringArrayStorage = stringArrayStorage; this.rc4Keys = RandomGeneratorUtils.getRandomGenerator() - .n(() => RandomGeneratorUtils.getRandomGenerator().string({length: 4}), 50); + .n( + () => RandomGeneratorUtils.getRandomGenerator().string({ + length: StringLiteralObfuscatingReplacer.rc4KeyLength + }), + StringLiteralObfuscatingReplacer.rc4KeysCount + ); } /** @@ -96,22 +112,17 @@ export class StringLiteralObfuscatingReplacer extends AbstractObfuscatingReplace * @returns {ESTree.Node} */ public replace (nodeValue: string): ESTree.Node { - const usingStringArray: boolean = this.canUseStringArray(nodeValue); - const cacheKey: string = `${nodeValue}-${String(usingStringArray)}`; + const useStringArray: boolean = this.canUseStringArray(nodeValue); + const cacheKey: string = `${nodeValue}-${String(useStringArray)}`; + const useCacheValue: boolean = this.nodesCache.has(cacheKey) && this.options.stringArrayEncoding !== StringArrayEncoding.Rc4; - if (this.nodesCache.has(cacheKey) && this.options.stringArrayEncoding !== StringArrayEncoding.rc4) { + if (useCacheValue) { return this.nodesCache.get(cacheKey); } - let resultNode: ESTree.Node; - - if (usingStringArray) { - resultNode = this.replaceWithStringArrayCallNode(nodeValue); - } else { - resultNode = Nodes.getLiteralNode( - `${Utils.stringToUnicodeEscapeSequence(nodeValue, !this.options.unicodeEscapeSequence)}` - ); - } + const resultNode: ESTree.Node = useStringArray + ? this.replaceWithStringArrayCallNode(nodeValue) + : this.replaceWithLiteralNode(nodeValue); this.nodesCache.set(cacheKey, resultNode); @@ -132,20 +143,26 @@ export class StringLiteralObfuscatingReplacer extends AbstractObfuscatingReplace /** * @param value - * @return {string} + * @param stringArrayStorageLength + * @return {IStringArrayIndexData} */ - private getArrayHexadecimalIndex (value: string): string { + private getStringArrayHexadecimalIndex (value: string, stringArrayStorageLength: number): IStringArrayIndexData { if (this.stringLiteralHexadecimalIndexCache.has(value)) { - return this.stringLiteralHexadecimalIndexCache.get(value); + return { + fromCache: true, + index: this.stringLiteralHexadecimalIndexCache.get(value) + }; } - const stringArrayStorageLength: number = this.stringArrayStorage.getLength(); - const hexadecimalIndex: string = `${Utils.hexadecimalPrefix}${Utils.decToHex(stringArrayStorageLength)}`; + const hexadecimalRawIndex: string = Utils.decToHex(stringArrayStorageLength); + const hexadecimalIndex: string = `${Utils.hexadecimalPrefix}${hexadecimalRawIndex}`; - this.stringArrayStorage.set(stringArrayStorageLength, value); this.stringLiteralHexadecimalIndexCache.set(value, hexadecimalIndex); - return hexadecimalIndex; + return { + fromCache: false, + index: hexadecimalIndex + }; } /** @@ -154,16 +171,16 @@ export class StringLiteralObfuscatingReplacer extends AbstractObfuscatingReplace */ private getEncodedValue (value: string): IEncodedValue { let encodedValue: string, - key: string | undefined; + key: string | null = null; switch (this.options.stringArrayEncoding) { - case StringArrayEncoding.rc4: + case StringArrayEncoding.Rc4: key = RandomGeneratorUtils.getRandomGenerator().pickone(this.rc4Keys); encodedValue = CryptUtils.btoa(CryptUtils.rc4(value, key)); break; - case StringArrayEncoding.base64: + case StringArrayEncoding.Base64: encodedValue = CryptUtils.btoa(value); break; @@ -172,28 +189,50 @@ export class StringLiteralObfuscatingReplacer extends AbstractObfuscatingReplace encodedValue = value; } - encodedValue = Utils.stringToUnicodeEscapeSequence(encodedValue, !this.options.unicodeEscapeSequence); - return { encodedValue, key }; } + /** + * @param value + * @return {ESTree.Literal} + */ + private replaceWithLiteralNode (value: string): ESTree.Node { + return Nodes.getLiteralNode( + Utils.stringToUnicodeEscapeSequence( + value, + this.options.unicodeEscapeSequence + ) + ); + } + /** * @param value * @returns {ESTree.Node} */ private replaceWithStringArrayCallNode (value: string): ESTree.Node { const { encodedValue, key }: IEncodedValue = this.getEncodedValue(value); + const escapedValue: string = Utils.stringToUnicodeEscapeSequence(encodedValue, this.options.unicodeEscapeSequence); + + const stringArrayStorageLength: number = this.stringArrayStorage.getLength(); const rotatedStringArrayStorageId: string = Utils.stringRotate(this.stringArrayStorage.getStorageId(), 1); const stringArrayStorageCallsWrapperName: string = `_${Utils.hexadecimalPrefix}${rotatedStringArrayStorageId}`; + + const { fromCache, index }: IStringArrayIndexData = this.getStringArrayHexadecimalIndex( + escapedValue, + stringArrayStorageLength + ); + + if (!fromCache) { + this.stringArrayStorage.set(stringArrayStorageLength, escapedValue); + } + const callExpressionArgs: (ESTree.Expression | ESTree.SpreadElement)[] = [ - StringLiteralObfuscatingReplacer.getHexadecimalLiteralNode( - this.getArrayHexadecimalIndex(encodedValue) - ) + StringLiteralObfuscatingReplacer.getHexadecimalLiteralNode(index) ]; if (key) { callExpressionArgs.push(StringLiteralObfuscatingReplacer.getRc4KeyLiteralNode( - Utils.stringToUnicodeEscapeSequence(key, !this.options.unicodeEscapeSequence) + Utils.stringToUnicodeEscapeSequence(key, this.options.unicodeEscapeSequence) )); } diff --git a/src/options/normalizer-rules/ControlFlowFlatteningThresholdRule.ts b/src/options/normalizer-rules/ControlFlowFlatteningThresholdRule.ts index c1c35424..0b3869d4 100644 --- a/src/options/normalizer-rules/ControlFlowFlatteningThresholdRule.ts +++ b/src/options/normalizer-rules/ControlFlowFlatteningThresholdRule.ts @@ -1,18 +1,13 @@ -import { TInputOptions } from '../../types/options/TInputOptions'; import { TOptionsNormalizerRule } from '../../types/options/TOptionsNormalizerRule'; import { IOptions } from '../../interfaces/options/IOptions'; -const DISABLED_CONTROL_FLOW_FLATTENING_OPTIONS: TInputOptions = { - controlFlowFlattening: false, - controlFlowFlatteningThreshold: 0 -}; - export const ControlFlowFlatteningThresholdRule: TOptionsNormalizerRule = (options: IOptions): IOptions => { if (options.controlFlowFlatteningThreshold === 0) { options = { ...options, - ...DISABLED_CONTROL_FLOW_FLATTENING_OPTIONS + controlFlowFlattening: false, + controlFlowFlatteningThreshold: 0 }; } diff --git a/src/options/normalizer-rules/DeadCodeInjectionRule.ts b/src/options/normalizer-rules/DeadCodeInjectionRule.ts index b4d92865..eeb058b5 100644 --- a/src/options/normalizer-rules/DeadCodeInjectionRule.ts +++ b/src/options/normalizer-rules/DeadCodeInjectionRule.ts @@ -1,31 +1,22 @@ -import { TInputOptions } from '../../types/options/TInputOptions'; import { TOptionsNormalizerRule } from '../../types/options/TOptionsNormalizerRule'; import { IOptions } from '../../interfaces/options/IOptions'; import { DEFAULT_PRESET } from '../presets/Default'; -const ENABLED_DEAD_CODE_INJECTION_OPTIONS: TInputOptions = { - deadCodeInjection: true, - stringArray: true -}; - -const ENABLED_STRING_ARRAY_THRESHOLD_OPTIONS: TInputOptions = { - stringArray: true, - stringArrayThreshold: DEFAULT_PRESET.stringArrayThreshold -}; - export const DeadCodeInjectionRule: TOptionsNormalizerRule = (options: IOptions): IOptions => { if (options.deadCodeInjection) { options = { ...options, - ...ENABLED_DEAD_CODE_INJECTION_OPTIONS, + deadCodeInjection: true, + stringArray: true }; if (!options.stringArrayThreshold) { options = { ...options, - ...ENABLED_STRING_ARRAY_THRESHOLD_OPTIONS + stringArray: true, + stringArrayThreshold: DEFAULT_PRESET.stringArrayThreshold }; } } diff --git a/src/options/normalizer-rules/DeadCodeInjectionThresholdRule.ts b/src/options/normalizer-rules/DeadCodeInjectionThresholdRule.ts index 4bc9e4e4..351a7215 100644 --- a/src/options/normalizer-rules/DeadCodeInjectionThresholdRule.ts +++ b/src/options/normalizer-rules/DeadCodeInjectionThresholdRule.ts @@ -1,18 +1,13 @@ -import { TInputOptions } from '../../types/options/TInputOptions'; import { TOptionsNormalizerRule } from '../../types/options/TOptionsNormalizerRule'; import { IOptions } from '../../interfaces/options/IOptions'; -const DISABLED_DEAD_CODE_INJECTION_OPTIONS: TInputOptions = { - deadCodeInjection: false, - deadCodeInjectionThreshold: 0 -}; - export const DeadCodeInjectionThresholdRule: TOptionsNormalizerRule = (options: IOptions): IOptions => { if (options.deadCodeInjectionThreshold === 0) { options = { ...options, - ...DISABLED_DEAD_CODE_INJECTION_OPTIONS + deadCodeInjection: false, + deadCodeInjectionThreshold: 0 }; } diff --git a/src/options/normalizer-rules/SelfDefendingRule.ts b/src/options/normalizer-rules/SelfDefendingRule.ts index 91b5901d..687af386 100644 --- a/src/options/normalizer-rules/SelfDefendingRule.ts +++ b/src/options/normalizer-rules/SelfDefendingRule.ts @@ -1,18 +1,13 @@ -import { TInputOptions } from '../../types/options/TInputOptions'; import { TOptionsNormalizerRule } from '../../types/options/TOptionsNormalizerRule'; import { IOptions } from '../../interfaces/options/IOptions'; -const SELF_DEFENDING_OPTIONS: TInputOptions = { - compact: true, - selfDefending: true -}; - export const SelfDefendingRule: TOptionsNormalizerRule = (options: IOptions): IOptions => { if (options.selfDefending) { options = { ...options, - ...SELF_DEFENDING_OPTIONS + compact: true, + selfDefending: true }; } diff --git a/src/options/normalizer-rules/StringArrayEncodingRule.ts b/src/options/normalizer-rules/StringArrayEncodingRule.ts index 8dc05706..47624f7e 100644 --- a/src/options/normalizer-rules/StringArrayEncodingRule.ts +++ b/src/options/normalizer-rules/StringArrayEncodingRule.ts @@ -1,17 +1,12 @@ -import { TInputOptions } from '../../types/options/TInputOptions'; import { TOptionsNormalizerRule } from '../../types/options/TOptionsNormalizerRule'; import { IOptions } from '../../interfaces/options/IOptions'; -const STRING_ARRAY_ENCODING_OPTIONS: TInputOptions = { - stringArrayEncoding: 'base64' -}; - export const StringArrayEncodingRule: TOptionsNormalizerRule = (options: IOptions): IOptions => { if (options.stringArrayEncoding === true) { options = { ...options, - ...STRING_ARRAY_ENCODING_OPTIONS + stringArrayEncoding: 'base64' }; } diff --git a/src/options/normalizer-rules/StringArrayRule.ts b/src/options/normalizer-rules/StringArrayRule.ts index ac703b0d..92ca7026 100644 --- a/src/options/normalizer-rules/StringArrayRule.ts +++ b/src/options/normalizer-rules/StringArrayRule.ts @@ -1,20 +1,15 @@ -import { TInputOptions } from '../../types/options/TInputOptions'; import { TOptionsNormalizerRule } from '../../types/options/TOptionsNormalizerRule'; import { IOptions } from '../../interfaces/options/IOptions'; -const DISABLED_STRING_ARRAY_OPTIONS: TInputOptions = { - rotateStringArray: false, - stringArray: false, - stringArrayEncoding: false, - stringArrayThreshold: 0 -}; - export const StringArrayRule: TOptionsNormalizerRule = (options: IOptions): IOptions => { if (!options.stringArray) { options = { ...options, - ...DISABLED_STRING_ARRAY_OPTIONS + rotateStringArray: false, + stringArray: false, + stringArrayEncoding: false, + stringArrayThreshold: 0 }; } diff --git a/src/options/normalizer-rules/StringArrayThresholdRule.ts b/src/options/normalizer-rules/StringArrayThresholdRule.ts index a0e877b6..0b69c87b 100644 --- a/src/options/normalizer-rules/StringArrayThresholdRule.ts +++ b/src/options/normalizer-rules/StringArrayThresholdRule.ts @@ -1,20 +1,15 @@ -import { TInputOptions } from '../../types/options/TInputOptions'; import { TOptionsNormalizerRule } from '../../types/options/TOptionsNormalizerRule'; import { IOptions } from '../../interfaces/options/IOptions'; -const DISABLED_STRING_ARRAY_OPTIONS: TInputOptions = { - rotateStringArray: false, - stringArray: false, - stringArrayEncoding: false, - stringArrayThreshold: 0 -}; - export const StringArrayThresholdRule: TOptionsNormalizerRule = (options: IOptions): IOptions => { if (options.stringArrayThreshold === 0) { options = { ...options, - ...DISABLED_STRING_ARRAY_OPTIONS + rotateStringArray: false, + stringArray: false, + stringArrayEncoding: false, + stringArrayThreshold: 0 }; } diff --git a/src/templates/custom-nodes/self-defending-nodes/self-defending-unicode-node/SelfDefendingTemplate.ts b/src/templates/custom-nodes/self-defending-nodes/self-defending-unicode-node/SelfDefendingTemplate.ts index 84c3afe7..d1d59f6c 100644 --- a/src/templates/custom-nodes/self-defending-nodes/self-defending-unicode-node/SelfDefendingTemplate.ts +++ b/src/templates/custom-nodes/self-defending-nodes/self-defending-unicode-node/SelfDefendingTemplate.ts @@ -15,13 +15,17 @@ export function SelfDefendingTemplate (): string { }; var test1 = function () { - var regExp = new RegExp('${Utils.stringToUnicodeEscapeSequence(`\\w+ *\\(\\) *{\\w+ *['|"].+['|"];? *}`)}'); + var regExp = new RegExp('${ + Utils.stringToUnicodeEscapeSequence(`\\w+ *\\(\\) *{\\w+ *['|"].+['|"];? *}`, true) + }'); return !regExp.test(func1.toString()); }; var test2 = function () { - var regExp = new RegExp('${Utils.stringToUnicodeEscapeSequence(`(\\\\[x|u](\\w){2,4})+`)}'); + var regExp = new RegExp('${ + Utils.stringToUnicodeEscapeSequence(`(\\\\[x|u](\\w){2,4})+`, true) + }'); return regExp.test(func2.toString()); }; diff --git a/src/templates/custom-nodes/string-array-nodes/string-array-calls-wrapper/SelfDefendingTemplate.ts b/src/templates/custom-nodes/string-array-nodes/string-array-calls-wrapper/SelfDefendingTemplate.ts index 555ef4e0..e5cd49a0 100644 --- a/src/templates/custom-nodes/string-array-nodes/string-array-calls-wrapper/SelfDefendingTemplate.ts +++ b/src/templates/custom-nodes/string-array-nodes/string-array-calls-wrapper/SelfDefendingTemplate.ts @@ -9,8 +9,12 @@ export function SelfDefendingTemplate (): string { this.rc4Bytes = rc4Bytes; this.states = [1, 0, 0]; this.newState = function(){return 'newState';}; - this.firstState = '${Utils.stringToUnicodeEscapeSequence(`\\w+ *\\(\\) *{\\w+ *`)}'; - this.secondState = '${Utils.stringToUnicodeEscapeSequence(`['|"].+['|"];? *}`)}'; + this.firstState = '${ + Utils.stringToUnicodeEscapeSequence(`\\w+ *\\(\\) *{\\w+ *`, true) + }'; + this.secondState = '${ + Utils.stringToUnicodeEscapeSequence(`['|"].+['|"];? *}`, true) + }'; }; StatesClass.prototype.checkState = function () { diff --git a/src/templates/custom-nodes/string-array-nodes/string-array-rotate-function-node/SelfDefendingTemplate.ts b/src/templates/custom-nodes/string-array-nodes/string-array-rotate-function-node/SelfDefendingTemplate.ts index 13b5a0ce..e924bfc8 100644 --- a/src/templates/custom-nodes/string-array-nodes/string-array-rotate-function-node/SelfDefendingTemplate.ts +++ b/src/templates/custom-nodes/string-array-nodes/string-array-rotate-function-node/SelfDefendingTemplate.ts @@ -55,7 +55,9 @@ export function SelfDefendingTemplate (): string { }; var test1 = function () { - var regExp = new RegExp('${Utils.stringToUnicodeEscapeSequence(`\\w+ *\\(\\) *{\\w+ *['|"].+['|"];? *}`)}'); + var regExp = new RegExp('${ + Utils.stringToUnicodeEscapeSequence(`\\w+ *\\(\\) *{\\w+ *['|"].+['|"];? *}`, true) + }'); return regExp.test(object.removeCookie.toString()); }; diff --git a/src/types/event-emitters/TObfuscationEvent.d.ts b/src/types/event-emitters/TObfuscationEvent.d.ts deleted file mode 100644 index 76b515d3..00000000 --- a/src/types/event-emitters/TObfuscationEvent.d.ts +++ /dev/null @@ -1 +0,0 @@ -export type TObfuscationEvent = 'beforeObfuscation' | 'afterObfuscation'; diff --git a/src/utils/Utils.ts b/src/utils/Utils.ts index 158a4a50..500337b2 100644 --- a/src/utils/Utils.ts +++ b/src/utils/Utils.ts @@ -138,18 +138,18 @@ export class Utils { return Array .from(string) .map((character: string): string => { - return JSFuck[character] || character; + return JSFuck[character] || character; }) .join(' + '); } /** * @param string - * @param nonLatinAndNonDigitsOnly + * @param usingUnicodeEscapeSequence * @returns {string} */ - public static stringToUnicodeEscapeSequence (string: string, nonLatinAndNonDigitsOnly: boolean = false): string { - const cacheKey: string = `${string}-${String(nonLatinAndNonDigitsOnly)}`; + public static stringToUnicodeEscapeSequence (string: string, usingUnicodeEscapeSequence: boolean): string { + const cacheKey: string = `${string}-${String(usingUnicodeEscapeSequence)}`; if (Utils.stringToUnicodeEscapeSequenceCache.has(cacheKey)) { return Utils.stringToUnicodeEscapeSequenceCache.get(cacheKey); @@ -157,18 +157,18 @@ export class Utils { const radix: number = 16; const replaceRegExp: RegExp = new RegExp('[\\s\\S]', 'g'); - const escapeRegExp: RegExp = new RegExp('[^a-zA-Z0-9]'); - const regexp: RegExp = new RegExp('[\\x00-\\x7F]'); + const escapeSequenceRegExp: RegExp = new RegExp('[\'\"\\\\\\s]'); + const regExp: RegExp = new RegExp('[\\x00-\\x7F]'); let prefix: string, template: string; - const result: string = string.replace(replaceRegExp, (escape: string): string => { - if (nonLatinAndNonDigitsOnly && !escapeRegExp.exec(escape)) { - return escape; + const result: string = string.replace(replaceRegExp, (character: string): string => { + if (!usingUnicodeEscapeSequence && !escapeSequenceRegExp.exec(character)) { + return character; } - if (regexp.exec(escape)) { + if (regExp.exec(character)) { prefix = '\\x'; template = '00'; } else { @@ -176,7 +176,7 @@ export class Utils { template = '0000'; } - return `${prefix}${(template + escape.charCodeAt(0).toString(radix)).slice(-template.length)}`; + return `${prefix}${(template + character.charCodeAt(0).toString(radix)).slice(-template.length)}`; }); Utils.stringToUnicodeEscapeSequenceCache.set(cacheKey, result); diff --git a/test/functional-tests/javascript-obfuscator/JavaScriptObfuscator.spec.ts b/test/functional-tests/javascript-obfuscator/JavaScriptObfuscator.spec.ts index 850428bd..4937ea2b 100644 --- a/test/functional-tests/javascript-obfuscator/JavaScriptObfuscator.spec.ts +++ b/test/functional-tests/javascript-obfuscator/JavaScriptObfuscator.spec.ts @@ -254,7 +254,7 @@ describe('JavaScriptObfuscator', () => { }); describe('cyrillic literal variable value', () => { - const stringArrayCyrillicRegExp: RegExp = /^var _0x(\w){4} *= *\['(\\u\d+)+'\];/; + const stringArrayCyrillicRegExp: RegExp = /^var _0x(\w){4} *= *\['абц'\];/; const stringArrayCallRegExp: RegExp = /var *test *= *_0x(\w){4}\('0x0'\);$/; let obfuscatedCode: string; diff --git a/test/functional-tests/node-transformers/control-flow-transformers/block-statement-control-flow-transformer/BlockStatementControlFlowTransformer.spec.ts b/test/functional-tests/node-transformers/control-flow-transformers/block-statement-control-flow-transformer/BlockStatementControlFlowTransformer.spec.ts index f811d4ae..e53d6d08 100644 --- a/test/functional-tests/node-transformers/control-flow-transformers/block-statement-control-flow-transformer/BlockStatementControlFlowTransformer.spec.ts +++ b/test/functional-tests/node-transformers/control-flow-transformers/block-statement-control-flow-transformer/BlockStatementControlFlowTransformer.spec.ts @@ -87,7 +87,7 @@ describe('BlockStatementControlFlowTransformer', function () { }); describe('switch-case map', () => { - const switchCaseMapVariableRegExp: RegExp = /var *_0x(?:[a-f0-9]){4,6} *= *_0x(?:[a-f0-9]){4,6}\['.*'\]\['split'\]\('\\x7c'\)/; + const switchCaseMapVariableRegExp: RegExp = /var *_0x(?:[a-f0-9]){4,6} *= *_0x(?:[a-f0-9]){4,6}\['.*'\]\['split'\]\('\|'\)/; const switchCaseMapStringRegExp: RegExp = /var *_0x(?:[a-f0-9]){4,6} *= *\{'.*' *: *'(.*)'\};/; const expectedSwitchCasesSequence: string[] = ['0', '1', '2', '3', '4']; @@ -96,7 +96,7 @@ describe('BlockStatementControlFlowTransformer', function () { before(() => { const switchCaseMapMatch: string = getRegExpMatch(obfuscatedCode, switchCaseMapStringRegExp); - switchCaseMap = switchCaseMapMatch.replace(/\\x7c/g, '|').split('|').sort(); + switchCaseMap = switchCaseMapMatch.split('|').sort(); }); it('should create switch-case map variable', () => { @@ -176,7 +176,7 @@ describe('BlockStatementControlFlowTransformer', function () { }); describe('switch-case map', () => { - const switchCaseMapVariableRegExp: RegExp = /var *_0x(?:[a-f0-9]){4,6} *= *_0x(?:[a-f0-9]){4,6}\['.*'\]\['split'\]\('\\x7c'\)/; + const switchCaseMapVariableRegExp: RegExp = /var *_0x(?:[a-f0-9]){4,6} *= *_0x(?:[a-f0-9]){4,6}\['.*'\]\['split'\]\('\|'\)/; const switchCaseMapStringRegExp: RegExp = /var *_0x(?:[a-f0-9]){4,6} *= *\{'.*' *: *'(.*)'\};/; const expectedSwitchCasesSequence: string[] = ['0', '1', '2', '3', '4']; @@ -185,7 +185,7 @@ describe('BlockStatementControlFlowTransformer', function () { before(() => { const switchCaseMapMatch: string = getRegExpMatch(obfuscatedCode, switchCaseMapStringRegExp); - switchCaseMap = switchCaseMapMatch.replace(/\\x7c/g, '|').split('|').sort(); + switchCaseMap = switchCaseMapMatch.split('|').sort(); }); it('should create switch-case map variable', () => { diff --git a/test/functional-tests/node-transformers/obfuscating-transformers/literal-transformer/LiteralTransformer.spec.ts b/test/functional-tests/node-transformers/obfuscating-transformers/literal-transformer/LiteralTransformer.spec.ts index bb5d6035..1ae7173c 100644 --- a/test/functional-tests/node-transformers/obfuscating-transformers/literal-transformer/LiteralTransformer.spec.ts +++ b/test/functional-tests/node-transformers/obfuscating-transformers/literal-transformer/LiteralTransformer.spec.ts @@ -190,7 +190,7 @@ describe('LiteralTransformer', () => { }); describe('variant #8: base64 encoding', () => { - const stringArrayRegExp: RegExp = /^var *_0x([a-f0-9]){4} *= *\['dGVzdA\\x3d\\x3d'\];/; + const stringArrayRegExp: RegExp = /^var *_0x([a-f0-9]){4} *= *\['dGVzdA=='\];/; const stringArrayCallRegExp: RegExp = /var *test *= *_0x([a-f0-9]){4}\('0x0'\);/; let obfuscatedCode: string; @@ -220,7 +220,7 @@ describe('LiteralTransformer', () => { }); describe('variant #9: rc4 encoding', () => { - const regExp: RegExp = /var *test *= *_0x([a-f0-9]){4}\('0x0', *'(?:\w|(?:\\x[a-f0-9]*)){4}'\);/; + const regExp: RegExp = /var *test *= *_0x([a-f0-9]){4}\('0x0', *'.{4}'\);/; let obfuscatedCode: string; diff --git a/test/unit-tests/utils/utils/Utils.spec.ts b/test/unit-tests/utils/utils/Utils.spec.ts index dd120d77..78482957 100644 --- a/test/unit-tests/utils/utils/Utils.spec.ts +++ b/test/unit-tests/utils/utils/Utils.spec.ts @@ -345,7 +345,7 @@ describe('Utils', () => { let actualString: string; before(() => { - actualString = Utils.stringToUnicodeEscapeSequence(string); + actualString = Utils.stringToUnicodeEscapeSequence(string, true); }); it('should return a unicode escape sequence based on a given string', () => { @@ -353,17 +353,17 @@ describe('Utils', () => { }); }); - describe('variant #2: escape non-digits and non-latin letters', () => { - const string: string = 'abc!де'; - const expectedString: string = 'abc\\x21\\u0434\\u0435'; + describe('variant #2: escape `escape sequences`', () => { + const string: string = 'abc\'\\r\\n'; + const expectedString: string = 'abc\\x27\\x5cr\\x5cn'; let actualString: string; before(() => { - actualString = Utils.stringToUnicodeEscapeSequence(string, true); + actualString = Utils.stringToUnicodeEscapeSequence(string, false); }); - it('should return a string where only non-digits and non-latin letters are escaped', () => { + it('should return a string where all `escape sequences` are escaped', () => { assert.equal(actualString, expectedString); }); }); diff --git a/yarn.lock b/yarn.lock index 4ad4149c..49e6581e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -45,13 +45,13 @@ resolved "https://registry.yarnpkg.com/@types/mocha/-/mocha-2.2.41.tgz#e27cf0817153eb9f2713b2d3f6c68f1e1c3ca608" "@types/node@*": - version "7.0.29" - resolved "https://registry.yarnpkg.com/@types/node/-/node-7.0.29.tgz#ccfcec5b7135c7caf6c4ffb8c7f33102340d99df" - -"@types/node@7.0.31": version "7.0.31" resolved "https://registry.yarnpkg.com/@types/node/-/node-7.0.31.tgz#80ea4d175599b2a00149c29a10a4eb2dff592e86" +"@types/node@8.0.0": + version "8.0.0" + resolved "https://registry.yarnpkg.com/@types/node/-/node-8.0.0.tgz#acaa89247afddc7967e9902fd11761dadea1a555" + "@types/sinon@2.3.1": version "2.3.1" resolved "https://registry.yarnpkg.com/@types/sinon/-/sinon-2.3.1.tgz#5e214093e9e2345219ab0f31bf310c9790ad0712" @@ -78,17 +78,25 @@ acorn@^5.0.0: version "5.0.3" resolved "https://registry.yarnpkg.com/acorn/-/acorn-5.0.3.tgz#c460df08491463f028ccb82eab3730bf01087b3d" -ajv-keywords@^1.1.1: - version "1.5.1" - resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-1.5.1.tgz#314dd0a4b3368fad3dfcdc54ede6171b886daf3c" +ajv-keywords@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-2.1.0.tgz#a296e17f7bfae7c1ce4f7e0de53d29cb32162df0" -ajv@^4.7.0, ajv@^4.9.1: +ajv@^4.9.1: version "4.11.8" resolved "https://registry.yarnpkg.com/ajv/-/ajv-4.11.8.tgz#82ffb02b29e662ae53bdc20af15947706739c536" dependencies: co "^4.6.0" json-stable-stringify "^1.0.1" +ajv@^5.1.5: + version "5.1.6" + resolved "https://registry.yarnpkg.com/ajv/-/ajv-5.1.6.tgz#4b2f1a19dece93d57ac216037e3e9791c7dd1564" + dependencies: + co "^4.6.0" + json-schema-traverse "^0.3.0" + json-stable-stringify "^1.0.1" + align-text@^0.1.1, align-text@^0.1.3: version "0.1.4" resolved "https://registry.yarnpkg.com/align-text/-/align-text-0.1.4.tgz#0cd90a561093f35d0a99256c22b7069433fad117" @@ -848,9 +856,9 @@ chalk@1.1.3, chalk@^1.0.0, chalk@^1.1.0, chalk@^1.1.1: strip-ansi "^3.0.0" supports-color "^2.0.0" -chance@1.0.9: - version "1.0.9" - resolved "https://registry.yarnpkg.com/chance/-/chance-1.0.9.tgz#85ae52c145c433d69f6f1eff24f056012b77a60f" +chance@1.0.10: + version "1.0.10" + resolved "https://registry.yarnpkg.com/chance/-/chance-1.0.10.tgz#03500b04ad94e778dd2891b09ec73a6ad87b1996" check-error@^1.0.1: version "1.0.2" @@ -877,9 +885,9 @@ cipher-base@^1.0.0, cipher-base@^1.0.1, cipher-base@^1.0.3: dependencies: inherits "^2.0.1" -class-validator@0.7.0: - version "0.7.0" - resolved "https://registry.yarnpkg.com/class-validator/-/class-validator-0.7.0.tgz#a45b96aaa2154d06efda1cac1061b0adf69ea55e" +class-validator@0.7.1: + version "0.7.1" + resolved "https://registry.yarnpkg.com/class-validator/-/class-validator-0.7.1.tgz#86d60d30d49783113a9d5e606fecbe7aceaf50b5" dependencies: validator "^7.0.0" @@ -1041,6 +1049,12 @@ crypto-browserify@^3.11.0: public-encrypt "^4.0.0" randombytes "^2.0.0" +d@1: + version "1.0.0" + resolved "https://registry.yarnpkg.com/d/-/d-1.0.0.tgz#754bb5bfe55451da69a58b94d45f4c5b0462d58f" + dependencies: + es5-ext "^0.10.9" + dashdash@^1.12.0: version "1.14.1" resolved "https://registry.yarnpkg.com/dashdash/-/dashdash-1.14.1.tgz#853cfa0f7cbe2fed5de20326b8dd581035f6e2f0" @@ -1173,6 +1187,58 @@ error-ex@^1.2.0: dependencies: is-arrayish "^0.2.1" +es5-ext@^0.10.14, es5-ext@^0.10.9, es5-ext@~0.10.14: + version "0.10.23" + resolved "https://registry.yarnpkg.com/es5-ext/-/es5-ext-0.10.23.tgz#7578b51be974207a5487821b56538c224e4e7b38" + dependencies: + es6-iterator "2" + es6-symbol "~3.1" + +es6-iterator@2, es6-iterator@^2.0.1, es6-iterator@~2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/es6-iterator/-/es6-iterator-2.0.1.tgz#8e319c9f0453bf575d374940a655920e59ca5512" + dependencies: + d "1" + es5-ext "^0.10.14" + es6-symbol "^3.1" + +es6-map@^0.1.3: + version "0.1.5" + resolved "https://registry.yarnpkg.com/es6-map/-/es6-map-0.1.5.tgz#9136e0503dcc06a301690f0bb14ff4e364e949f0" + dependencies: + d "1" + es5-ext "~0.10.14" + es6-iterator "~2.0.1" + es6-set "~0.1.5" + es6-symbol "~3.1.1" + event-emitter "~0.3.5" + +es6-set@~0.1.5: + version "0.1.5" + resolved "https://registry.yarnpkg.com/es6-set/-/es6-set-0.1.5.tgz#d2b3ec5d4d800ced818db538d28974db0a73ccb1" + dependencies: + d "1" + es5-ext "~0.10.14" + es6-iterator "~2.0.1" + es6-symbol "3.1.1" + event-emitter "~0.3.5" + +es6-symbol@3.1.1, es6-symbol@^3.1, es6-symbol@^3.1.1, es6-symbol@~3.1, es6-symbol@~3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/es6-symbol/-/es6-symbol-3.1.1.tgz#bf00ef4fdab6ba1b46ecb7b629b4c7ed5715cc77" + dependencies: + d "1" + es5-ext "~0.10.14" + +es6-weak-map@^2.0.1: + version "2.0.2" + resolved "https://registry.yarnpkg.com/es6-weak-map/-/es6-weak-map-2.0.2.tgz#5e3ab32251ffd1538a1f8e5ffa1357772f92d96f" + dependencies: + d "1" + es5-ext "^0.10.14" + es6-iterator "^2.0.1" + es6-symbol "^3.1.1" + escape-string-regexp@1.0.5, escape-string-regexp@^1.0.2, escape-string-regexp@^1.0.5: version "1.0.5" resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" @@ -1198,6 +1264,15 @@ escodegen@~1.3.2: optionalDependencies: source-map "~0.1.33" +escope@^3.6.0: + version "3.6.0" + resolved "https://registry.yarnpkg.com/escope/-/escope-3.6.0.tgz#e01975e812781a163a6dadfdd80398dc64c889c3" + dependencies: + es6-map "^0.1.3" + es6-weak-map "^2.0.1" + esrecurse "^4.1.0" + estraverse "^4.1.1" + escope@~1.0.1: version "1.0.3" resolved "https://registry.yarnpkg.com/escope/-/escope-1.0.3.tgz#759dce8496c4248fec2d0caaf4108bcf3f1a7f5d" @@ -1233,6 +1308,13 @@ esprima@~1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/esprima/-/esprima-1.1.1.tgz#5b6f1547f4d102e670e140c509be6771d6aeb549" +esrecurse@^4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/esrecurse/-/esrecurse-4.1.0.tgz#4713b6536adf7f2ac4f327d559e7756bff648220" + dependencies: + estraverse "~4.1.0" + object-assign "^4.0.1" + esshorten@~1.1.0: version "1.1.1" resolved "https://registry.yarnpkg.com/esshorten/-/esshorten-1.1.1.tgz#174f96b7cc267e46872d814e7db7c290bdff61a9" @@ -1241,7 +1323,7 @@ esshorten@~1.1.0: estraverse "~4.1.1" esutils "~2.0.2" -estraverse@4.2.0: +estraverse@4.2.0, estraverse@^4.1.1: version "4.2.0" resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-4.2.0.tgz#0dee3fed31fcd469618ce7342099fc1afa0bdb13" @@ -1257,7 +1339,7 @@ estraverse@~1.5.0: version "1.5.1" resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-1.5.1.tgz#867a3e8e58a9f84618afb6c2ddbcd916b7cbaf71" -estraverse@~4.1.1: +estraverse@~4.1.0, estraverse@~4.1.1: version "4.1.1" resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-4.1.1.tgz#f6caca728933a850ef90661d0e17982ba47111a2" @@ -1269,6 +1351,13 @@ esutils@^2.0.2, esutils@~2.0.2: version "1.0.0" resolved "https://registry.yarnpkg.com/esutils/-/esutils-1.0.0.tgz#8151d358e20c8acc7fb745e7472c0025fe496570" +event-emitter@~0.3.5: + version "0.3.5" + resolved "https://registry.yarnpkg.com/event-emitter/-/event-emitter-0.3.5.tgz#df8c69eef1647923c7157b9ce83840610b02cc39" + dependencies: + d "1" + es5-ext "~0.10.14" + events@^1.0.0: version "1.1.1" resolved "https://registry.yarnpkg.com/events/-/events-1.1.1.tgz#9ebdb7635ad099c70dcc4c2a1f5004288e8bd924" @@ -1923,6 +2012,10 @@ json-loader@^0.5.4: version "0.5.4" resolved "https://registry.yarnpkg.com/json-loader/-/json-loader-0.5.4.tgz#8baa1365a632f58a3c46d20175fc6002c96e37de" +json-schema-traverse@^0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-0.3.0.tgz#0016c0b1ca1efe46d44d37541bcdfc19dcfae0db" + json-schema@0.2.3: version "0.2.3" resolved "https://registry.yarnpkg.com/json-schema/-/json-schema-0.2.3.tgz#b480c892e59a2f05954ce727bd3f2a4e882f9e13" @@ -2010,15 +2103,6 @@ loader-runner@^2.3.0: version "2.3.0" resolved "https://registry.yarnpkg.com/loader-runner/-/loader-runner-2.3.0.tgz#f482aea82d543e07921700d5a46ef26fdac6b8a2" -loader-utils@^0.2.16: - version "0.2.17" - resolved "https://registry.yarnpkg.com/loader-utils/-/loader-utils-0.2.17.tgz#f86e6374d43205a6e6c60e9196f17c0299bfb348" - dependencies: - big.js "^3.1.3" - emojis-list "^2.0.0" - json5 "^0.5.0" - object-assign "^4.0.1" - loader-utils@^1.0.2, loader-utils@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/loader-utils/-/loader-utils-1.1.0.tgz#c98aef488bcceda2ffb5e2de646d6a754429f5cd" @@ -2875,9 +2959,9 @@ sntp@1.x.x: dependencies: hoek "2.x.x" -source-list-map@^1.1.1: - version "1.1.2" - resolved "https://registry.yarnpkg.com/source-list-map/-/source-list-map-1.1.2.tgz#9889019d1024cce55cdc069498337ef6186a11a1" +source-list-map@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/source-list-map/-/source-list-map-2.0.0.tgz#aaa47403f7b245a92fbc97ea08f250d6087ed085" source-map-support@0.4.15, source-map-support@^0.4.0, source-map-support@^0.4.15, source-map-support@^0.4.2: version "0.4.15" @@ -3181,11 +3265,11 @@ typedarray@^0.0.6: version "0.0.6" resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" -typescript@2.3.4: - version "2.3.4" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.3.4.tgz#3d38321828231e434f287514959c37a82b629f42" +typescript@2.4.0: + version "2.4.0" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.4.0.tgz#aef5a8d404beba36ad339abf079ddddfffba86dd" -uglify-js@^2.6, uglify-js@^2.8.27: +uglify-js@^2.6: version "2.8.27" resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-2.8.27.tgz#47787f912b0f242e5b984343be8e35e95f694c9c" dependencies: @@ -3198,6 +3282,13 @@ uglify-to-browserify@~1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/uglify-to-browserify/-/uglify-to-browserify-1.0.2.tgz#6e0924d6bda6b5afe349e39a6d632850a0f882b7" +uglifyjs-webpack-plugin@^0.4.4: + version "0.4.4" + resolved "https://registry.yarnpkg.com/uglifyjs-webpack-plugin/-/uglifyjs-webpack-plugin-0.4.4.tgz#7829c50ee5a5b755969d4458357ed5a2dd36fbbd" + dependencies: + source-map "^0.5.6" + webpack-sources "^1.0.1" + uid-number@^0.0.6: version "0.0.6" resolved "https://registry.yarnpkg.com/uid-number/-/uid-number-0.0.6.tgz#0ea10e8035e8eb5b8e4449f06da1c730663baa81" @@ -3268,37 +3359,38 @@ webpack-node-externals@1.6.0: version "1.6.0" resolved "https://registry.yarnpkg.com/webpack-node-externals/-/webpack-node-externals-1.6.0.tgz#232c62ec6092b100635a3d29d83c1747128df9bd" -webpack-sources@^0.2.3: - version "0.2.3" - resolved "https://registry.yarnpkg.com/webpack-sources/-/webpack-sources-0.2.3.tgz#17c62bfaf13c707f9d02c479e0dcdde8380697fb" +webpack-sources@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/webpack-sources/-/webpack-sources-1.0.1.tgz#c7356436a4d13123be2e2426a05d1dad9cbe65cf" dependencies: - source-list-map "^1.1.1" + source-list-map "^2.0.0" source-map "~0.5.3" -webpack@2.6.1: - version "2.6.1" - resolved "https://registry.yarnpkg.com/webpack/-/webpack-2.6.1.tgz#2e0457f0abb1ac5df3ab106c69c672f236785f07" +webpack@3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/webpack/-/webpack-3.0.0.tgz#ee9bcebf21247f7153cb410168cab45e3a59d4d7" dependencies: acorn "^5.0.0" acorn-dynamic-import "^2.0.0" - ajv "^4.7.0" - ajv-keywords "^1.1.1" + ajv "^5.1.5" + ajv-keywords "^2.0.0" async "^2.1.2" enhanced-resolve "^3.0.0" + escope "^3.6.0" interpret "^1.0.0" json-loader "^0.5.4" json5 "^0.5.1" loader-runner "^2.3.0" - loader-utils "^0.2.16" + loader-utils "^1.1.0" memory-fs "~0.4.1" mkdirp "~0.5.0" node-libs-browser "^2.0.0" source-map "^0.5.3" supports-color "^3.1.0" tapable "~0.2.5" - uglify-js "^2.8.27" + uglifyjs-webpack-plugin "^0.4.4" watchpack "^1.3.1" - webpack-sources "^0.2.3" + webpack-sources "^1.0.1" yargs "^6.0.0" which-module@^1.0.0: