js-noalnum_com.html 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. <html>
  2. <head>
  3. <script>
  4. /* Supported letters & symbols */
  5. var replacement_chars=[
  6. /* */ '(NaN+[]["filter"])[11]',
  7. /*!*/ 'window["atob"]("If")[0]',
  8. /*"*/ '("").fontcolor()[12]',
  9. /*#*/ 'window["atob"]("0iN")[1]',
  10. /*$*/ 'window["atob"]("0iT")[1]',
  11. /*%*/ 'window["atob"]("0iW")[1]',
  12. /*&*/ 'window["atob"]("0ia")[1]',
  13. /*'*/ 'window["atob"]("0if")[1]',
  14. /*(*/ '(false+[]["filter"])[20]',
  15. /*)*/ '(false+[]["filter"])[21]',
  16. /***/ 'window["atob"]("0ir")[1]',
  17. /*+*/ 'window["atob"]("0it")[1]',
  18. /*,*/ 'window["atob"]("0iy")[1]',
  19. /*-*/ '(NaN+window["Date"]())[31]',
  20. /*.*/ 'window["atob"]("1i4")[1]',
  21. /*/*/ '(true+("")["sub"]())[10]',
  22. /*0-9 ignored*/ ,,,,,,,,,,
  23. /*:*/ 'window["Date"]()[21]',
  24. /*;*/ 'window["atob"]("O0")[0]',
  25. /*<*/ '("")["sub"]()[0]',
  26. /*=*/ '("").fontcolor()[11]',
  27. /*>*/ '("")["sub"]()[10]',
  28. /*?*/ 'window["atob"]("0j9")[1]',
  29. /*@*/ 'window["atob"]("00A")[1]',
  30. /*A*/ '(+[]+[]["constructor"])[10]',
  31. /*B*/ '(+[]+(false)["constructor"])[10]',
  32. /*C*/ 'window["atob"]("00N")[1]',
  33. /*D*/ 'window["atob"](00)[1]',
  34. /*E*/ 'window["atob"](01)[2]',
  35. /*F*/ '(0+[]["filter"]["constructor"])[10]',
  36. /*G*/ 'window["atob"]("0f")[1]',
  37. /*H*/ 'window["atob"]("0t")[1]',
  38. /*I*/ '("Infinity")[0]',
  39. /*J*/ 'window["atob"]("00r")[1]',
  40. /*K*/ 'window["atob"]("(")[0]',
  41. /*L*/ 'window["atob"]("/")[0]',
  42. /*M*/ 'window["atob"](0)[0]',
  43. /*N*/ '("NaN")[0]',
  44. /*O*/ 'window["atob"](8)[0]',
  45. /*P*/ 'window["atob"]("<")[0]',
  46. /*Q*/ 'window["atob"]("a")[1]',
  47. /*R*/ 'window["atob"]("01I")[1]',
  48. /*S*/ '(String+"")[9]',
  49. /*T*/ 'window["atob"]("N")[0]',
  50. /*U*/ 'window["atob"]("01W")[1]',
  51. /*V*/ 'window["atob"]("01a")[1]',
  52. /*W*/ '(true+window)[12]',
  53. /*X*/ 'window["atob"]("01i")[1]',
  54. /*Y*/ 'window["atob"]("a")[0]',
  55. /*Z*/ 'window["atob"]("f")[0]',
  56. /*[*/ '(undefined+[]["filter"])[33]',
  57. /*\*/ 'window["atob"]("01y")[1]',
  58. /*]*/ '(true+[]["filter"])[40]',
  59. /*^*/ 'window["atob"](014)[1]',
  60. /*_*/ 'window["atob"](018)[1]',
  61. /*`*/ 'window["atob"]("02A")[1]',
  62. /*a*/ '("false")[1]',
  63. /*b*/ '(window+[])[2]', // "[object"
  64. /*c*/ '([]["filter"]+[])[3]',
  65. /*d*/ '("undefined")[2]',
  66. /*e*/ '("true")[3]',
  67. /*f*/ '("false")[0]',
  68. /*g*/ '([]+("")["constructor"])[14]',
  69. /*h*/ '(+(17))["toString"](18)',
  70. /*i*/ '([false]+undefined)[10]',
  71. /*j*/ '(window+[])[3]',
  72. /*k*/ '(+(20))["toString"](21)',
  73. /*l*/ '("false")[2]',
  74. /*m*/ '(Number+[])[11]',
  75. /*n*/ '("undefined")[1]',
  76. /*o*/ '(true+[]["filter"])[10]',
  77. /*p*/ '(+(25))["toString"](30)',
  78. /*q*/ '(+(26))["toString"](30)',
  79. /*r*/ '("true")[1]',
  80. /*s*/ '("false")[3]',
  81. /*t*/ '("true")[0]',
  82. /*u*/ '("undefined")[0]',
  83. /*v*/ '(+(31))["toString"](32)',
  84. /*w*/ '(+(32))["toString"](33)',
  85. /*x*/ '(+(33))["toString"](34)',
  86. /*y*/ '(NaN+[Infinity])[10]',
  87. /*z*/ '(+(35))["toString"](36)',
  88. /*{*/ '(NaN+[]["filter"])[21]',
  89. /*|*/ 'window["atob"]("03y")[1]',
  90. /*}*/ '(NaN+[]["filter"])[41]',
  91. /*~*/ 'window["atob"](234)[1]'
  92. ]
  93. var reg;
  94. var step=-1;
  95. function makeDigit(d){
  96. var n=parseInt(d);
  97. var res="+[]";
  98. if (n>0)
  99. res="+!"+res;
  100. for (i=1;i<n;i++)
  101. res="+!+[]"+res;
  102. if (n>1)
  103. res=res.substr(1);
  104. return res;
  105. }
  106. function makeNumberStr(r){
  107. var res=makeDigit(r[0]);
  108. if (r.length>1)
  109. res+="+["+makeNumberStr(r.substr(1))+"]";
  110. return res;
  111. }
  112. function makeNumber(r){
  113. return "+("+makeNumberStr(r)+")";
  114. }
  115. function swapString(s){
  116. s=s.substring(1,s.length-1);
  117. s=s.replace(/\"/g,replacement_chars[2]);
  118. var constr=['false','true','NaN','Infinity','undefined'];
  119. var constr_r=['![]','!![]','+[![]]','+(+!+[]+(!+[]+[])[!+[]+!+[]+!+[]]+[+!+[]]+[+[]]+[+[]]+[+[]])','[][[]]'];
  120. function swapInner(str,f){
  121. if (str=="") return "";
  122. var rep="";
  123. var up=1;
  124. var enc=true;
  125. for (i=0;i<constr.length;i++)
  126. if (str.indexOf(constr[i])==0){
  127. rep=constr_r[i];
  128. up=constr[i].length;
  129. if (f&&str.length==up)
  130. rep+="+[]";
  131. }
  132. if (rep==""){
  133. rep=(/[0-9]+/).exec(str);
  134. if (rep!=null && str.indexOf(rep=String(rep))==0){
  135. up=rep.length;
  136. rep=makeNumberStr(rep);
  137. }
  138. else {
  139. enc=false;
  140. rep=replacement_chars[str.charCodeAt(0)-32];
  141. }
  142. }
  143. if (f)
  144. enc=false;
  145. return (f?"":"+")+(enc?"[":"")+rep+(enc?"]":"")+swapInner(str.substr(up),false);
  146. }
  147. return swapInner(s,true);
  148. }
  149. function noalnum(){
  150. txt=" "+document.getElementById("txt").value+" ";
  151. /* 1. FORMAT REFERENCES USING BRACKETS */
  152. txt=txt.replace(/\.([a-zA-Z0-9_$]+)/gi,"[\"$1\"]");
  153. /* 2. GROUND GLOBAL REFERENCES */
  154. txt=txt.replace(/([\s()\[\]{};+])(alert|eval|atob|btoa|document)/g,"$1(window[\"$2\"])");
  155. /* 3. REPLACE ESCAPED QUOTES */
  156. txt=txt.replace(/\\"/g,replacement_chars[92-32]+replacement_chars[34-32]);
  157. txt=txt.replace(/\\'/g,replacement_chars[92-32]+replacement_chars[39-32]);
  158. /* Loop */
  159. var it=0;
  160. var old="";
  161. while (txt!=old){
  162. old=txt;
  163. /* 3. REPLACE OBJECTS */
  164. var objs=['String','Boolean','Function','Array','Number','Date','Object','window'];
  165. var objs_r=['("")["constructor"]','(false)["constructor"]','[]["filter"]["constructor"]','[]["constructor"]','(0)["constructor"]','window["Date"]','(window["constructor"])["constructor"]','[]["sort"]["constructor"]("return this")()'];
  166. for (i=0;i<objs.length;i++){
  167. reg=new RegExp("([\\s()\\[\\]{};,.+])"+objs[i]+"([\\s()\\[\\]{};,.+])","g");
  168. txt=txt.replace(reg,"$1"+objs_r[i]+"$2");
  169. }
  170. /* 4. REPLACE CONSTANTS */
  171. var cons=['false','true','NaN','Infinity','undefined'];
  172. var cons_r=['![]','!![]','+[![]]','+(+!+[]+(!+[]+[])[!+[]+!+[]+!+[]]+[+!+[]]+[+[]]+[+[]]+[+[]])','[][[]]'];
  173. for (i=0;i<cons.length;i++){
  174. reg=new RegExp("([\\s()\\[\\]{};,.+])"+cons[i]+"([\\s()\\[\\]{};,.+])","g");
  175. txt=txt.replace(reg,"$1"+cons_r[i]+"$2");
  176. }
  177. txt=txt.replace(/([\(\)\[\]])("")([\(\)\[\]])/g,"$1[]+[]$3");
  178. txt=txt.replace(/""/g,"([]+[])");
  179. /* 5. REPLACE STRINGS */
  180. txt=txt.replace(/"([^"]+)"/g,swapString);
  181. txt=txt.replace(/'([^']+)'/g,swapString);
  182. if (step==it)
  183. break;
  184. it++;
  185. }
  186. /* 6. REPLACE NUMBERS */
  187. txt=txt.replace(/([\(\)\[\]])([0-9]+)([\(\)\[\]])/g,function(a,b,c,d){return b+makeNumberStr(c)+d;});
  188. txt=txt.replace(/[0-9]+/g,makeNumber);
  189. document.getElementById("len").value=txt.length-2;
  190. document.getElementById("out").value=txt.substring(1,txt.length-1);
  191. }
  192. </script>
  193. </head>
  194. <body bgcolor="FFFF99" >
  195. <p>Converts javascript command into no alnum version using only []()+! characters (unless you input extras).</p>
  196. <p>Intended input: one line, no whitespace, no variables, function definitions or conditionals.</p>
  197. <p>Note:
  198. <br>~ Some obscure letters/symbols might not be implemented (will remain as they are in the output)
  199. <br>~ A precise syntax is required:
  200. <br> - Infinity, NaN, or any number needs to be enclosed when being added to something from behind
  201. <br> - Numbers outside strings, ie. "abc"+123
  202. <br> - Strings in double quotations, not nested
  203. <br>~ Most problems caused by missing parentheses around strings
  204. </p>
  205. <p>
  206. Example:
  207. <br>alert(document.getElementById("txt").value+String.fromCharCode(33))
  208. </p>
  209. <p>Let me know if you find any improvements! Page tested with Firefox only.</p>
  210. <br>Input:
  211. <br><textarea id="txt" cols="80" rows="2">alert("Type your code here!")</textarea>
  212. <br>
  213. <input type="button" value="Convert" onclick="step=-1;noalnum()" />
  214. <input type="button" value="Step" onclick="step++;noalnum()" />
  215. <input type="button" value="eval(--v)" onclick="eval(document.getElementById('out').value);" />
  216. <input type="button" value="alert(eval(--v))" onclick="alert(eval(document.getElementById('out').value));" />
  217. <input type="button" value="Clear--^" onclick="document.getElementById('txt').value=''" />
  218. <input type="button" value="Clear--v" onclick="document.getElementById('out').value=''" />
  219. Output Length: <input type="text" size="12" id="len" />
  220. <br>
  221. <textarea id="out" cols="80" rows="30">alert(" Result shows here. ")</textarea>
  222. </body>
  223. </html>