123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273 |
- <html>
- <head>
- <script>
- /* Supported letters & symbols */
- var replacement_chars=[
- /* */ '(NaN+[]["filter"])[11]',
- /*!*/ 'window["atob"]("If")[0]',
- /*"*/ '("").fontcolor()[12]',
- /*#*/ 'window["atob"]("0iN")[1]',
- /*$*/ 'window["atob"]("0iT")[1]',
- /*%*/ 'window["atob"]("0iW")[1]',
- /*&*/ 'window["atob"]("0ia")[1]',
- /*'*/ 'window["atob"]("0if")[1]',
- /*(*/ '(false+[]["filter"])[20]',
- /*)*/ '(false+[]["filter"])[21]',
- /***/ 'window["atob"]("0ir")[1]',
- /*+*/ 'window["atob"]("0it")[1]',
- /*,*/ 'window["atob"]("0iy")[1]',
- /*-*/ '(NaN+window["Date"]())[31]',
- /*.*/ 'window["atob"]("1i4")[1]',
- /*/*/ '(true+("")["sub"]())[10]',
- /*0-9 ignored*/ ,,,,,,,,,,
- /*:*/ 'window["Date"]()[21]',
- /*;*/ 'window["atob"]("O0")[0]',
- /*<*/ '("")["sub"]()[0]',
- /*=*/ '("").fontcolor()[11]',
- /*>*/ '("")["sub"]()[10]',
- /*?*/ 'window["atob"]("0j9")[1]',
- /*@*/ 'window["atob"]("00A")[1]',
- /*A*/ '(+[]+[]["constructor"])[10]',
- /*B*/ '(+[]+(false)["constructor"])[10]',
- /*C*/ 'window["atob"]("00N")[1]',
- /*D*/ 'window["atob"](00)[1]',
- /*E*/ 'window["atob"](01)[2]',
- /*F*/ '(0+[]["filter"]["constructor"])[10]',
- /*G*/ 'window["atob"]("0f")[1]',
- /*H*/ 'window["atob"]("0t")[1]',
- /*I*/ '("Infinity")[0]',
- /*J*/ 'window["atob"]("00r")[1]',
- /*K*/ 'window["atob"]("(")[0]',
- /*L*/ 'window["atob"]("/")[0]',
- /*M*/ 'window["atob"](0)[0]',
- /*N*/ '("NaN")[0]',
- /*O*/ 'window["atob"](8)[0]',
- /*P*/ 'window["atob"]("<")[0]',
- /*Q*/ 'window["atob"]("a")[1]',
- /*R*/ 'window["atob"]("01I")[1]',
- /*S*/ '(String+"")[9]',
- /*T*/ 'window["atob"]("N")[0]',
- /*U*/ 'window["atob"]("01W")[1]',
- /*V*/ 'window["atob"]("01a")[1]',
- /*W*/ '(true+window)[12]',
- /*X*/ 'window["atob"]("01i")[1]',
- /*Y*/ 'window["atob"]("a")[0]',
- /*Z*/ 'window["atob"]("f")[0]',
- /*[*/ '(undefined+[]["filter"])[33]',
- /*\*/ 'window["atob"]("01y")[1]',
- /*]*/ '(true+[]["filter"])[40]',
- /*^*/ 'window["atob"](014)[1]',
- /*_*/ 'window["atob"](018)[1]',
- /*`*/ 'window["atob"]("02A")[1]',
- /*a*/ '("false")[1]',
- /*b*/ '(window+[])[2]', // "[object"
- /*c*/ '([]["filter"]+[])[3]',
- /*d*/ '("undefined")[2]',
- /*e*/ '("true")[3]',
- /*f*/ '("false")[0]',
- /*g*/ '([]+("")["constructor"])[14]',
- /*h*/ '(+(17))["toString"](18)',
- /*i*/ '([false]+undefined)[10]',
- /*j*/ '(window+[])[3]',
- /*k*/ '(+(20))["toString"](21)',
- /*l*/ '("false")[2]',
- /*m*/ '(Number+[])[11]',
- /*n*/ '("undefined")[1]',
- /*o*/ '(true+[]["filter"])[10]',
- /*p*/ '(+(25))["toString"](30)',
- /*q*/ '(+(26))["toString"](30)',
- /*r*/ '("true")[1]',
- /*s*/ '("false")[3]',
- /*t*/ '("true")[0]',
- /*u*/ '("undefined")[0]',
- /*v*/ '(+(31))["toString"](32)',
- /*w*/ '(+(32))["toString"](33)',
- /*x*/ '(+(33))["toString"](34)',
- /*y*/ '(NaN+[Infinity])[10]',
- /*z*/ '(+(35))["toString"](36)',
- /*{*/ '(NaN+[]["filter"])[21]',
- /*|*/ 'window["atob"]("03y")[1]',
- /*}*/ '(NaN+[]["filter"])[41]',
- /*~*/ 'window["atob"](234)[1]'
- ]
- var reg;
- var step=-1;
- function makeDigit(d){
- var n=parseInt(d);
- var res="+[]";
- if (n>0)
- res="+!"+res;
- for (i=1;i<n;i++)
- res="+!+[]"+res;
- if (n>1)
- res=res.substr(1);
- return res;
- }
- function makeNumberStr(r){
- var res=makeDigit(r[0]);
- if (r.length>1)
- res+="+["+makeNumberStr(r.substr(1))+"]";
- return res;
- }
- function makeNumber(r){
- return "+("+makeNumberStr(r)+")";
- }
- function swapString(s){
- s=s.substring(1,s.length-1);
- s=s.replace(/\"/g,replacement_chars[2]);
-
- var constr=['false','true','NaN','Infinity','undefined'];
- var constr_r=['![]','!![]','+[![]]','+(+!+[]+(!+[]+[])[!+[]+!+[]+!+[]]+[+!+[]]+[+[]]+[+[]]+[+[]])','[][[]]'];
- function swapInner(str,f){
- if (str=="") return "";
- var rep="";
- var up=1;
- var enc=true;
- for (i=0;i<constr.length;i++)
- if (str.indexOf(constr[i])==0){
- rep=constr_r[i];
- up=constr[i].length;
- if (f&&str.length==up)
- rep+="+[]";
- }
- if (rep==""){
- rep=(/[0-9]+/).exec(str);
- if (rep!=null && str.indexOf(rep=String(rep))==0){
- up=rep.length;
- rep=makeNumberStr(rep);
- }
- else {
- enc=false;
- rep=replacement_chars[str.charCodeAt(0)-32];
- }
- }
- if (f)
- enc=false;
- return (f?"":"+")+(enc?"[":"")+rep+(enc?"]":"")+swapInner(str.substr(up),false);
- }
- return swapInner(s,true);
- }
- function noalnum(){
- txt=" "+document.getElementById("txt").value+" ";
- /* 1. FORMAT REFERENCES USING BRACKETS */
- txt=txt.replace(/\.([a-zA-Z0-9_$]+)/gi,"[\"$1\"]");
- /* 2. GROUND GLOBAL REFERENCES */
- txt=txt.replace(/([\s()\[\]{};+])(alert|eval|atob|btoa|document)/g,"$1(window[\"$2\"])");
- /* 3. REPLACE ESCAPED QUOTES */
- txt=txt.replace(/\\"/g,replacement_chars[92-32]+replacement_chars[34-32]);
- txt=txt.replace(/\\'/g,replacement_chars[92-32]+replacement_chars[39-32]);
- /* Loop */
- var it=0;
- var old="";
- while (txt!=old){
- old=txt;
- /* 3. REPLACE OBJECTS */
- var objs=['String','Boolean','Function','Array','Number','Date','Object','window'];
- var objs_r=['("")["constructor"]','(false)["constructor"]','[]["filter"]["constructor"]','[]["constructor"]','(0)["constructor"]','window["Date"]','(window["constructor"])["constructor"]','[]["sort"]["constructor"]("return this")()'];
- for (i=0;i<objs.length;i++){
- reg=new RegExp("([\\s()\\[\\]{};,.+])"+objs[i]+"([\\s()\\[\\]{};,.+])","g");
- txt=txt.replace(reg,"$1"+objs_r[i]+"$2");
- }
- /* 4. REPLACE CONSTANTS */
- var cons=['false','true','NaN','Infinity','undefined'];
- var cons_r=['![]','!![]','+[![]]','+(+!+[]+(!+[]+[])[!+[]+!+[]+!+[]]+[+!+[]]+[+[]]+[+[]]+[+[]])','[][[]]'];
- for (i=0;i<cons.length;i++){
- reg=new RegExp("([\\s()\\[\\]{};,.+])"+cons[i]+"([\\s()\\[\\]{};,.+])","g");
- txt=txt.replace(reg,"$1"+cons_r[i]+"$2");
- }
- txt=txt.replace(/([\(\)\[\]])("")([\(\)\[\]])/g,"$1[]+[]$3");
- txt=txt.replace(/""/g,"([]+[])");
- /* 5. REPLACE STRINGS */
- txt=txt.replace(/"([^"]+)"/g,swapString);
- txt=txt.replace(/'([^']+)'/g,swapString);
- if (step==it)
- break;
- it++;
- }
- /* 6. REPLACE NUMBERS */
- txt=txt.replace(/([\(\)\[\]])([0-9]+)([\(\)\[\]])/g,function(a,b,c,d){return b+makeNumberStr(c)+d;});
- txt=txt.replace(/[0-9]+/g,makeNumber);
- document.getElementById("len").value=txt.length-2;
- document.getElementById("out").value=txt.substring(1,txt.length-1);
- }
- </script>
- </head>
- <body bgcolor="FFFF99" >
- <p>Converts javascript command into no alnum version using only []()+! characters (unless you input extras).</p>
- <p>Intended input: one line, no whitespace, no variables, function definitions or conditionals.</p>
- <p>Note:
- <br>~ Some obscure letters/symbols might not be implemented (will remain as they are in the output)
- <br>~ A precise syntax is required:
- <br> - Infinity, NaN, or any number needs to be enclosed when being added to something from behind
- <br> - Numbers outside strings, ie. "abc"+123
- <br> - Strings in double quotations, not nested
- <br>~ Most problems caused by missing parentheses around strings
- </p>
- <p>
- Example:
- <br>alert(document.getElementById("txt").value+String.fromCharCode(33))
- </p>
- <p>Let me know if you find any improvements! Page tested with Firefox only.</p>
- <br>Input:
- <br><textarea id="txt" cols="80" rows="2">alert("Type your code here!")</textarea>
- <br>
- <input type="button" value="Convert" onclick="step=-1;noalnum()" />
- <input type="button" value="Step" onclick="step++;noalnum()" />
- <input type="button" value="eval(--v)" onclick="eval(document.getElementById('out').value);" />
- <input type="button" value="alert(eval(--v))" onclick="alert(eval(document.getElementById('out').value));" />
- <input type="button" value="Clear--^" onclick="document.getElementById('txt').value=''" />
- <input type="button" value="Clear--v" onclick="document.getElementById('out').value=''" />
- Output Length: <input type="text" size="12" id="len" />
- <br>
- <textarea id="out" cols="80" rows="30">alert(" Result shows here. ")</textarea>
- </body>
- </html>
|