pax_global_header00006660000000000000000000000064121603742600014513gustar00rootroot0000000000000052 comment=d26065a4238256d8b087d7d5625d6c74da1ffd2c node-active-x-obfuscator-0.0.2/000077500000000000000000000000001216037426000163225ustar00rootroot00000000000000node-active-x-obfuscator-0.0.2/.gitignore000066400000000000000000000000231216037426000203050ustar00rootroot00000000000000*.un~ /node_modulesnode-active-x-obfuscator-0.0.2/.travis.yml000066400000000000000000000000521216037426000204300ustar00rootroot00000000000000language: node_js node_js: - 0.6 - 0.8node-active-x-obfuscator-0.0.2/LICENSE000066400000000000000000000021361216037426000173310ustar00rootroot00000000000000Copyright (c) 2012 Felix Geisendörfer (felix@debuggable.com) and contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. node-active-x-obfuscator-0.0.2/Readme.md000066400000000000000000000015661216037426000200510ustar00rootroot00000000000000[![build status](https://secure.travis-ci.org/felixge/node-active-x-obfuscator.png)](http://travis-ci.org/felixge/node-active-x-obfuscator) # active-x-obfuscator A module to (safely) obfuscate all occurrences of the string 'ActiveX' inside any JavaScript code. ## Why? Some corporate firewalls /proxies such as Blue Coat block JavaScript files to be downloaded if they contain the word `'ActiveX'`. That of course is very annoying for libraries such as [socket.io][] that need to use `ActiveXObject` for supporting IE8 and older. ## Install ``` npm install active-x-obfuscator ``` ## Usage ```js var activeXObfuscator = require('active-x-obfuscator'); var code = 'foo(new ActiveXObject());'; var obfuscated = activeXObfuscator(code); // -> foo(new window[(['Active'].concat('Object').join('X'))]) ``` ## License Licensed under the MIT license. [socket.io]: http://socket.io/ node-active-x-obfuscator-0.0.2/index.js000066400000000000000000000042331216037426000177710ustar00rootroot00000000000000var 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; }, ''); }; node-active-x-obfuscator-0.0.2/package.json000066400000000000000000000012061216037426000206070ustar00rootroot00000000000000{ "author": "Felix Geisendörfer (http://debuggable.com/)", "name": "active-x-obfuscator", "description": "A module to (safely) obfuscate all occurrences of the string 'ActiveX' inside any JavaScript code.", "version": "0.0.2", "homepage": "https://github.com/felixge/node-active-x-obfuscator", "repository": { "type": "git", "url": "git://github.com/felixge/node-active-x-obfuscator.git" }, "main": "./index", "scripts": { "test": "node test.js" }, "engines": { "node": "*" }, "dependencies": { "zeparser": "0.0.7" }, "devDependencies": {}, "optionalDependencies": {} } node-active-x-obfuscator-0.0.2/test.js000066400000000000000000000027411216037426000176430ustar00rootroot00000000000000var activeXObfuscator = require('./index'); var assert = require('assert'); var OBFUSCATED_ACTIVE_X_OBJECT = activeXObfuscator.OBFUSCATED_ACTIVE_X_OBJECT; var OBFUSCATED_ACTIVE_X = activeXObfuscator.OBFUSCATED_ACTIVE_X; var input = "foo(new ActiveXObject('Microsoft.XMLHTTP'))"; var expected = "foo(new window[" + OBFUSCATED_ACTIVE_X_OBJECT + "]('Microsoft.XMLHTTP'))"; assert.equal(activeXObfuscator(input), expected); var input = "var foo = 'ActiveXObject';"; var expected = "var foo = " + OBFUSCATED_ACTIVE_X_OBJECT + ";"; assert.equal(activeXObfuscator(input), expected); var input = 'var foo = "ActiveXObject";'; var expected = "var foo = " + OBFUSCATED_ACTIVE_X_OBJECT + ";"; assert.equal(activeXObfuscator(input), expected); var input = 'var foo = o.ActiveXObject;'; var expected = "var foo = o[" + OBFUSCATED_ACTIVE_X_OBJECT + "];"; assert.equal(activeXObfuscator(input), expected); var input = 'var foo = "ActiveX";'; var expected = "var foo = " + OBFUSCATED_ACTIVE_X + ";"; assert.equal(activeXObfuscator(input), expected); var input = "var foo = 'ActiveX';"; var expected = "var foo = " + OBFUSCATED_ACTIVE_X + ";"; assert.equal(activeXObfuscator(input), expected); var input = "var foo; // ActiveX is cool"; var expected = "var foo; // Ac...eX is cool"; assert.equal(activeXObfuscator(input), expected); var input = "var foo = 'ActiveX is cool';"; assert.throws(function() { activeXObfuscator(input); }, /Unknown ActiveX occurence/);