r/programming • • Aug 10 '12

Write any javascript code with just these characters: ()[]{}+!

http://patriciopalladino.com/blog/2012/08/09/non-alphanumeric-javascript.html
1.3k Upvotes

288 comments sorted by

View all comments

1

u/tantalor Aug 10 '12

I was impressed until the part where the scripts are just eval'd.

4

u/alcuadrado Aug 10 '12

It's not always necessary, but I don't have that free time to do it the right way

0

u/__j_random_hacker Aug 12 '12

But is it correct that to actually execute the script, you need to include the text eval or Function near the start? That's what I want to know.

It seems to me that using your approach, you can produce any abitrary string, which of course may contain a legal Javascript program and so may produce arbitrary behaviour if it is evaled, but the only code you can directly run this way is a single expression that evaluates to a single data structure (like a boolean, a number, a string, or a possibly multilevel array or hash of such). If that's the case, then there's no security risk here (unless the website being targeted evals user input twice).

→ More replies (2)