2022-10-27 14:13:23 -04:00
|
|
|
var CreateWsmanComm=function(e,t,n,r,o){var u={};function c(e){e="00000000"+e.toString(16);return e.substring(e.length-8)}function a(){for(i in u.socketState=2,u.pendingAjaxCall)u.sendRequest(u.pendingAjaxCall[i][0],u.pendingAjaxCall[i][3],u.pendingAjaxCall[i][4])}function s(e){for(u.socketAccumulator+=(e=new Uint8Array(e.data),String.fromCharCode.apply(null,e));;){if(0==u.socketParseState){var t,n=u.socketAccumulator.indexOf("\r\n\r\n");if(n<0)return;if(u.socketHeader=u.socketAccumulator.substring(0,n).split("\r\n"),null==u.amtVersion)for(var r in u.socketHeader)0==u.socketHeader[r].indexOf("Server: Intel(R) Active Management Technology ")&&(u.amtVersion=u.socketHeader[r].substring(46));for(r in u.socketAccumulator=u.socketAccumulator.substring(n+4),u.socketParseState=1,u.socketData="",u.socketXHeader={Directive:u.socketHeader[0].split(" ")},u.socketHeader)0!=r&&(t=u.socketHeader[r].indexOf(":"),u.socketXHeader[u.socketHeader[r].substring(0,t).toLowerCase()]=u.socketHeader[r].substring(t+2))}if(1==u.socketParseState){n=-1;if(null==u.socketXHeader.connection||"close"!=u.socketXHeader.connection.toLowerCase()||null!=u.socketXHeader["transfer-encoding"]&&"chunked"==u.socketXHeader["transfer-encoding"].toLowerCase())if(null!=u.socketXHeader["content-length"]){if(n=parseInt(u.socketXHeader["content-length"]),u.socketAccumulator.length<n)return;var o=u.socketAccumulator.substring(0,n);u.socketAccumulator=u.socketAccumulator.substring(n),u.socketData=o,n=0}else{var a=u.socketAccumulator.indexOf("\r\n");if(a<0)return;if(n=parseInt(u.socketAccumulator.substring(0,a),16),isNaN(n))return void(u.websocket&&u.websocket.close());if(u.socketAccumulator.length<a+2+n+2)return;o=u.socketAccumulator.substring(a+2,a+2+n);u.socketAccumulator=u.socketAccumulator.substring(a+2+n+2),u.socketData+=o}else n=0;if(0==n){l=i=c=s=a=void 0;var a=u.socketXHeader,s=u.socketData,c=parseInt(a.Directive[1]);if(401==(c=isNaN(c)?602:c)&&++u.authcounter<3){if(u.challengeParams=u.parseDigest(a["www-authenticate"]),null!=u.challengeParams.qop){var l,i=u.challengeParams.qop.split(",");for(l in i)i[l]=i[l].trim();0<=i.indexOf("auth-int")?u.challengeParams.qop="auth-int":u.challengeParams.qop="auth"}}else{a=u.pendingAjaxCall.shift();u.authcounter=0,u.ActiveAjaxCount--,u.gotNextMessages(s,"success",{status:c},a),u.PerformNextAjax()}u.socketParseState=0,u.socketHeader=null}}}}function l(e){var t,n;u.socketState=0,null!=u.socket&&(u.socket.close(),u.socket=null),0<u.pendingAjaxCall.length&&(n=(t=u.pendingAjaxCall.shift())[5],u.PerformAjaxExNodeJS2(t[0],t[1],t[2],t[3],t[4],--n))}return u.PendingAjax=[],u.ActiveAjaxCount=0,u.MaxActiveAjaxCount=1,u.FailAllError=0,u.challengeParams=null,u.noncecounter=1,u.authcounter=0,u.socket=null,u.socketState=0,u.host=e,u.port=t,u.user=n,u.pass=r,u.tls=o,u.tlsv1only=1,u.cnonce=Math.random().toString(36).substring(7),u.PerformAjax=function(e,t,n,r,o,a){u.ActiveAjaxCount<u.MaxActiveAjaxCount&&0==u.PendingAjax.length?u.PerformAjaxEx(e,t,n,o,a):1==r?u.PendingAjax.unshift([e,t,n,o,a]):u.PendingAjax.push([e,t,n,o,a])},u.PerformNextAjax=function(){var e;u.ActiveAjaxCount>=u.MaxActiveAjaxCount||0==u.PendingAjax.length||(e=u.PendingAjax.shift(),u.PerformAjaxEx(e[0],e[1],e[2],e[3],e[4]),u.PerformNextAjax())},u.PerformAjaxEx=function(e,t,n,r,o){if(0==u.FailAllError)return e=e||"",u.ActiveAjaxCount++,u.PerformAjaxExNodeJS(e,t,n,r,o);u.gotNextMessagesError({status:u.FailAllError},"error",null,[e,t,n,r,o])},u.pendingAjaxCall=[],u.PerformAjaxExNodeJS=function(e,t,n,r,o){u.PerformAjaxExNodeJS2(e,t,n,r,o,3)},u.PerformAjaxExNodeJS2=function(e,t,n,r,o,a){a<=0||0!=u.FailAllError?(u.ActiveAjaxCount--,999!=u.FailAllError&&u.gotNextMessages(null,"error",{status:0==u.FailAllError?408:u.FailAllError},[e,t,n,r,o]),u.PerformNextAjax()):(u.pendingAjaxCall.push([e,t,n,r,o,a]),0==u.socketState?u.xxConnectHttpSocket():2==u.socketState&&u.sendRequest(e,r,o))},u.sendRequest=function(e,t,n){var r=(n=n||"POST")+" "+(t=t||"/wsman")+" HTTP/1.1\r\n",o=(null!=u.challengeParams&&(n=hex_md5(hex_md5(u.user+":"+u.challengeParams.realm+":"+u.pass)+":"+u.challengeParams.nonce
|