28

I have this code in JavaScript:

[(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+
(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+
(!![]+[])[+!+[]]]

In the console, it will return

Array [ "filter" ]

And how can I decode a lot of text that’s similar to the text above? E.g.:

[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+
(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]][([][(![]+[])[+[]]+
([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+
(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+
(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+
(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+
([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+
(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+
(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+
(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+
([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+
(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]]

I want to see the plain script.

j08691
  • 204,283
  • 31
  • 260
  • 272
Szymon Marczak
  • 1,055
  • 1
  • 16
  • 31
  • 4
    [Here you go.](http://www.jsfuck.com/) – Mike Cluck Aug 06 '15 at 17:32
  • 1
    This should not have been downvoted. Pretty interesting stuff. – Madness Aug 06 '15 at 17:33
  • @MikeC what do you think a more constructive title would be? I think this Q&A could be quite helpful. What are people likely to google for this? "Decoding Atomic JavaScript", other thoughts? – Madness Aug 06 '15 at 17:48
  • @Madness It’s still the same title, I just removed the tag from the title. – Sebastian Simon Aug 06 '15 at 17:49
  • @Madness I don't think this question is suitable for Stack Overflow. As was mentioned elsewhere, JSFuck requires understanding type coercion, native types strings, and more in JS. That's a pretty broad field of knowledge. – Mike Cluck Aug 06 '15 at 17:54
  • 2
    @Madness Maybe something with “obfuscated JavaScript”, “block-like JS code”, “unreadable JS”, the fact that the code only consists of six symbols… – Sebastian Simon Aug 06 '15 at 17:55
  • This question may be a duplicate of http://codegolf.stackexchange.com/questions/28714/convert-jsfuck-to-normal-js – Foo Bar Feb 03 '16 at 17:33

3 Answers3

14

I have seen many decoding attempts around, but none that work reliably. The easiest way I have found to decode Non Alphanumeric Javascript is with Chrome.

Open Chrome > Go to jsfuck.com > paste the code you would like to decode in the window > hit Run This.

Then open the Console, in the case of your specific code from PasteBin there will be an error:

Uncaught TypeError: Cannot read property 'innerHTML' of null  

To the right of the error, click the line number link, and the code will be revealed. The result is:

(function(){
    window.false=document.getElementById('sc').innerHTML;
})

Which explains why you get the error trying to just decode it using JSFuck itself. There is no element with the id sc on their site.

Madness
  • 2,730
  • 3
  • 20
  • 29
  • You can paste it in that box on their website, you will likely need to uncheck `Eval Source`. – Madness Aug 06 '15 at 17:45
  • 1
    You can also decode it by hand once you understand how JS type coercion works. – Sebastian Simon Aug 06 '15 at 17:48
  • 9
    I can also do long division by hand. – Madness Aug 06 '15 at 17:49
  • @Madness I want to see native code too... If I decode "a" with checked Excutable code and decode it with unchecked Excutable code I get: `(![]+[+!![]]+![]+![].........` – Szymon Marczak Aug 06 '15 at 19:34
  • I want to decode this script: http://pastebin.com/HZrmFcUQ (note: last char is **;** ) Can I get plain script? I don't want to decode it by hand... – Szymon Marczak Aug 06 '15 at 19:46
  • I put the output you were looking for above. Its a couple steps, I wouldn't call it by hand. – Madness Aug 07 '15 at 06:54
  • You were already trying to decode with JSFuck, now all you need to do after you run it there is to check the console's error, that is where the raw code output is. (And in Chrome) – Madness Aug 07 '15 at 07:03
  • Why don't you run the script (in an isolated env) and then, reimplment it? Use Chrome's dev tools to see what the code is doing. – Fighter178 May 18 '23 at 08:35
6

You can use this website to decode jsfuck: http://codertab.com/jsunfuck

UPDATED I extracted the decode javascript from the URL above, this is how the decode process work: (javascript)

s = source.slice(0, source.length - 2); txtResult = eval(s);

Hope it help!

Tubekeeper
  • 61
  • 1
  • 1
  • Hello @Tubekeeper, Welcome to SO, please provide and explanation to your answer, in that way it will be more likely to get up-voted. – Alejandro Montilla Sep 29 '17 at 20:20
  • It doesn't really decode it then, it interprets it using eval x'] But i probably misunderstood the question since i was thinking it would transpile it back to code – Lorenzo Aug 23 '22 at 19:51
2
    let elem = yourJSFuck
function decode(elem) {
    return (/\n(.+)/.exec(eval(elem.replace(/\s+/, "").slice(0, -2)))[1]);
}

console.log(decode(elem))

This should work, the source is from this page