Tell me more ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

I’m having some problems debugging an encoded javacscript. This script I’m referring to given in this link over here.

The encoding here is simple and it works by shifting the unicodes values to whatever Codekey was use during encoding. The code that does the decoding is given here in plain English below:-

<script language="javascript">
    function dF(s) {
        var s1 = unescape(s.substr(0, s.length - 1));
        var t = '';
        for (i = 0; i < s1.length; i++) t += String.fromCharCode(s1.charCodeAt(i) - s.substr(s.length - 1, 1));
        document.write(unescape(t));
    }
</script>

I’m interested in knowing or understanding the values (e.g s1,t). Like for example when the value of i=0 what values would the following attributes / method would hold

s1.charCodeAt(i) and s.substr(s.length-1,1)

The reason I’m doing this is to understand as to how a CodeKey function really works. I don’t see anything in the code above which tells it to decode on the basis of codekey value. The only thing I can point in the encoding text is the last character which is set to 1 , 2 ,3 or 4 depending upon the codekey selected during encoding process. One can verify using the link I have given above.

However, to debug, I’m using firebug addon with the script running as localhost on my wamp server. I’m able to put a breakpoint on the js using firebug but I’m unable to retrieve any of the user defined parameters or functions I mentioned above.

I want to know under this context what would be best way to debug this encoded js.

share|improve this question
I have been able to decode some of it using a js debugger addon for firefox. Here is the s9.postimage.org/iajkdl9fy/scan.jpg screenshot. What I'm unable to understand is how the script get the codekey. If codekey is 2 then unicode is shifted twice how does the code know this. I got no idea how does these characters (&1B&1:&1:&1) also shown in the screenshot appears the encoding was suppose to close at 4F (>). When the codekey is shift to 2 these characters are changed to &2...but how does the script use this information? I don't know – linkme69 Oct 26 '12 at 14:25

closed as off topic by Anagio, LazyOne, John Conde Oct 27 '12 at 1:20

Questions on Webmasters Stack Exchange are expected to relate to webmastering within the scope defined in the FAQ. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about closed questions here.

Browse other questions tagged or ask your own question.