aboutsummaryrefslogtreecommitdiffstats
path: root/signaling-server/node_modules/socket.io/node_modules/socket.io-client/node_modules/active-x-obfuscator/index.js
diff options
context:
space:
mode:
Diffstat (limited to 'signaling-server/node_modules/socket.io/node_modules/socket.io-client/node_modules/active-x-obfuscator/index.js')
-rw-r--r--signaling-server/node_modules/socket.io/node_modules/socket.io-client/node_modules/active-x-obfuscator/index.js83
1 files changed, 83 insertions, 0 deletions
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;
+ }, '');
+};