Created
June 1, 2011 09:56
-
-
Save msgodf/1002060 to your computer and use it in GitHub Desktop.
Code to run arbitrary JavaScript code as a string, using only the characters []$=()-+~""!_
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[][$___=(($=(({}+"")))[$__=-~-~-~-~-~[]]+$[-~[]]+(""[+[]]+"")[-~[]]+(![]+"")[-~-~-~[]]+(($_=(!""+"")))[+[]]+$_[-~[]]+$_[-~-~[]]+$[$__]+$_[+[]]+$[-~[]]+$_[-~[]])][$___](($$=($_____=(!""+"")[-~[]]+(!""+"")[-~-~-~[]]+(!""+"")[+[]]+(!""+"")[-~-~[]]+(!""+"")[-~[]]+(""[+[]]+"")[-~[]] | |
)+"[][$___][$___]('"+$_____+"\"\\"+(""[+[]]+"")[+[]] | |
+(+[])+(+[]))+($$$=""+(-~-~-~-~[])+(-~[]))+($$$$="\"')()"))()+[][$___][$___]($$+($$$=-~$$$)+$$$$)()+[][$___][$___]($$+($$$=-~$$$)+$$$$)()+[][$___][$___]($$+($$$=-~$$$)+$$$$)() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The code just constructs the string 'constructor' from the primitives '[object Object]', | |
// 'true', 'false', and 'undefined' and then uses it to access the Function constructor of | |
// the built-in Array type | |
[]['constructor']['constructor']("//Insert arbitrary code here")(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[][$___=(($=(({}+"")))[$__=-~-~-~-~-~[]]+$[-~[]]+(""[+[]]+"")[-~[]]+(![]+"")[-~-~-~[]]+(($_=(!""+"")))[+[]]+$_[-~[]]+$_[-~-~[]]+$[$__]+$_[+[]]+$[-~[]]+$_[-~[]])][$___]("// Insert arbitrary code here")() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[][$___=(($=(({}+"")))[$__=-~-~-~-~-~[]]+$[-~[]]+(""[+[]]+"")[-~[]]+(![]+"")[-~-~-~[]]+(($_=(!""+"")))[+[]]+$_[-~[]]+$_[-~-~[]]+$[$__]+$_[+[]]+$[-~[]]+$_[-~[]])][$___]($_____+(___$=[][$___][$___]("_$_$",($_____=(!""+"")[-~[]]+(!""+"")[-~-~-~[]]+(!""+"")[+[]]+(!""+"")[-~-~[]]+(!""+"")[-~[]]+(""[+[]]+"")[-~[]] | |
)+'[][$___][$___]($_____+"\'\\\\'+(''[+[]]+'')[+[]]+'"+_$_$+"\';")();'))(""+(+[])+(+[])+(-~-~[])+(+[]))+___$(""+(+[])+(+[])+(-~-~-~[])+(-~-~-~-~[])))() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(___$=[][$___][$___]("_$_$",($_____=(!""+"")[-~[]]+(!""+"")[-~-~-~[]]+(!""+"")[+[]]+(!""+"")[-~-~[]]+(!""+"")[-~[]]+(""[+[]]+"")[-~[]] | |
)+'[][$___][$___]($_____+"\'\\\\'+(''[+[]]+'')[+[]]+'"+_$_$+"\';")();'))(""+(+[])+(+[])+(-~-~[])+(+[])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I decided to see if I could write something to execute more arbitrary code than in the original article on Hacker News at http://adamcecc.blogspot.com/2011/01/javascript.html