Luc wrote:
[...]
Is it a strange character set ? an obfuscation ? both ?
It's obfuscation. The author is trying to prevent you from reading the
source, which I've included at the end, because it's pretty meaty.
I suppose it *might* be an attempt to compress the script --- the
unobfuscated output is much larger than the input --- but doing that in
Javascript is a total waste of time; you're far better off just using a
gzip transport. You get better compression and you don't need the kind of
crap in the script.
Incidentally, if you're tempted to obfuscate your scripts --- don't. You
can't stop people from reading your scripts. At all. There's no point even
trying. All you'll do is make your code more brittle and prone to bugs.
There is one other reason why people try and obfuscate their scripts; it's a
(mostly futile) attempt to work around browser security. Some web proxies
examine the web pages an attempt to remove scripts they think are
malicious. It's much harder for them, of course, to decipher the above.
Incidentally, I decoded it by cut-and-pasting into the js command-line
Javascript interpreter. It took maybe thirty seconds, most of which were
spent in working out where the line breaks were. I then fed it to indent to
pretty-print it. (I haven't got it quite right; I think I may have missed a
couple of characters in the cut-and-paste. But at least it's readable.)
---script follows---
function navigation(navButton, enabledAlt, disabledAlt)
{
this.linkObj = topNav.document.getElementById(navButton);
this.linkObj.onclick = this.navClick;
this.enabled = true;
this.enabledAlt = enabledAlt;
this.disabledAlt = disabledAlt;
this.linkObj.enabledImage = this.linkObj.firstChild.src;
varstart =
this.linkObj.firstChild.src.substring(0,
this.linkObj.firstChild.
src.indexOf(this.linkObj.
id.
toLowerCase
()));
varend =
this.linkObj.firstChild.src.substring(this.linkObj .firstChild.
src.indexOf(this.linkObj.
id.
toLowerCase
()),
this.linkObj.firstChild.
src.length);
this.linkObj.disabledImage = start + 'grey' + end;
this.enable = enable_m;
this.disable = disable_m;
};
navigation.prototype.navClick = function()
{
eval('root.navAction("' + this.id + '")');
};
functiondisable_m()
{
this.linkObj.onclick = null;
this.linkObj.style.cursor = '';
this.enabled = false;
this.linkObj.firstChild.alt = this.disabledAlt;
this.linkObj.firstChild.title = this.disabledAlt;
this.linkObj.firstChild.src = this.linkObj.disabledImage;
};
functionenable_m()
{
this.linkObj.onclick = this.navClick;
this.linkObj.style.cursor = parent.pointer;
this.enabled = true;
this.linkObj.firstChild.alt = this.enabledAlt;
this.linkObj.firstChild.title = this.enabledAlt;
this.linkObj.firstChild.src = this.linkObj.enabledImage;
};
functionbookmarkConstructor()
{
this.linkObj = topNav.document.getElementById('bookmarkButton');
this.linkObj.createImage = this.linkObj.firstChild.src;
this.linkObj.deleteImage = '../images/bookmarkdelete.gif';
this.linkObj.style.cursor = parent.pointer;
this.linkObj.parentObj = this;
this.enabled = true;
this.linkObj.enabledImage = this.linkObj.firstChild.src;
varstart =
this.linkObj.firstChild.src.substring(0,
this.linkObj.firstChild.
src.indexOf('bookmark'));
varend =
this.linkObj.firstChild.src.substring(this.linkObj .firstChild.
src.indexOf('bookmark'),
this.linkObj.firstChild.
src.length);
this.linkObj.disabledImage = start + 'grey' + end;
this.setDelete = setDelete_m;
this.setCreate = setCreate_m;
this.enable = enable_m;
this.disable = disable_m;
};
functionsetDelete_m()
{
this.linkObj.firstChild.src = this.linkObj.deleteImage;
this.linkObj.onclick = deleteBookmark_m;
this.linkObj.firstChild.alt = buttonDeleteBookmarkAlt;
this.linkObj.firstChild.title = buttonDeleteBookmarkAlt;
};
functionsetCreate_m()
{
this.linkObj.firstChild.src = this.linkObj.createImage;
this.linkObj.onclick = createBookmark_m;
this.linkObj.firstChild.alt = buttonCreateBookmarkAlt;
this.linkObj.firstChild.title = buttonCreateBookmarkAlt;
};
functioncreateBookmark_m()
{
root.bookmarks[root.bookmarks.length] =
root.currentDocument.nodeGlobalID;
root.addBookmark(root.
findNodeGlobalID(root.currentDocument.
nodeGlobalID));
this.parentObj.setDelete();
};
functiondeleteookmark_m()
{
var arrayString = arrayToStr(root.bookmarks, ':');
deleteroot.bookmarks;
root.bookmarks = arrayString.split(':').reverse();
for (var counter = 0; counter < root.bookmarks.length; counter++)
{
if (root.bookmarks[counter] ==
root.currentDocument.nodeGlobalID)
{
root.bookmarks.splice(counter, 1);
break;
}
}
root.deleteBookmark(root.
findNodeGlobalID(root.currentDocument.
nodeGlobalID));
this.parentObj.setCreate();
};
---script ends---
--
+- David Given --McQ-+ "...you could wire up a *dead rat* to a DIMM
|
dg@cowlark.com | socket, and the PC BIOS memory test would pass it
| (dg@tao-group.com) | just fine." --- Ethan Benson
+-
www.cowlark.com --+