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