12
6
Many of you already know JSF**k. For those who don't, it's a script that basically turns any JavaScript code into something written using only []()!+.
Your task is to build, using any language of your choice, a program which converts JSF**k into unobfuscated JavaScript.
- Input: A string with valid JSF**k code.
- Output: A string with the regular JavaScript code that has been previously JSF**ked to generate the input.
For this challenge, consider that the input string has only been JSF**ked once.
This is a code-golf contest, so the shortest code, in bytes, wins.
For those who are wondering, censoring the title is partially in compliance with the generally accepted answer here.
– HyperNeutrino – 2017-07-06T00:12:40.913@Michael but is the encoding unambiguously revertible? I don't think so... how do I decide if a some
[...]array access was part of the original code or part of the obfuscation? same for all other constructs, really. – Martin Ender – 2014-05-28T19:10:04.047@m.buettner, I don't know, maybe it's not possible. I was looking at the JSFuck encoder (http://www.jsfuck.com/jsfuck.js) and maybe it's doable. Anyway, the good term for the question is not interpreter but decoder.
– Michael M. – 2014-05-28T19:11:30.820@m.buettner essentially, this boils down to a database of certain strings and constant expression evaluation. We should be given some definite specs as to what simplifications exactly are needed. Voting to close for now. – John Dvorak – 2014-05-28T19:11:45.980
Okay, it's full of loopholes. I'm a newbie at this and I really thought carefully before posting, but my lack of experience made the question confusing. Could you guys help me making it better by editing it? I appreciate the comments as well – William Barbosa – 2014-05-28T19:13:35.543
@WilliamBarbosa post it in the sandbox first. That's the place for the community to help you polish the challenge before it goes live.
– Martin Ender – 2014-05-28T19:14:46.363Only you can patch the loopholes. Specify exactly what parts of compilation need to be undone. – John Dvorak – 2014-05-28T19:14:56.863
@m.buettner unfortunately, posting to meta requires 15 reputation and the sandbox hasn't been moved to main yet (nor is going to be) – John Dvorak – 2014-05-28T19:15:57.920
2@JanDvorak oh what... that's so counter-productive... we could help him out with closing this question and upvoting instead of downvoting. – Martin Ender – 2014-05-28T19:16:29.910
In fact, it's only 5 rep on meta. Here is your upvote, go ahead and post in the sandbox please! :) – Martin Ender – 2014-05-28T19:17:21.350
2@m.buettner I've downvoted because I don't feel the question is going anywhere. I definitely don't want to upvote a post just to unlock some privileges for someone. – John Dvorak – 2014-05-28T19:17:31.257
2@JanDvorak I think we shouldn't discourage new users who want to write good challenges and listen to criticism. Since the sandbox is on meta and will stay there, downvoting is counter-productive. Closing is totally sufficient. I don't think a single upvote would harm anyone, and it would give the user the chance to actually find an entry into this community. But someone agreed with you and decided to downvote as well, because heck, why should new users be allowed to post in the sandbox (I guess)... and now he still can't post there. I don't think that's how we grow this community. – Martin Ender – 2014-05-28T19:49:41.620
1Can you please add some explanation what normal JavaScript means? It might not be obvious how the back-transformation has to be done. E.g. if I iterate the obfustator twice on some nice input, what is the suggested output? The original program or the input which was already obfuscated? – Howard – 2014-05-29T11:36:50.643
@Howard I'm not sure that you'd get different output after running the obfuscator a second time (since there would be nothing to obfuscate), so one deobfuscation should make it should go back to an unobfuscated state. Correct me if I'm wrong – None – 2014-05-29T12:03:43.533
@professorfish It is, because
[]is altered by the encoder. But that was only meant as an example where the transformation is not unique. – Howard – 2014-05-29T12:15:06.010