Closed mithuns closed 6 years ago
JScrewIt typically tries out a number of different encoding techniques and then picks up whichever happens to produce the shortest output. So the output is deterministic, but not always trivial to deduce. AFAIK, there is no specific decoder.
Is there a way to validate if the script indeed is free of errors ? I am working with a puzzle which presents a giant string of javascript in those 6 characters, decoding it , and obtaining the result will unlock the next step of the challenge. And every time I copy it in the javascript console, it just throws
Uncaught ReferenceError: len is not defined
at eval (eval at <anonymous> (:1:2226), <anonymous>:1:15)
at eval (<anonymous>)
at <anonymous>:1:2226
@mithuns If you mind posting the script I can have a look at it.
@mithuns The first 2225 characters in your script are used to encode eval
(the JS function): remove those many characters, then paste what remains in a browser console to see the original code as a string. You will find an undeclared identifier len
somewhere in the first line which explains the ReferenceError you are getting. If you're wondering how I figured this out, I just encoded the input eval
with JScrewIt using different compatibility settings until I got a match. This will not always work, but it does for most sufficiently long inputs encoded with default settings.
How did you know that the first 2225 chars would be for eval ? Even when I remove that many characters all I can see is
"for(var i=0;i<len;i++){buffer+=
'ROOTSOFLIFE'[i];undefined}"
This is simply how JScrewIt works. Even a=b
is encoded as eval("a=b")
, and eval
is 2225 chars in maximum compatibility mode. Removing that part will leave you with a string that can be easily evaluated without side effects, and that is the original input: exactly what you found.
Running the original code in the console will have the same effect as running the encoded script. In your case, it will throw the same error.
So, is this the entire string ?
"for(var i=0;i<len;i++){buffer+=
'ROOTSOFLIFE'[i];undefined}"
Yes, with a bunch of newlines after +=
.
I am a bit new to this , so forgive me if I sound like I dont understand this, I think the encoding is non-deterministic, for instance, there are multiple encodings that can be produced from a source String, does that make decoding impossible ? Is there a decoder available somewhere ?