/* * Soya.Encode.ScriptDecoder * Decodes JScript/VBscript data encoded with the * MS ScriptEncoder in true crossbrowser manner. * * This script was influenced by the C version (scrdec1x.c) by Mr.Brownstone, * and is distributed under the terms of the BSD License. * -------------------------------------------------------------------------------- * ! DISCLAIMER ! * -------------------------------------------------------------------------------- * * Reverse engineering and copyright infringement are in many countries a * criminal offense. This script was solely written for demonstrative and * educational purposes only and may NOT in any way or under no * circumstance be used to decode data that you do not hold copyrights * of or have expressed consent by the copyright owner to do so. * The author of this script cannot be held responsible of YOU using or * attempt to use this script in a way violating the laws of YOUR country * in the aspects of reverse engineering and copyright matters. * * -------------------------------------------------------------------------------- * scrdec1x.c is copyright(c) Mr.Brownstone * http://www.virtualconspiracy.com/scrdec.html * * Soya.Encode.ScriptDecoder [ScriptDecoder.js] (this script) * is copyright(c) 2001-2002, Thomas Loo - Saltstorm. * * The MS ScriptEncoder counterpart can be found here: (beware linewraps) * * -------------------------------------------------------------------------------- */ function Soya_Encode_ScriptDecoder() { this.name = 'Soya.Encode.ScriptDecoder'; this.type = 'constructor'; this.version = '1.10'; this.dependencies = []; this.initialize(); } function Soya_Encode_ScriptDecoder_initialize(oClass){ with(oClass){ prototype.decode = $Soya_Encode_ScriptDecoder_decode; prototype.$matrix = []; prototype.$prepareMatrix = $Soya_Encode_ScriptDecoder_$prepareMatrix; prototype.$rotor = [ 1,2,0, 1,2,0, 2,0,0, 2,0,2, 1,0,2, 0,1,0, 2,0,1, 1,2,0, 0,2,1, 0,2,0, 0,2,1, 1,0,2, 0,2,0, 1,0,1, 1,2,0, 1,0,2, 1,0,2, 0,1,1, 2,0,0, 1,1,2, 0,1,0, 2]; prototype.$ccmap = [ 0x7b,0x57,0x6e, 0x32,0x2e,0x2d, 0x30,0x47,0x75, 0x21,0x7a,0x52, 0x29,0x56,0x60, 0x5b,0x42,0x71, 0x38,0x6a,0x5e, 0x33,0x2f,0x49, 0x3d,0x26,0x5c, 0x58,0x49,0x62, 0x3a,0x41,0x7d, 0x35,0x34,0x29, 0x65,0x32,0x36, 0x39,0x5b,0x20, 0x5c,0x76,0x7c, 0x56,0x72,0x7a, 0x73,0x43,0x00, 0x66,0x38,0x6b, 0x4e,0x39,0x63, 0x45,0x70,0x33, 0x6b,0x45,0x2b, 0x62,0x68,0x68, 0x59,0x71,0x51, 0x78,0x4f,0x66, 0x5e,0x09,0x76, 0x7d,0x62,0x31, 0x4a,0x44,0x64, 0x6d,0x23,0x54, 0x71,0x75,0x43, 0x00,0x00,0x00, 0x60,0x7e,0x3a, 0x00,0x00,0x00, 0x53,0x5e,0x7e, 0x00,0x00,0x00, 0x42,0x77,0x45, 0x27,0x4a,0x2c, 0x48,0x61,0x2a, 0x72,0x5d,0x74, 0x75,0x22,0x27, 0x31,0x4b,0x37, 0x37,0x6f,0x44, 0x4d,0x4e,0x79, 0x52,0x3b,0x59, 0x22,0x4c,0x2f, 0x54,0x50,0x6f, 0x6a,0x67,0x26, 0x47,0x2a,0x72, 0x64,0x7d,0x6a, 0x2d,0x74,0x39, 0x20,0x54,0x7b, 0x00,0x2b,0x3f, 0x2e,0x2d,0x38, 0x4c,0x2c,0x77, 0x5d,0x30,0x67, 0x7e,0x6e,0x53, 0x6c,0x6b,0x47, 0x6f,0x66,0x34, 0x79,0x35,0x78, 0x74,0x25,0x5d, 0x43,0x21,0x30, 0x26,0x64,0x23, 0x76,0x4d,0x5a, 0x25,0x52,0x5b, 0x24,0x63,0x6c, 0x2b,0x3f,0x48, 0x28,0x7b,0x55, 0x23,0x78,0x70, 0x41,0x29,0x69, 0x34,0x28,0x2e, 0x09,0x73,0x4c, 0x2a,0x59,0x21, 0x44,0x33,0x24, 0x3f,0x00,0x4e, 0x77,0x6d,0x50, 0x3b,0x55,0x09, 0x55,0x53,0x56, 0x69,0x7c,0x73, 0x61,0x3a,0x35, 0x63,0x5f,0x61, 0x50,0x65,0x4b, 0x67,0x46,0x58, 0x51,0x58,0x3b, 0x49,0x31,0x57, 0x4f,0x69,0x22, 0x46,0x6c,0x6d, 0x68,0x5a,0x4d, 0x7c,0x48,0x25, 0x36,0x27,0x28, 0x70,0x5c,0x46, 0x6e,0x3d,0x4a, 0x7a,0x24,0x32, 0x2f,0x79,0x41, 0x5f,0x37,0x3d, 0x4b,0x60,0x5f, 0x5a,0x51,0x4f, 0x2c,0x20,0x42, 0x57,0x36,0x65]; } } function $Soya_Encode_ScriptDecoder_$prepareMatrix(){ // pre-building the char-matrix will give us a // *slight* performance boost for repeated calls. if(!this.$matrix.length){ var i, j, afccs = function (cca) { return String.fromCharCode (cca[0], 0, cca[1], 0, cca[2]).split('\x00'); }; this.$matrix[9] = afccs(this.$ccmap.slice(0, j = 3)); for(i = 0x20; i < 0x80; j += 3, i++) this.$matrix[i] = afccs(this.$ccmap.slice(j, j + 3)); } } function $Soya_Encode_ScriptDecoder_decode(sData){ var i, offset, cc, at, s, sEncoded, sDecoded = ''; // do we have anything to decode. if not, return an empty string. if(!sData) return sDecoded; // else try isolating the sEncoded script from its surroundings. else if(/#@~\^.{6}==(.+).{6}==\^#~@/.test(sData)) sEncoded = RegExp.$1; // no surrounding checksum found, then subject everything for decoding. else sEncoded = sData; this.$prepareMatrix(); // iterate the sEncoded string and decode it char by char... for(at = offset = i = 0; i < sEncoded.length; i++){ cc = sEncoded.charCodeAt(i); // 'at' switched off and the charcode is less 128 means we have // to perform decoding unless charcode equals 64 (@, at). if(!at && cc < 0x80){ (cc != 0x40) ? sDecoded += this.$matrix[cc][this.$rotor[offset++ % 0x40]] : at = 1; continue; } // if 'at' switch is set... // switch it off and replace char left of '@' if one of the control-chars // Other chars is passed throgh as-is. else { at = 0; if(cc < 0x80) offset++; switch(cc){ case 33 : cc = 60; break; case 35 : cc = 13; break; case 36 : cc = 64; break; case 38 : cc = 10; break; case 42 : cc = 62; break; } sDecoded += String.fromCharCode(cc); } } return sDecoded; } if(typeof(Soya) == 'object') Soya.registerBean('Soya.Encode.ScriptDecoder', false, 1); }