js-noalnum_com.html 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  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["escape"]("<")[0]',
  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*/ '[]["sort"]["constructor"]("return \\\"\\103\\\"")()',
  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["unescape"]("%"+(5)+"c")[0]',
  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. console.log(":", s)
  117. s=s.substring(1,s.length-1);
  118. s=s.replace(/\"/g,replacement_chars[2]);
  119. var constr=['false','true','NaN','Infinity','undefined'];
  120. var constr_r=['![]','!![]','+[![]]','+(+!+[]+(!+[]+[])[!+[]+!+[]+!+[]]+[+!+[]]+[+[]]+[+[]]+[+[]])','[][[]]'];
  121. function swapInner(str,f){
  122. if (str=="") return "";
  123. var rep="";
  124. var up=1;
  125. var enc=true;
  126. for (i=0;i<constr.length;i++)
  127. if (str.indexOf(constr[i])==0){
  128. rep=constr_r[i];
  129. up=constr[i].length;
  130. if (f&&str.length==up)
  131. rep+="+[]";
  132. }
  133. if (rep==""){
  134. rep=(/[0-9]+/).exec(str);
  135. if (rep!=null && str.indexOf(rep=String(rep))==0){
  136. up=rep.length;
  137. rep=makeNumberStr(rep);
  138. }
  139. else {
  140. enc=false;
  141. rep=replacement_chars[str.charCodeAt(0)-32];
  142. }
  143. }
  144. if (f)
  145. enc=false;
  146. return (f?"":"+")+(enc?"[":"")+rep+(enc?"]":"")+swapInner(str.substr(up),false);
  147. }
  148. return swapInner(s,true);
  149. }
  150. function noalnum(){
  151. txt=" "+document.getElementById("txt").value+" ";
  152. // /* 1. FORMAT REFERENCES USING BRACKETS */
  153. // txt=txt.replace(/\.([a-zA-Z0-9_$]+)/gi,"[\"$1\"]");
  154. /* 2. GROUND GLOBAL REFERENCES */
  155. txt=txt.replace(/([\s()\[\]{};+])(alert|eval|atob|btoa|document)/g,"$1(window[\"$2\"])");
  156. /* 3. REPLACE ESCAPED QUOTES */
  157. txt=txt.replace(/\\"/g,replacement_chars[92-32]+"+"+replacement_chars[34-32]);
  158. txt=txt.replace(/\\'/g,replacement_chars[92-32]+"+"+replacement_chars[39-32]);
  159. console.log(txt)
  160. /* Loop */
  161. var it=0;
  162. var old="";
  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. //
  167. // for (i=0;i<objs.length;i++){
  168. // reg=new RegExp("([\\s()\\[\\]{};,.+])"+objs[i]+"([\\s()\\[\\]{};,.+])","g");
  169. // txt=txt.replace(reg,"$1"+objs_r[i]+"$2");
  170. // }
  171. //
  172. //
  173. // /* 4. REPLACE CONSTANTS */
  174. // var cons=['false','true','NaN','Infinity','undefined'];
  175. // var cons_r=['![]','!![]','+[![]]','+(+!+[]+(!+[]+[])[!+[]+!+[]+!+[]]+[+!+[]]+[+[]]+[+[]]+[+[]])','[][[]]'];
  176. //
  177. // for (i=0;i<cons.length;i++){
  178. // reg=new RegExp("([\\s()\\[\\]{};,.+])"+cons[i]+"([\\s()\\[\\]{};,.+])","g");
  179. // txt=txt.replace(reg,"$1"+cons_r[i]+"$2");
  180. // }
  181. // txt=txt.replace(/([\(\)\[\]])("")([\(\)\[\]])/g,"$1[]+[]$3");
  182. // txt=txt.replace(/""/g,"([]+[])");
  183. //
  184. // /* 5. REPLACE STRINGS */
  185. txt=txt.replace(/"([^"]+)"/g,swapString);
  186. txt=txt.replace(/([^']+)/g,swapString);
  187. /* 6. REPLACE NUMBERS */
  188. txt=txt.replace(/([\(\)\[\]])([0-9]+)([\(\)\[\]])/g,function(a,b,c,d){return b+makeNumberStr(c)+d;});
  189. txt=txt.replace(/[0-9]+/g,makeNumber);
  190. document.getElementById("len").value=txt.length-2;
  191. document.getElementById("out").value=txt;
  192. }
  193. </script>
  194. </head>
  195. <body bgcolor="FFFF99">
  196. <p>Converts javascript command into no alnum version using only []()+! characters (unless you input extras).</p>
  197. <p>Intended input: one line, no whitespace, no variables, function definitions or conditionals.</p>
  198. <p>Note:
  199. <br>~ Some obscure letters/symbols might not be implemented (will remain as they are in the output)
  200. <br>~ A precise syntax is required:
  201. <br> - Infinity, NaN, or any number needs to be enclosed when being added to something from behind
  202. <br> - Numbers outside strings, ie. "abc"+123
  203. <br> - Strings in double quotations, not nested
  204. <br>~ Most problems caused by missing parentheses around strings
  205. </p>
  206. <p>
  207. Example:
  208. <br>alert(document.getElementById("txt").value+String.fromCharCode(33))
  209. </p>
  210. <p>Let me know if you find any improvements! Page tested with Firefox only.</p>
  211. <br>Input:
  212. <br><textarea id="txt" cols="80" rows="2">abcdefg</textarea>
  213. <br>
  214. <input type="button" value="Convert" onclick="step=-1;noalnum()" />
  215. <input type="button" value="Step" onclick="step++;noalnum()" />
  216. <input type="button" value="eval(--v)" onclick="eval(document.getElementById('out').value);" />
  217. <input type="button" value="alert(eval(--v))" onclick="alert(eval(document.getElementById('out').value));" />
  218. <input type="button" value="Clear--^" onclick="document.getElementById('txt').value=''" />
  219. <input type="button" value="Clear--v" onclick="document.getElementById('out').value=''" />
  220. Output Length: <input type="text" size="12" id="len" />
  221. <br>
  222. <textarea id="out" cols="80" rows="30">alert(" Result shows here. ")</textarea>
  223. </body>
  224. </html>