index.html 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. <html>
  2. <head>
  3. <title>JSFuck - Write any JavaScript with 6 Characters: []()!+</title>
  4. <meta name="description" content="JSFuck is an esoteric and educational programming style based on the atomic parts of JavaScript. It uses only six different characters to execute code.">
  5. <meta charset="utf-8" />
  6. <meta property="og:image" content="http://www.jsfuck.com/preview.png" />
  7. <meta name="viewport" content="width=device-width" />
  8. <style>
  9. body {
  10. padding: 20px;
  11. }
  12. body, * {
  13. font-family: monospace;
  14. font-size: 14px;
  15. line-height: 1.4em;
  16. }
  17. h1 {
  18. font-size: 2em;
  19. position: absolute;
  20. top: 70px;
  21. font-weight: normal;
  22. left: 140px;
  23. }
  24. h2 {
  25. width: 90px;
  26. text-align: right;
  27. padding: 50px 5px 5px;
  28. background: #F0DB4E;
  29. color: #323230;
  30. font-weight: bold;
  31. font-size: 20px;
  32. line-height: 1em;
  33. }
  34. h3 {
  35. font-weight: bold;
  36. }
  37. p, li, textarea, .actions {
  38. width: 100%;
  39. max-width: 600px;
  40. }
  41. textarea {
  42. display: block;
  43. height: 200px;
  44. margin: 1em 0;
  45. }
  46. ul.pre li{
  47. white-space: pre;
  48. }
  49. .checkbox {
  50. display: inline-block;
  51. }
  52. .actions a {
  53. float: right;
  54. }
  55. .actions {
  56. clear: both;
  57. }
  58. </style>
  59. </head>
  60. <body>
  61. <h1>JSFuck</h1>
  62. <h2>()+<br>[]!</h2>
  63. <p>JSFuck is an esoteric and educational programming style based on the
  64. atomic parts of JavaScript. It uses only six different characters to
  65. write and execute code.</p>
  66. <p>It does not depend on a browser, so you can even run it on Node.js.</p>
  67. <p>Use the form below to convert your own script. Uncheck "eval source" to
  68. get back a plain string.</p>
  69. <input id="input" type="text" value="alert(1)"/>
  70. <button id="encode" type="text">Encode</button>
  71. <div class="checkbox">
  72. <input id="eval" type="checkbox" checked />
  73. <label for="eval">Eval Source</label>
  74. </div>
  75. <textarea id="output"></textarea>
  76. <div class="actions">
  77. <span id="stats">…</span>
  78. <a id="run" href="#">Run This</a>
  79. </div>
  80. <h3>Links</h3>
  81. <ul>
  82. <li>View source on <a href="http://github.com/aemkei/jsfuck">GitHub</a></li>
  83. <li>Follow <a href="http://twitter.com/aemkei">@aemkei</a> (Martin Kleppe)</li>
  84. <li>Original discussion at <a href="http://sla.ckers.org/forum/read.php?24,32930">Sla.ckers.org</a></li>
  85. </ul>
  86. <h3>Alternatives</h3>
  87. <ul>
  88. <li><a href="http://patriciopalladino.com/files/hieroglyphy/">Hieroglyphy</a> (8 chars, browser only)</li>
  89. <li><a href="http://utf-8.jp/public/jsfuck.html">utf-8.jp</a> (broken)</li>
  90. <li><a href="http://discogscounter.getfreehosting.co.uk/js-noalnum.php">JS-NoAlnum</a> (broken)</li>
  91. </ul>
  92. <h3>Basics</h3>
  93. <ul class="pre">
  94. <li>false => ![]</li>
  95. <li>true => !![]</li>
  96. <li>undefined => [][[]]</li>
  97. <li>NaN => +[![]]</li>
  98. <li>0 => +[]</li>
  99. <li>1 => +!+[]</li>
  100. <li>2 => !+[]+!+[]</li>
  101. <li>10 => [+!+[]]+[+[]]</li>
  102. <li>Array => []</li>
  103. <li>Number => +[]</li>
  104. <li>String => []+[]</li>
  105. <li>Boolean => ![]</li>
  106. <li>Function => []["filter"]</li>
  107. <li>eval => []["filter"]["constructor"]( CODE )()</li>
  108. <li>window => []["filter"]["constructor"]("return this")()</li>
  109. </ul>
  110. <p>See the full list <a href="https://github.com/aemkei/jsfuck/blob/master/jsfuck.js">here</a>.</p>
  111. <script src="jsfuck.js"></script>
  112. <script>
  113. function $(id){
  114. return document.getElementById(id);
  115. }
  116. function encode(){
  117. var output = JSFuck.encode($("input").value, $("eval").checked);
  118. $("output").value = output;
  119. $("stats").innerHTML = output.length + " chars";
  120. }
  121. $("encode").onclick = encode;
  122. $("eval").onchange = encode;
  123. encode();
  124. $("run").onclick = function(){
  125. value = eval($("output").value);
  126. if (!$("eval").checked){
  127. alert('"' + value + '"');
  128. }
  129. return false;
  130. };
  131. </script>
  132. <script type="text/javascript">
  133. var _gaq = _gaq || [];
  134. _gaq.push(['_setAccount', 'UA-57649-11']);
  135. _gaq.push(['_trackPageview']);
  136. (function() {
  137. var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
  138. ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
  139. var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  140. })();
  141. </script>
  142. </body>
  143. </html>