From b60df56157ee1fd0bd4938799bac05a62fda91a1 Mon Sep 17 00:00:00 2001 From: lookshe Date: Sat, 14 Mar 2015 20:45:20 +0100 Subject: initial commit from working version --- .../node_modules/active-x-obfuscator/index.js | 83 ++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 signaling-server/node_modules/socket.io/node_modules/socket.io-client/node_modules/active-x-obfuscator/index.js (limited to 'signaling-server/node_modules/socket.io/node_modules/socket.io-client/node_modules/active-x-obfuscator/index.js') diff --git a/signaling-server/node_modules/socket.io/node_modules/socket.io-client/node_modules/active-x-obfuscator/index.js b/signaling-server/node_modules/socket.io/node_modules/socket.io-client/node_modules/active-x-obfuscator/index.js new file mode 100644 index 0000000..57b421b --- /dev/null +++ b/signaling-server/node_modules/socket.io/node_modules/socket.io-client/node_modules/active-x-obfuscator/index.js @@ -0,0 +1,83 @@ +var ZeParser = require('zeparser').ZeParser; +var Util = require('util'); + +module.exports = ActiveXObfuscator; +function ActiveXObfuscator(code) { + if (!(this instanceof ActiveXObfuscator)) { + var obfuscator = new ActiveXObfuscator(code); + obfuscator.execute(); + return obfuscator.toString(); + } + + this._parser = ZeParser.createParser(code); +} + +var OBFUSCATED_ACTIVE_X_OBJECT = ActiveXObfuscator.OBFUSCATED_ACTIVE_X_OBJECT = + "(['Active'].concat('Object').join('X'))"; +var OBFUSCATED_ACTIVE_X = ActiveXObfuscator.OBFUSCATED_ACTIVE_X = + "(['Active'].concat('').join('X'))"; + +ActiveXObfuscator.prototype.execute = function() { + this._parser.tokenizer.fixValues(); + this._obfuscate(this.getAst()); +}; + +ActiveXObfuscator.prototype.getAst = function() { + return this._parser.stack; +}; + +ActiveXObfuscator.prototype.getWhiteTokens = function() { + return this._parser.tokenizer.wtree; +}; + +ActiveXObfuscator.prototype._obfuscate = function(ast) { + var self = this; + + ast.forEach(function(node, index) { + if (Array.isArray(node)) { + self._obfuscate(node); + return; + } + + switch (node.value) { + case 'ActiveXObject': + if (!node.isPropertyName) { + node.value = 'window[' + OBFUSCATED_ACTIVE_X_OBJECT + ']'; + break; + } + + var dot = ast[index - 1] + var whiteTokens = self.getWhiteTokens(); + whiteTokens[dot.tokposw].value = ''; + + node.value = '[' + OBFUSCATED_ACTIVE_X_OBJECT + ']'; + break; + case "'ActiveXObject'": + case '"ActiveXObject"': + node.value = OBFUSCATED_ACTIVE_X_OBJECT; + break; + case "'ActiveX'": + case '"ActiveX"': + node.value = OBFUSCATED_ACTIVE_X; + break; + default: + if (!/ActiveX/i.test(node.value)) { + break; + } + + if (!node.isComment) { + throw new Error('Unknown ActiveX occurence in: ' + Util.inspect(node)); + } + + node.value = node.value.replace(/ActiveX/i, 'Ac...eX'); + } + + }); +}; + +ActiveXObfuscator.prototype.toString = function() { + var whiteTokens = this.getWhiteTokens(); + return whiteTokens.reduce(function(output, node) { + return output += node.value; + }, ''); +}; -- cgit v1.2.3