2020-09-08 16:33:52 -04:00
|
|
|
var CreateAmtRedirect=function(e,c){var A={};function T(e){return String.fromCharCode.apply(null,e)}function U(e){for(var t="",n=0;n<e;n++)t+="abcdef0123456789".charAt(Math.floor(16*Math.random()));return t}return((A.m=e).parent=A).authCookie=c,A.State=0,A.socket=null,A.host=null,A.port=0,A.user=null,A.pass=null,A.authuri="/RedirectionService",A.tlsv1only=0,A.inDataCount=0,A.connectstate=0,A.protocol=e.protocol,A.acc=null,A.amtsequence=1,A.amtkeepalivetimer=null,A.onStateChanged=null,A.Start=function(e,t,n,r,a){A.host=e,A.port=t,A.user=n,A.pass=r,A.connectstate=0,A.inDataCount=0;var o=window.location.protocol.replace("http","ws")+"//"+window.location.host+window.location.pathname.substring(0,window.location.pathname.lastIndexOf("/"))+"/webrelay.ashx?p=2&host="+e+"&port="+t+"&tls="+a+("*"==n?"&serverauth=1":"")+(void 0===r?"&serverauth=1&user="+n:"");null!=c&&""!=c&&(o+="&auth="+c),A.socket=new WebSocket(o),A.socket.binaryType="arraybuffer",A.socket.onopen=A.xxOnSocketConnected,A.socket.onmessage=A.xxOnMessage,A.socket.onclose=A.xxOnSocketClosed,A.xxStateChange(1)},A.xxOnSocketConnected=function(){A.xxStateChange(2),1==A.protocol&&A.directSend(new Uint8Array([16,0,0,0,83,79,76,32])),2==A.protocol&&A.directSend(new Uint8Array([16,1,0,0,75,86,77,82])),3==A.protocol&&A.directSend(new Uint8Array([16,0,0,0,73,68,69,82]))},A.xxOnMessage=function(e){if(e.data&&-1!=A.connectstate){if(A.inDataCount++,1==A.connectstate&&(2==A.protocol||3==A.protocol))return A.m.ProcessBinaryData?A.m.ProcessBinaryData(e.data):A.m.ProcessData(T(e.data));if(null==A.acc)A.acc=e.data;else{var t=new Uint8Array(A.acc.byteLength+e.data.byteLength);t.set(new Uint8Array(A.acc),0),t.set(new Uint8Array(e.data),A.acc.byteLength),A.acc=t.buffer}for(;null!=A.acc&&1<=A.acc.byteLength;){var n=0,r=new Uint8Array(A.acc);switch(r[0]){case 17:if(r.byteLength<4)return;switch(r[1]){case 0:if(r.byteLength<13)return;var a=r[12];if(r.byteLength<13+a)return;A.directSend(new Uint8Array([19,0,0,0,0,0,0,0,0])),n=13+a;break;default:A.Stop(1)}break;case 20:if(r.byteLength<9)return;var o=new DataView(A.acc).getUint32(5,!0);if(r.byteLength<9+o)return;var c=r[1],s=r[4],l=[];for(i=0;i<o;i++)l.push(r[9+i]);var h=new Uint8Array(A.acc.slice(9,9+o));if(n=9+o,0==s)0<=l.indexOf(4)?A.xxSend(String.fromCharCode(19,0,0,0,4)+IntToStrX(A.user.length+A.authuri.length+8)+String.fromCharCode(A.user.length)+A.user+String.fromCharCode(0,0)+String.fromCharCode(A.authuri.length)+A.authuri+String.fromCharCode(0,0,0,0)):0<=l.indexOf(3)?A.xxSend(String.fromCharCode(19,0,0,0,3)+IntToStrX(A.user.length+A.authuri.length+7)+String.fromCharCode(A.user.length)+A.user+String.fromCharCode(0,0)+String.fromCharCode(A.authuri.length)+A.authuri+String.fromCharCode(0,0,0)):0<=l.indexOf(1)?A.xxSend(String.fromCharCode(19,0,0,0,1)+IntToStrX(A.user.length+A.pass.length+2)+String.fromCharCode(A.user.length)+A.user+String.fromCharCode(A.pass.length)+A.pass):A.Stop(2);else if(3!=s&&4!=s||1!=c)if(0==c)switch(A.protocol){case 1:A.xxSend(String.fromCharCode(32,0,0,0)+IntToStrX(A.amtsequence++)+ShortToStrX(1e4)+ShortToStrX(100)+ShortToStrX(0)+ShortToStrX(1e4)+ShortToStrX(100)+ShortToStrX(0)+IntToStrX(0));break;case 2:A.directSend(new Uint8Array([64,0,0,0,0,0,0,0]));break;case 3:A.connectstate=1,A.xxStateChange(3)}else A.Stop(3);else{var u=0,S=h[u],d=T(new Uint8Array(h.buffer.slice(u+1,u+1+S))),f=h[u+=S+1],g=T(new Uint8Array(h.buffer.slice(u+1,u+1+f)));u+=f+1;var C=0,m=null,x=U(32),y="00000002",b="";4==s&&(C=h[u],m=T(new Uint8Array(h.buffer.slice(u+1,u+1+C))),u+=C+1,b=y+":"+x+":"+m+":");var p=hex_md5(hex_md5(A.user+":"+d+":"+A.pass)+":"+g+":"+b+hex_md5("POST:"+A.authuri)),k=A.user.length+d.length+g.length+A.authuri.length+x.length+y.length+p.length+7;4==s&&(k+=m.length+1);var w=String.fromCharCode(19,0,0,0,s)+IntToStrX(k)+String.fromCharCode(A.user.length)+A.user+String.fromCharCode(d.length)+d+String.fromCharCode(g.length)+g+String.fromCharCode(A.authuri.length)+A.authuri+String.fromCharCode(x.length)+x+String.fromCharCode(y.length)+y+String.fromCharCode(p.length)+p;4==s&&(w+=String.fromCharCode(m.length)+m),A.xxSend(w)}break
|