mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2024-12-25 22:55:52 -05:00
First version with working Intel AMT IDER from the server for LAN connections only.
This commit is contained in:
parent
7ed963f414
commit
6f68741cb8
131
amt/amt-ider.js
131
amt/amt-ider.js
@ -15,6 +15,7 @@
|
||||
|
||||
// Construct a MeshAgent object, called upon connection
|
||||
module.exports.CreateAmtIderSession = function (parent, db, ws, req, args, domain, user) {
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const common = parent.common;
|
||||
const amtMeshRedirModule = require('./amt-redir-mesh.js');
|
||||
@ -47,8 +48,7 @@ module.exports.CreateAmtIderSession = function (parent, db, ws, req, args, domai
|
||||
// If the web socket is closed
|
||||
ws.on('close', function (req) {
|
||||
// Close the IDER session
|
||||
obj.ider.Stop();
|
||||
delete obj.ider;
|
||||
if (obj.ider) { obj.ider.Stop(); delete obj.ider; }
|
||||
});
|
||||
|
||||
// We are all set, start receiving data
|
||||
@ -64,42 +64,85 @@ module.exports.CreateAmtIderSession = function (parent, db, ws, req, args, domai
|
||||
|
||||
switch (command.action) {
|
||||
case 'ping': { try { ws.send(JSON.stringify({ action: 'pong' })); } catch (ex) { } break; }
|
||||
case 'selector': {
|
||||
var r = { action: 'selector', args: { html: 'Click ok to start IDER session.' }, buttons: 3 };
|
||||
// TODO: Return a list of disk images for the user to select.
|
||||
try { ws.send(JSON.stringify(r)); } catch (ex) { }
|
||||
break;
|
||||
}
|
||||
case 'selectorResponse': {
|
||||
//console.log('selectorResponse', command.args, req.query);
|
||||
// Start IDER Session
|
||||
case 'start': {
|
||||
// Get the list of disk images
|
||||
var domainx = 'domain' + ((domain.id == '') ? '' : ('-' + domain.id));
|
||||
var useridx = user._id.split('/')[2];
|
||||
var userPath = parent.parent.path.join(parent.parent.filespath, domainx, 'user-' + useridx);
|
||||
|
||||
command.args = {
|
||||
floppyPath: 'C:\\Users\\Default.DESKTOP-M9I88C9\\Desktop\\AmtWebApp\\meshcentral-files\\domain\\user-admin\\msdos.img',
|
||||
cdromPath: 'C:\\Users\\Default.DESKTOP-M9I88C9\\Desktop\\AmtWebApp\\meshcentral-files\\domain\\user-admin\\recovery.iso',
|
||||
iderStart: 1,
|
||||
tlsv1only: true
|
||||
};
|
||||
// Look for a list of disk images for the user to select.
|
||||
if (fs.existsSync(userPath)) {
|
||||
// Do something
|
||||
readFsRec(userPath, function (err, results) {
|
||||
var floppyImages = [], cdromImages = [];
|
||||
for (var i in results) {
|
||||
if (results[i].toLowerCase().endsWith('.img')) { floppyImages.push(results[i].substring(userPath.length + 1)); }
|
||||
else if (results[i].toLowerCase().endsWith('.iso')) { cdromImages.push(results[i].substring(userPath.length + 1)); }
|
||||
}
|
||||
//console.log(floppyImages, cdromImages);
|
||||
|
||||
// Setup the IDER session
|
||||
obj.ider = amtMeshRedirModule.CreateAmtRedirect(amtMeshIderModule.CreateAmtRemoteIder(parent, parent.parent), domain, user, parent, parent.parent);
|
||||
obj.ider.onStateChanged = onIderStateChange;
|
||||
obj.ider.m.iderStart = command.args.iderStart;
|
||||
obj.ider.m.sectorStats = iderSectorStats;
|
||||
obj.ider.tlsv1only = req.query.tlsv1only;
|
||||
var xx, sel = true, html = "<div style='margin:10px 5px 10px 5px'>Select disk images & start type.</div>";
|
||||
|
||||
// Setup disk images
|
||||
if (obj.ider.m.diskSetup(command.args.floppyPath, command.args.cdromPath) != 0) {
|
||||
// Error with the disk images, unable to start IDER
|
||||
obj.ider.onStateChanged = null;
|
||||
obj.ider.m.sectorStats = null;
|
||||
delete obj.ider;
|
||||
obj.close();
|
||||
break;
|
||||
// Floppy image selection
|
||||
xx = "<select style=width:240px id=xxFloppyImagesSelect><option value=''>None</option>";
|
||||
for (var i in floppyImages) { xx += "<option value='" + encodeURIComponent(floppyImages[i]) + "'" + (sel?" selected":"") + ">" + floppyImages[i] + "</option>"; sel = false; }
|
||||
xx += "</select>";
|
||||
html += "<div style=margin:5px>" + addHtmlValue("Floppy Image", xx) + "</div>";
|
||||
|
||||
// CDROM image selection
|
||||
sel = true;
|
||||
xx = "<select style=width:240px id=xxCdromImagesSelect><option value=''>None</option>";
|
||||
for (var i in cdromImages) { xx += "<option value='" + encodeURIComponent(cdromImages[i]) + "'" + (sel ? " selected" : "") + ">" + cdromImages[i] + "</option>"; sel = false; }
|
||||
xx += "</select>";
|
||||
html += "<div style=margin:5px>" + addHtmlValue("CDROM Image", xx) + "</div>";
|
||||
|
||||
// Start type
|
||||
xx = "<select style=width:240px id=xxIderStartType><option value=0>On next boot<option value=1>Graceful<option value=2>Immediate</select>";
|
||||
html += "<div style=margin:5px>" + addHtmlValue("Session Start", xx) + "</div>";
|
||||
|
||||
var js = "function iderServerCall() { return { ider: 1, floppyPath: Q('xxFloppyImagesSelect').value, cdromPath: Q('xxCdromImagesSelect').value, iderStart: Q('xxIderStartType').value }; }";
|
||||
|
||||
try { ws.send(JSON.stringify({ action: 'dialog', args: { html: html, js: js }, buttons: 3 })); } catch (ex) { }
|
||||
});
|
||||
} else {
|
||||
// No user folder
|
||||
try { ws.send(JSON.stringify({ action: 'dialog', args: { html: 'No disk images found on remote server. Upload .img and .iso files to server "My Files" folder to enable this feature.' }, buttons: 2 })); } catch (ex) { }
|
||||
}
|
||||
|
||||
// Start the IDER session
|
||||
obj.ider.Start(req.query.host, req.query.port, req.query.tls);
|
||||
break;
|
||||
}
|
||||
case 'dialogResponse': {
|
||||
if (command.args.ider == 1) { // Start IDER Session
|
||||
// Decode and validate file paths
|
||||
if ((command.args.floppyPath != null) && (typeof command.args.floppyPath != 'string')) { command.args.floppyPath = null; } else { command.args.floppyPath = decodeURIComponent(command.args.floppyPath); }
|
||||
if ((command.args.cdromPath != null) && (typeof command.args.cdromPath != 'string')) { command.args.cdromPath = null; } else { command.args.cdromPath = decodeURIComponent(command.args.cdromPath); }
|
||||
// TODO: Double check that "." or ".." are not used.
|
||||
if ((command.args.floppyPath != null) && (command.args.floppyPath.indexOf("..") >= 0)) { delete command.args.floppyPath; }
|
||||
if ((command.args.cdromPath != null) && (command.args.cdromPath.indexOf("..") >= 0)) { delete command.args.cdromPath; }
|
||||
|
||||
// Get the disk image paths
|
||||
var domainx = 'domain' + ((domain.id == '') ? '' : ('-' + domain.id));
|
||||
var useridx = user._id.split('/')[2];
|
||||
var floppyPath = null, cdromPath = null;
|
||||
if (command.args.floppyPath) { floppyPath = parent.parent.path.join(parent.parent.filespath, domainx, 'user-' + useridx, command.args.floppyPath); }
|
||||
if (command.args.cdromPath) { cdromPath = parent.parent.path.join(parent.parent.filespath, domainx, 'user-' + useridx, command.args.cdromPath); }
|
||||
|
||||
// Setup the IDER session
|
||||
obj.ider = amtMeshRedirModule.CreateAmtRedirect(amtMeshIderModule.CreateAmtRemoteIder(parent, parent.parent), domain, user, parent, parent.parent);
|
||||
obj.ider.onStateChanged = onIderStateChange;
|
||||
obj.ider.m.iderStart = command.args.iderStart;
|
||||
obj.ider.m.sectorStats = iderSectorStats;
|
||||
obj.ider.tlsv1only = req.query.tlsv1only;
|
||||
|
||||
// Setup disk images
|
||||
var iderError = obj.ider.m.diskSetup(floppyPath, cdromPath);
|
||||
|
||||
// Error with the disk images, unable to start IDER
|
||||
if (iderError != 0) { try { ws.send(JSON.stringify({ action: "error", code: iderError })); } catch (ex) { } break; }
|
||||
|
||||
// Start the IDER session
|
||||
obj.ider.Start(req.query.host, req.query.port, req.query.tls);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
@ -128,5 +171,27 @@ module.exports.CreateAmtIderSession = function (parent, db, ws, req, args, domai
|
||||
try { ws.send(JSON.stringify({ action: 'stats', mode: mode, dev: dev, total: total, start: start, len: len, toAmt: obj.ider.m.bytesToAmt, fromAmt: obj.ider.m.bytesFromAmt })); } catch (ex) { }
|
||||
}
|
||||
|
||||
// Recursivly read all of the files in a fonder
|
||||
function readFsRec(dir, func) {
|
||||
var results = [];
|
||||
fs.readdir(dir, function (err, list) {
|
||||
if (err) return func(err);
|
||||
var pending = list.length;
|
||||
if (!pending) return func(null, results);
|
||||
list.forEach(function (file) {
|
||||
file = path.resolve(dir, file);
|
||||
fs.stat(file, function (err, stat) {
|
||||
if (stat && stat.isDirectory()) {
|
||||
readFsRec(file, function (err, res) { results = results.concat(res); if (!--pending) func(null, results); });
|
||||
} else {
|
||||
results.push(file); if (!--pending) func(null, results);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
function addHtmlValue(t, v) { return '<div style=height:20px><div style=float:right;width:240px;overflow:hidden><b title="' + v + '">' + v + '</b></div><div>' + t + '</div></div>'; }
|
||||
|
||||
return obj;
|
||||
};
|
@ -34,39 +34,40 @@ e.iderinfo.minor=e.acc.charCodeAt(9);e.iderinfo.fwmajor=e.acc.charCodeAt(10);e.i
|
||||
e.Stop());0==e.iderStart?e.SendDisableEnableFeatures(3,IntToStrX(9)):1==e.iderStart?e.SendDisableEnableFeatures(3,IntToStrX(17)):2==e.iderStart&&e.SendDisableEnableFeatures(3,IntToStrX(25));return 30+a;case 67:return b("CLOSE"),e.Stop(),8;case 68:return e.SendCommand(69),8;case 69:return b("PONG"),8;case 70:if(9>e.acc.length)break;a=e.acc.charCodeAt(8);null===D?(e.SendCommand(71),b("RESETOCCURED1",a)):(z=!0,b("RESETOCCURED2",a));return 9;case 73:if(13>e.acc.length)break;var a=e.acc.charCodeAt(8),
|
||||
m=ReadIntX(e.acc,9);b("STATUS_DATA",a,m);switch(a){case 1:m&1&&(0==e.iderStart?e.SendDisableEnableFeatures(3,IntToStrX(9)):1==e.iderStart?e.SendDisableEnableFeatures(3,IntToStrX(17)):2==e.iderStart&&e.SendDisableEnableFeatures(3,IntToStrX(25)));break;case 2:e.enabled=m&2?!0:!1;b("IDER Status: "+e.enabled);break;case 3:1!=m&&b("Register toggle failure")}return 13;case 74:if(11>e.acc.length)break;b("IDER: ABORT",e.acc.charCodeAt(8));return 11;case 75:return 8;case 80:if(28>e.acc.length)break;var a=
|
||||
e.acc.charCodeAt(14)&16?176:160,m=e.acc.charCodeAt(14),g=e.acc.substring(16,28),y=e.acc.charCodeAt(9);b("SCSI_CMD",a,rstr2hex(g),y,m);c(a,g,y,m);return 28;case 83:if(14>e.acc.length)break;a=ReadShortX(e.acc,9);if(e.acc.length<14+a)break;b("SCSI_WRITE, len = "+(14+a));e.SendCommand(81,String.fromCharCode(0,0,0,0,0,0,0,0,0,0,0,0,135,112,3,0,0,0,160,81,7,39,0),!0);return 14+a;default:b("Unknown IDER command",e.acc[0]),e.Stop()}return 0};var z=!1,D=null,A,G,L;return e},CreateAmtRemoteServerIder=function(){function b(){urlvars&&
|
||||
urlvars.idertrace&&console.log.apply(console,[].concat($jscomp.arrayFromArguments(arguments)))}var c={protocol:4,iderStart:0,floppy:null,cdrom:null,state:0,onStateChanged:null,m:{sectorStats:null,onDialogPrompt:null,dialogPrompt:function(a){console.log("dialogPromptResponse",a);c.socket.send(JSON.stringify({action:"selectorResponse",args:a}))},bytesToAmt:0,bytesFromAmt:0,server:!0,Stop:function(){c.Stop()}},xxStateChange:function(a){if(c.state!=a&&(b("SIDER-StateChange",a),c.state=a,null!=c.onStateChanged))c.onStateChanged(c,
|
||||
c.state)},Start:function(a,d,e,n,p){b("SIDER-Start",a,d,e,n,p);c.host=a;c.port=d;c.user=e;c.pass=n;c.connectstate=0;c.socket=new WebSocket(window.location.protocol.replace("http","ws")+"//"+window.location.host+window.location.pathname.substring(0,window.location.pathname.lastIndexOf("/"))+"/webider.ashx?host="+a+"&port="+d+"&tls="+p+("*"==e?"&serverauth=1":"")+("undefined"===typeof n?"&serverauth=1&user="+e:"")+"&tls1only="+c.tlsv1only);c.socket.onopen=c.xxOnSocketConnected;c.socket.onmessage=c.xxOnMessage;
|
||||
c.socket.onclose=c.xxOnSocketClosed;c.xxStateChange(1)},Stop:function(){b("SIDER-Stop");null!=c.socket&&(c.socket.close(),c.socket=null);c.xxStateChange(0)},xxOnSocketConnected:function(){c.xxStateChange(2);c.socket.send(JSON.stringify({action:"selector"}))},xxOnMessage:function(a){var b=null;try{b=JSON.parse(a.data)}catch(e){}if(null!=b&&"string"==typeof b.action)switch(b.action){case "selector":if(null!=c.m.onDialogPrompt)c.m.onDialogPrompt(c,b.args,b.buttons);break;case "state":2==b.state&&c.xxStateChange(3);
|
||||
break;case "stats":c.m.bytesToAmt=b.toAmt;c.m.bytesFromAmt=b.fromAmt;c.m.sectorStats&&c.m.sectorStats(b.mode,b.dev,b.total,b.start,b.len);break;default:console.log("Unknown Server IDER action: "+b.action),breal}},xxOnSocketClosed:function(){c.Stop()}};return c},CreateWsmanComm=function(b,c,a,d,e){function n(){g.socketState=2;g.socketParseState=0;g.socketAccumulator="";g.socketHeader=null;g.socketData="";for(i in g.pendingAjaxCall)g.sendRequest(g.pendingAjaxCall[i][0],g.pendingAjaxCall[i][3],g.pendingAjaxCall[i][4])}
|
||||
function p(a){if("object"==typeof a.data)if(1==l)v.push(a.data);else if(w.readAsBinaryString)l=!0,w.readAsBinaryString(new Blob([a.data]));else if(w.readAsArrayBuffer)l=!0,w.readAsArrayBuffer(a.data);else{var b="";a=new Uint8Array(a.data);for(var c=a.byteLength,m=0;m<c;m++)b+=String.fromCharCode(a[m]);r(b)}else r(a.data)}function r(a){if("object"===typeof a){var b="";a=new Uint8Array(a);for(var c=a.byteLength,m=0;m<c;m++)b+=String.fromCharCode(a[m]);a=b}else if("string"!==typeof a)return;for(g.socketAccumulator+=
|
||||
a;;){if(0==g.socketParseState){a=g.socketAccumulator.indexOf("\r\n\r\n");if(0>a)break;g.socketHeader=g.socketAccumulator.substring(0,a).split("\r\n");if(null==g.amtVersion)for(m in g.socketHeader)0==g.socketHeader[m].indexOf("Server: Intel(R) Active Management Technology ")&&(g.amtVersion=g.socketHeader[m].substring(46));g.socketAccumulator=g.socketAccumulator.substring(a+4);g.socketParseState=1;g.socketData="";g.socketXHeader={Directive:g.socketHeader[0].split(" ")};for(m in g.socketHeader)0!=m&&
|
||||
(a=g.socketHeader[m].indexOf(":"),g.socketXHeader[g.socketHeader[m].substring(0,a).toLowerCase()]=g.socketHeader[m].substring(a+2))}if(1==g.socketParseState){b=-1;if(void 0==g.socketXHeader.connection||"close"!=g.socketXHeader.connection.toLowerCase()||void 0!=g.socketXHeader["transfer-encoding"]&&"chunked"==g.socketXHeader["transfer-encoding"].toLowerCase())if(void 0!=g.socketXHeader["content-length"]){b=parseInt(g.socketXHeader["content-length"]);if(g.socketAccumulator.length<b)break;a=g.socketAccumulator.substring(0,
|
||||
b);g.socketAccumulator=g.socketAccumulator.substring(b);g.socketData=a;b=0}else{c=g.socketAccumulator.indexOf("\r\n");if(0>c)break;b=parseInt(g.socketAccumulator.substring(0,c),16);if(isNaN(b)){g.websocket&&g.websocket.close();break}if(g.socketAccumulator.length<c+2+b+2)break;a=g.socketAccumulator.substring(c+2,c+2+b);g.socketAccumulator=g.socketAccumulator.substring(c+2+b+2);g.socketData+=a}else b=0;0==b&&(c=g.socketXHeader,a=g.socketData,b=parseInt(c.Directive[1]),isNaN(b)&&(b=602),401==b&&3>++g.authcounter?
|
||||
g.challengeParams=g.parseDigest(c["www-authenticate"]):(c=g.pendingAjaxCall.shift(),g.authcounter=0,g.ActiveAjaxCount--,g.gotNextMessages(a,"success",{status:b},c),g.PerformNextAjax()),g.socketParseState=0,g.socketHeader=null)}}}function m(a){0==g.inDataCount&&(g.tlsv1only=1-g.tlsv1only);g.socketState=0;null!=g.socket&&(g.socket.close(),g.socket=null);if(0<g.pendingAjaxCall.length){a=g.pendingAjaxCall.shift();var b=a[5];g.PerformAjaxExNodeJS2(a[0],a[1],a[2],a[3],a[4],--b)}}var g={PendingAjax:[],ActiveAjaxCount:0,
|
||||
MaxActiveAjaxCount:1,FailAllError:0,challengeParams:null,noncecounter:1,authcounter:0,socket:null,socketState:0};g.host=b;g.port=c;g.user=a;g.pass=d;g.tls=e;g.tlsv1only=0;g.cnonce=Math.random().toString(36).substring(7);g.inDataCount=0;g.amtVersion=null;g.PerformAjax=function(a,b,c,m,d,e){g.ActiveAjaxCount<g.MaxActiveAjaxCount&&0==g.PendingAjax.length?g.PerformAjaxEx(a,b,c,d,e):1==m?g.PendingAjax.unshift([a,b,c,d,e]):g.PendingAjax.push([a,b,c,d,e])};g.PerformNextAjax=function(){if(!(g.ActiveAjaxCount>=
|
||||
g.MaxActiveAjaxCount||0==g.PendingAjax.length)){var a=g.PendingAjax.shift();g.PerformAjaxEx(a[0],a[1],a[2],a[3],a[4]);g.PerformNextAjax()}};g.PerformAjaxEx=function(a,b,c,m,d){if(0!=g.FailAllError)g.gotNextMessagesError({status:g.FailAllError},"error",null,[a,b,c,m,d]);else return a||(a=""),g.ActiveAjaxCount++,g.PerformAjaxExNodeJS(a,b,c,m,d)};g.pendingAjaxCall=[];g.PerformAjaxExNodeJS=function(a,b,c,m,d){g.PerformAjaxExNodeJS2(a,b,c,m,d,3)};g.PerformAjaxExNodeJS2=function(a,b,c,m,d,e){0>=e||0!=g.FailAllError?
|
||||
(g.ActiveAjaxCount--,999!=g.FailAllError&&g.gotNextMessages(null,"error",{status:0==g.FailAllError?408:g.FailAllError},[a,b,c,m,d]),g.PerformNextAjax()):(g.pendingAjaxCall.push([a,b,c,m,d,e]),0==g.socketState?g.xxConnectHttpSocket():2==g.socketState&&g.sendRequest(a,m,d))};g.sendRequest=function(a,b,c){b=b?b:"/wsman";c=c?c:"POST";var m=c+" "+b+" HTTP/1.1\r\n";null!=g.challengeParams&&(c=hex_md5(hex_md5(g.user+":"+g.challengeParams.realm+":"+g.pass)+":"+g.challengeParams.nonce+":"+g.noncecounter+":"+
|
||||
g.cnonce+":"+g.challengeParams.qop+":"+hex_md5(c+":"+b)),m+="Authorization: "+g.renderDigest({username:g.user,realm:g.challengeParams.realm,nonce:g.challengeParams.nonce,uri:b,qop:g.challengeParams.qop,response:c,nc:g.noncecounter++,cnonce:g.cnonce})+"\r\n");a=m+="Host: "+g.host+":"+g.port+"\r\nContent-Length: "+a.length+"\r\n\r\n"+a;if(2==g.socketState&&null!=g.socket&&g.socket.readyState==WebSocket.OPEN){b=new Uint8Array(a.length);for(m=0;m<a.length;++m)b[m]=a.charCodeAt(m);try{g.socket.send(b.buffer)}catch(d){}}};
|
||||
g.parseDigest=function(a){a=a.substring(7).split(",");for(i in a)a[i]=a[i].trim();return a.reduce(function(a,b){var c=b.split("=");a[c[0]]=c[1].replace(/"/g,"");return a},{})};g.renderDigest=function(a){var b=[];for(i in a)b.push(i);return"Digest "+b.reduce(function(b,c){return b+","+c+'="'+a[c]+'"'},"").substring(1)};g.xxConnectHttpSocket=function(){g.inDataCount=0;g.socketState=1;g.socket=new WebSocket(window.location.protocol.replace("http","ws")+"//"+window.location.host+window.location.pathname.substring(0,
|
||||
window.location.pathname.lastIndexOf("/"))+"/webrelay.ashx?p=1&host="+g.host+"&port="+g.port+"&tls="+g.tls+"&tls1only="+g.tlsv1only+("*"==a?"&serverauth=1":"")+("undefined"===typeof d?"&serverauth=1&user="+a:""));g.socket.onopen=n;g.socket.onmessage=p;g.socket.onclose=m};var w=new FileReader,l=!1,v=[];w.readAsBinaryString?w.onload=function(a){r(a.target.result);0==v.length?l=!1:w.readAsBinaryString(new Blob([v.shift()]))}:w.readAsArrayBuffer&&(w.onloadend=function(a){r(a.target.result);0==v.length?
|
||||
l=!1:w.readAsArrayBuffer(v.shift())});g.gotNextMessages=function(a,b,c,m){if(999!=g.FailAllError)if(0!=g.FailAllError)m[1](null,g.FailAllError,m[2]);else if(200!=c.status)m[1](null,c.status,m[2]);else m[1](a,200,m[2])};g.gotNextMessagesError=function(a,b,c,m){if(999!=g.FailAllError)if(0!=g.FailAllError)m[1](null,g.FailAllError,m[2]);else m[1](g,null,{Header:{HttpError:a.status}},a.status,m[2])};g.CancelAllQueries=function(a){for(;0<g.PendingAjax.length;){var b=g.PendingAjax.shift();b[1](null,a,b[2])}null!=
|
||||
g.websocket&&(g.websocket.close(),g.websocket=null,g.socketState=0)};return g},CreateAmtRedirect=function(b){var c={};c.m=b;b.parent=c;c.State=0;c.socket=null;c.host=null;c.port=0;c.user=null;c.pass=null;c.authuri="/RedirectionService";c.tlsv1only=0;c.connectstate=0;c.protocol=b.protocol;c.amtaccumulator="";c.amtsequence=1;c.amtkeepalivetimer=null;c.onStateChanged=null;c.Start=function(a,b,d,m,g){c.host=a;c.port=b;c.user=d;c.pass=m;c.connectstate=0;c.socket=new WebSocket(window.location.protocol.replace("http",
|
||||
"ws")+"//"+window.location.host+window.location.pathname.substring(0,window.location.pathname.lastIndexOf("/"))+"/webrelay.ashx?p=2&host="+a+"&port="+b+"&tls="+g+("*"==d?"&serverauth=1":"")+("undefined"===typeof m?"&serverauth=1&user="+d:"")+"&tls1only="+c.tlsv1only);c.socket.onopen=c.xxOnSocketConnected;c.socket.onmessage=c.xxOnMessage;c.socket.onclose=c.xxOnSocketClosed;c.xxStateChange(1)};c.xxOnSocketConnected=function(){urlvars&&urlvars.redirtrace&&console.log("REDIR-CONNECT");c.xxStateChange(2);
|
||||
1==c.protocol&&c.xxSend(c.RedirectStartSol);2==c.protocol&&c.xxSend(c.RedirectStartKvm);3==c.protocol&&c.xxSend(c.RedirectStartIder)};var a=new FileReader,d=!1,e=[];a.readAsBinaryString?a.onload=function(b){c.xxOnSocketData(b.target.result);0==e.length?d=!1:a.readAsBinaryString(new Blob([e.shift()]))}:a.readAsArrayBuffer&&(a.onloadend=function(b){c.xxOnSocketData(b.target.result);0==e.length?d=!1:a.readAsArrayBuffer(e.shift())});c.xxOnMessage=function(b){c.inDataCount++;if("object"==typeof b.data)if(1==
|
||||
d)e.push(b.data);else if(a.readAsBinaryString)d=!0,a.readAsBinaryString(new Blob([b.data]));else if(f.readAsArrayBuffer)d=!0,a.readAsArrayBuffer(b.data);else{var p="";b=new Uint8Array(b.data);for(var r=b.byteLength,m=0;m<r;m++)p+=String.fromCharCode(b[m]);c.xxOnSocketData(p)}else c.xxOnSocketData(b.data)};c.xxOnSocketData=function(a){if(a&&-1!=c.connectstate){if("object"===typeof a){var b="",d=new Uint8Array(a),m=d.byteLength;for(a=0;a<m;a++)b+=String.fromCharCode(d[a]);a=b}else if("string"!==typeof a)return;
|
||||
if((2==c.protocol||3==c.protocol)&&1==c.connectstate)return c.m.ProcessData(a);c.amtaccumulator+=a;for(urlvars&&urlvars.redirtrace&&console.log("REDIR-RECV("+c.amtaccumulator.length+"): "+rstr2hex(c.amtaccumulator));1<=c.amtaccumulator.length;){a=0;switch(c.amtaccumulator.charCodeAt(0)){case 17:if(4>c.amtaccumulator.length)return;switch(c.amtaccumulator.charCodeAt(1)){case 0:if(13>c.amtaccumulator.length)return;b=c.amtaccumulator.charCodeAt(12);if(c.amtaccumulator.length<13+b)return;c.xxSend(String.fromCharCode(19,
|
||||
0,0,0,0,0,0,0,0));a=13+b;break;default:c.Stop()}break;case 20:if(9>c.amtaccumulator.length)return;var g=ReadIntX(c.amtaccumulator,5);if(c.amtaccumulator.length<9+g)return;var m=c.amtaccumulator.charCodeAt(1),b=c.amtaccumulator.charCodeAt(4),e=[];for(a=0;a<g;a++)e.push(c.amtaccumulator.charCodeAt(9+a));d=c.amtaccumulator.substring(9,9+g);a=9+g;if(0==b)0<=e.indexOf(4)?c.xxSend(String.fromCharCode(19,0,0,0,4)+IntToStrX(c.user.length+c.authuri.length+8)+String.fromCharCode(c.user.length)+c.user+String.fromCharCode(0,
|
||||
0)+String.fromCharCode(c.authuri.length)+c.authuri+String.fromCharCode(0,0,0,0)):0<=e.indexOf(3)?c.xxSend(String.fromCharCode(19,0,0,0,3)+IntToStrX(c.user.length+c.authuri.length+7)+String.fromCharCode(c.user.length)+c.user+String.fromCharCode(0,0)+String.fromCharCode(c.authuri.length)+c.authuri+String.fromCharCode(0,0,0)):0<=e.indexOf(1)?c.xxSend(String.fromCharCode(19,0,0,0,1)+IntToStrX(c.user.length+c.pass.length+2)+String.fromCharCode(c.user.length)+c.user+String.fromCharCode(c.pass.length)+c.pass):
|
||||
c.Stop();else if(3!=b&&4!=b||1!=m)0==m?(1==c.protocol&&c.xxSend(String.fromCharCode(32,0,0,0)+IntToStrX(c.amtsequence++)+ShortToStrX(1E4)+ShortToStrX(100)+ShortToStrX(0)+ShortToStrX(1E4)+ShortToStrX(100)+ShortToStrX(0)+IntToStrX(0)),2==c.protocol&&c.xxSend(String.fromCharCode(64,0,0,0,0,0,0,0)),3==c.protocol&&(c.connectstate=1,c.xxStateChange(3))):c.Stop();else{var g=0,e=d.charCodeAt(g),m=d.substring(g+1,g+1+e),g=g+(e+1),l=d.charCodeAt(g),e=d.substring(g+1,g+1+l),g=g+(l+1),l=0,l=null,v=c.xxRandomNonce(32),
|
||||
x="";4==b&&(l=d.charCodeAt(g),l=d.substring(g+1,g+1+l),x="00000002:"+v+":"+l+":");d=hex_md5(hex_md5(c.user+":"+m+":"+c.pass)+":"+e+":"+x+hex_md5("POST:"+c.authuri));g=c.user.length+m.length+e.length+c.authuri.length+v.length+8+d.length+7;4==b&&(g+=l.length+1);d=String.fromCharCode(19,0,0,0,b)+IntToStrX(g)+String.fromCharCode(c.user.length)+c.user+String.fromCharCode(m.length)+m+String.fromCharCode(e.length)+e+String.fromCharCode(c.authuri.length)+c.authuri+String.fromCharCode(v.length)+v+String.fromCharCode(8)+
|
||||
"00000002"+String.fromCharCode(d.length)+d;4==b&&(d+=String.fromCharCode(l.length)+l);c.xxSend(d)}break;case 33:if(23>c.amtaccumulator.length)break;a=23;c.xxSend(String.fromCharCode(39,0,0,0)+IntToStrX(c.amtsequence++)+String.fromCharCode(0,0,27,0,0,0));1==c.protocol&&(c.amtkeepalivetimer=setInterval(c.xxSendAmtKeepAlive,2E3));c.connectstate=1;c.xxStateChange(3);break;case 41:if(10>c.amtaccumulator.length)break;a=10;break;case 42:if(10>c.amtaccumulator.length)break;b=10+((c.amtaccumulator.charCodeAt(9)&
|
||||
255)<<8)+(c.amtaccumulator.charCodeAt(8)&255);if(c.amtaccumulator.length<b)break;c.m.ProcessData(c.amtaccumulator.substring(10,b));a=b;break;case 43:if(8>c.amtaccumulator.length)break;a=8;break;case 65:if(8>c.amtaccumulator.length)break;c.connectstate=1;c.m.Start();8<c.amtaccumulator.length&&c.m.ProcessData(c.amtaccumulator.substring(8));a=c.amtaccumulator.length;break;default:console.log("Unknown Intel AMT command: "+c.amtaccumulator.charCodeAt(0)+" acclen="+c.amtaccumulator.length);c.Stop();return}if(0==
|
||||
a)break;c.amtaccumulator=c.amtaccumulator.substring(a)}}};c.xxSend=function(a){urlvars&&urlvars.redirtrace&&console.log("REDIR-SEND("+a.length+"): "+rstr2hex(a));if(null!=c.socket&&c.socket.readyState==WebSocket.OPEN){for(var b=new Uint8Array(a.length),d=0;d<a.length;++d)b[d]=a.charCodeAt(d);c.socket.send(b.buffer)}};c.Send=function(a){null!=c.socket&&1==c.connectstate&&(1==c.protocol?c.xxSend(String.fromCharCode(40,0,0,0)+IntToStrX(c.amtsequence++)+ShortToStrX(a.length)+a):c.xxSend(a))};c.xxSendAmtKeepAlive=
|
||||
function(){null!=c.socket&&c.xxSend(String.fromCharCode(43,0,0,0)+IntToStrX(c.amtsequence++))};c.xxRandomNonceX="abcdef0123456789";c.xxRandomNonce=function(a){for(var b="",d=0;d<a;d++)b+=c.xxRandomNonceX.charAt(Math.floor(Math.random()*c.xxRandomNonceX.length));return b};c.xxOnSocketClosed=function(){urlvars&&urlvars.redirtrace&&console.log("REDIR-CLOSED");c.Stop()};c.xxStateChange=function(a){if(c.State!=a&&(c.State=a,c.m.xxStateChange(c.State),null!=c.onStateChanged))c.onStateChanged(c,c.State)};
|
||||
c.Stop=function(){c.xxStateChange(0);c.connectstate=-1;c.amtaccumulator="";null!=c.socket&&(c.socket.close(),c.socket=null);null!=c.amtkeepalivetimer&&(clearInterval(c.amtkeepalivetimer),c.amtkeepalivetimer=null)};c.RedirectStartSol=String.fromCharCode(16,0,0,0,83,79,76,32);c.RedirectStartKvm=String.fromCharCode(16,1,0,0,75,86,77,82);c.RedirectStartIder=String.fromCharCode(16,0,0,0,73,68,69,82);return c},WsmanStackCreateService=function(b,c,a,d,e,n){function p(a){for(var b,c={},m=0;m<a.childNodes.length;m++){var g=
|
||||
a.childNodes[m];b=null==g.childElementCount||0==g.childElementCount?g.textContent:p(g);"true"==b&&(b=!0);"false"==b&&(b=!1);parseInt(b)+""===b&&(b=parseInt(b));var h=b;if(null!=g.attributes&&0<g.attributes.length)for(h={Value:b},b=0;b<g.attributes.length;b++)h["@"+g.attributes[b].name]=g.attributes[b].value;c[g.localName]instanceof Array?c[g.localName].push(h):c[g.localName]=null==c[g.localName]?h:[c[g.localName],h]}return c}function r(a){if(!a)return"";var b="",c;for(c in a)a.hasOwnProperty(c)&&
|
||||
0===c.indexOf("@")&&(b+=" "+c.substring(1)+'="'+a[c]+'"');return b}function m(a){if(!a)return"";if("string"==typeof a)return a;if(a.InstanceID)return'<w:SelectorSet><w:Selector Name="InstanceID">'+a.InstanceID+"</w:Selector></w:SelectorSet>";var b="<w:SelectorSet>",c;for(c in a)if(a.hasOwnProperty(c)){b+='<w:Selector Name="'+c+'">';if(a[c].ReferenceParameters){var b=b+"<a:EndpointReference>",b=b+("<a:Address>"+a[c].Address+"</a:Address><a:ReferenceParameters><w:ResourceURI>"+a[c].ReferenceParameters.ResourceURI+
|
||||
"</w:ResourceURI><w:SelectorSet>"),m=a[c].ReferenceParameters.SelectorSet.Selector;if(Array.isArray(m))for(var g=0;g<m.length;g++)b+="<w:Selector"+r(m[g])+">"+m[g].Value+"</w:Selector>";else b+="<w:Selector"+r(m)+">"+m.Value+"</w:Selector>";b+="</w:SelectorSet></a:ReferenceParameters></a:EndpointReference>"}else b+=a[c];b+="</w:Selector>"}return b+"</w:SelectorSet>"}var g={NextMessageId:1,Address:"/wsman"};g.comm=CreateWsmanComm(b,c,a,d,e,n);g.PerformAjax=function(a,b,c,m,d){null==d&&(d="");g.comm.PerformAjax('<?xml version="1.0" encoding="utf-8"?><Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:a="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:w="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd" xmlns="http://www.w3.org/2003/05/soap-envelope" '+
|
||||
urlvars.idertrace&&console.log.apply(console,[].concat($jscomp.arrayFromArguments(arguments)))}var c={protocol:4,iderStart:0,floppy:null,cdrom:null,state:0,onStateChanged:null,m:{sectorStats:null,onDialogPrompt:null,dialogPrompt:function(a){c.socket.send(JSON.stringify({action:"dialogResponse",args:a}))},bytesToAmt:0,bytesFromAmt:0,server:!0,Stop:function(){c.Stop()}},xxStateChange:function(a){if(c.state!=a&&(b("SIDER-StateChange",a),c.state=a,null!=c.onStateChanged))c.onStateChanged(c,c.state)},
|
||||
Start:function(a,d,e,n,p){b("SIDER-Start",a,d,e,n,p);c.host=a;c.port=d;c.user=e;c.pass=n;c.connectstate=0;c.socket=new WebSocket(window.location.protocol.replace("http","ws")+"//"+window.location.host+window.location.pathname.substring(0,window.location.pathname.lastIndexOf("/"))+"/webider.ashx?host="+a+"&port="+d+"&tls="+p+("*"==e?"&serverauth=1":"")+("undefined"===typeof n?"&serverauth=1&user="+e:"")+"&tls1only="+c.tlsv1only);c.socket.onopen=c.xxOnSocketConnected;c.socket.onmessage=c.xxOnMessage;
|
||||
c.socket.onclose=c.xxOnSocketClosed;c.xxStateChange(1)},Stop:function(){b("SIDER-Stop");null!=c.socket&&(c.socket.close(),c.socket=null);c.xxStateChange(0)},xxOnSocketConnected:function(){c.xxStateChange(2);c.socket.send(JSON.stringify({action:"start"}))},xxOnMessage:function(a){var b=null;try{b=JSON.parse(a.data)}catch(e){}if(null!=b&&"string"==typeof b.action)switch(b.action){case "dialog":if(null!=c.m.onDialogPrompt)c.m.onDialogPrompt(c,b.args,b.buttons);break;case "state":2==b.state&&c.xxStateChange(3);
|
||||
break;case "stats":c.m.bytesToAmt=b.toAmt;c.m.bytesFromAmt=b.fromAmt;c.m.sectorStats&&c.m.sectorStats(b.mode,b.dev,b.total,b.start,b.len);break;case "error":console.log("IDER Error: "+";Floppy disk image does not exist;Invalid floppy disk image;Unable to open floppy disk image;CDROM disk image does not exist;Invalid CDROM disk image;Unable to open CDROM disk image;Can't perform IDER with no disk images".split(";")[b.code]);break;default:console.log("Unknown Server IDER action: "+b.action),breal}},
|
||||
xxOnSocketClosed:function(){c.Stop()}};return c},CreateWsmanComm=function(b,c,a,d,e){function n(){g.socketState=2;g.socketParseState=0;g.socketAccumulator="";g.socketHeader=null;g.socketData="";for(i in g.pendingAjaxCall)g.sendRequest(g.pendingAjaxCall[i][0],g.pendingAjaxCall[i][3],g.pendingAjaxCall[i][4])}function p(a){if("object"==typeof a.data)if(1==l)v.push(a.data);else if(w.readAsBinaryString)l=!0,w.readAsBinaryString(new Blob([a.data]));else if(w.readAsArrayBuffer)l=!0,w.readAsArrayBuffer(a.data);
|
||||
else{var b="";a=new Uint8Array(a.data);for(var c=a.byteLength,m=0;m<c;m++)b+=String.fromCharCode(a[m]);r(b)}else r(a.data)}function r(a){if("object"===typeof a){var b="";a=new Uint8Array(a);for(var c=a.byteLength,m=0;m<c;m++)b+=String.fromCharCode(a[m]);a=b}else if("string"!==typeof a)return;for(g.socketAccumulator+=a;;){if(0==g.socketParseState){a=g.socketAccumulator.indexOf("\r\n\r\n");if(0>a)break;g.socketHeader=g.socketAccumulator.substring(0,a).split("\r\n");if(null==g.amtVersion)for(m in g.socketHeader)0==
|
||||
g.socketHeader[m].indexOf("Server: Intel(R) Active Management Technology ")&&(g.amtVersion=g.socketHeader[m].substring(46));g.socketAccumulator=g.socketAccumulator.substring(a+4);g.socketParseState=1;g.socketData="";g.socketXHeader={Directive:g.socketHeader[0].split(" ")};for(m in g.socketHeader)0!=m&&(a=g.socketHeader[m].indexOf(":"),g.socketXHeader[g.socketHeader[m].substring(0,a).toLowerCase()]=g.socketHeader[m].substring(a+2))}if(1==g.socketParseState){b=-1;if(void 0==g.socketXHeader.connection||
|
||||
"close"!=g.socketXHeader.connection.toLowerCase()||void 0!=g.socketXHeader["transfer-encoding"]&&"chunked"==g.socketXHeader["transfer-encoding"].toLowerCase())if(void 0!=g.socketXHeader["content-length"]){b=parseInt(g.socketXHeader["content-length"]);if(g.socketAccumulator.length<b)break;a=g.socketAccumulator.substring(0,b);g.socketAccumulator=g.socketAccumulator.substring(b);g.socketData=a;b=0}else{c=g.socketAccumulator.indexOf("\r\n");if(0>c)break;b=parseInt(g.socketAccumulator.substring(0,c),16);
|
||||
if(isNaN(b)){g.websocket&&g.websocket.close();break}if(g.socketAccumulator.length<c+2+b+2)break;a=g.socketAccumulator.substring(c+2,c+2+b);g.socketAccumulator=g.socketAccumulator.substring(c+2+b+2);g.socketData+=a}else b=0;0==b&&(c=g.socketXHeader,a=g.socketData,b=parseInt(c.Directive[1]),isNaN(b)&&(b=602),401==b&&3>++g.authcounter?g.challengeParams=g.parseDigest(c["www-authenticate"]):(c=g.pendingAjaxCall.shift(),g.authcounter=0,g.ActiveAjaxCount--,g.gotNextMessages(a,"success",{status:b},c),g.PerformNextAjax()),
|
||||
g.socketParseState=0,g.socketHeader=null)}}}function m(a){0==g.inDataCount&&(g.tlsv1only=1-g.tlsv1only);g.socketState=0;null!=g.socket&&(g.socket.close(),g.socket=null);if(0<g.pendingAjaxCall.length){a=g.pendingAjaxCall.shift();var b=a[5];g.PerformAjaxExNodeJS2(a[0],a[1],a[2],a[3],a[4],--b)}}var g={PendingAjax:[],ActiveAjaxCount:0,MaxActiveAjaxCount:1,FailAllError:0,challengeParams:null,noncecounter:1,authcounter:0,socket:null,socketState:0};g.host=b;g.port=c;g.user=a;g.pass=d;g.tls=e;g.tlsv1only=
|
||||
0;g.cnonce=Math.random().toString(36).substring(7);g.inDataCount=0;g.amtVersion=null;g.PerformAjax=function(a,b,c,m,d,e){g.ActiveAjaxCount<g.MaxActiveAjaxCount&&0==g.PendingAjax.length?g.PerformAjaxEx(a,b,c,d,e):1==m?g.PendingAjax.unshift([a,b,c,d,e]):g.PendingAjax.push([a,b,c,d,e])};g.PerformNextAjax=function(){if(!(g.ActiveAjaxCount>=g.MaxActiveAjaxCount||0==g.PendingAjax.length)){var a=g.PendingAjax.shift();g.PerformAjaxEx(a[0],a[1],a[2],a[3],a[4]);g.PerformNextAjax()}};g.PerformAjaxEx=function(a,
|
||||
b,c,m,d){if(0!=g.FailAllError)g.gotNextMessagesError({status:g.FailAllError},"error",null,[a,b,c,m,d]);else return a||(a=""),g.ActiveAjaxCount++,g.PerformAjaxExNodeJS(a,b,c,m,d)};g.pendingAjaxCall=[];g.PerformAjaxExNodeJS=function(a,b,c,m,d){g.PerformAjaxExNodeJS2(a,b,c,m,d,3)};g.PerformAjaxExNodeJS2=function(a,b,c,m,d,e){0>=e||0!=g.FailAllError?(g.ActiveAjaxCount--,999!=g.FailAllError&&g.gotNextMessages(null,"error",{status:0==g.FailAllError?408:g.FailAllError},[a,b,c,m,d]),g.PerformNextAjax()):
|
||||
(g.pendingAjaxCall.push([a,b,c,m,d,e]),0==g.socketState?g.xxConnectHttpSocket():2==g.socketState&&g.sendRequest(a,m,d))};g.sendRequest=function(a,b,c){b=b?b:"/wsman";c=c?c:"POST";var m=c+" "+b+" HTTP/1.1\r\n";null!=g.challengeParams&&(c=hex_md5(hex_md5(g.user+":"+g.challengeParams.realm+":"+g.pass)+":"+g.challengeParams.nonce+":"+g.noncecounter+":"+g.cnonce+":"+g.challengeParams.qop+":"+hex_md5(c+":"+b)),m+="Authorization: "+g.renderDigest({username:g.user,realm:g.challengeParams.realm,nonce:g.challengeParams.nonce,
|
||||
uri:b,qop:g.challengeParams.qop,response:c,nc:g.noncecounter++,cnonce:g.cnonce})+"\r\n");a=m+="Host: "+g.host+":"+g.port+"\r\nContent-Length: "+a.length+"\r\n\r\n"+a;if(2==g.socketState&&null!=g.socket&&g.socket.readyState==WebSocket.OPEN){b=new Uint8Array(a.length);for(m=0;m<a.length;++m)b[m]=a.charCodeAt(m);try{g.socket.send(b.buffer)}catch(d){}}};g.parseDigest=function(a){a=a.substring(7).split(",");for(i in a)a[i]=a[i].trim();return a.reduce(function(a,b){var c=b.split("=");a[c[0]]=c[1].replace(/"/g,
|
||||
"");return a},{})};g.renderDigest=function(a){var b=[];for(i in a)b.push(i);return"Digest "+b.reduce(function(b,c){return b+","+c+'="'+a[c]+'"'},"").substring(1)};g.xxConnectHttpSocket=function(){g.inDataCount=0;g.socketState=1;g.socket=new WebSocket(window.location.protocol.replace("http","ws")+"//"+window.location.host+window.location.pathname.substring(0,window.location.pathname.lastIndexOf("/"))+"/webrelay.ashx?p=1&host="+g.host+"&port="+g.port+"&tls="+g.tls+"&tls1only="+g.tlsv1only+("*"==a?"&serverauth=1":
|
||||
"")+("undefined"===typeof d?"&serverauth=1&user="+a:""));g.socket.onopen=n;g.socket.onmessage=p;g.socket.onclose=m};var w=new FileReader,l=!1,v=[];w.readAsBinaryString?w.onload=function(a){r(a.target.result);0==v.length?l=!1:w.readAsBinaryString(new Blob([v.shift()]))}:w.readAsArrayBuffer&&(w.onloadend=function(a){r(a.target.result);0==v.length?l=!1:w.readAsArrayBuffer(v.shift())});g.gotNextMessages=function(a,b,c,m){if(999!=g.FailAllError)if(0!=g.FailAllError)m[1](null,g.FailAllError,m[2]);else if(200!=
|
||||
c.status)m[1](null,c.status,m[2]);else m[1](a,200,m[2])};g.gotNextMessagesError=function(a,b,c,m){if(999!=g.FailAllError)if(0!=g.FailAllError)m[1](null,g.FailAllError,m[2]);else m[1](g,null,{Header:{HttpError:a.status}},a.status,m[2])};g.CancelAllQueries=function(a){for(;0<g.PendingAjax.length;){var b=g.PendingAjax.shift();b[1](null,a,b[2])}null!=g.websocket&&(g.websocket.close(),g.websocket=null,g.socketState=0)};return g},CreateAmtRedirect=function(b){var c={};c.m=b;b.parent=c;c.State=0;c.socket=
|
||||
null;c.host=null;c.port=0;c.user=null;c.pass=null;c.authuri="/RedirectionService";c.tlsv1only=0;c.connectstate=0;c.protocol=b.protocol;c.amtaccumulator="";c.amtsequence=1;c.amtkeepalivetimer=null;c.onStateChanged=null;c.Start=function(a,b,d,m,g){c.host=a;c.port=b;c.user=d;c.pass=m;c.connectstate=0;c.socket=new WebSocket(window.location.protocol.replace("http","ws")+"//"+window.location.host+window.location.pathname.substring(0,window.location.pathname.lastIndexOf("/"))+"/webrelay.ashx?p=2&host="+
|
||||
a+"&port="+b+"&tls="+g+("*"==d?"&serverauth=1":"")+("undefined"===typeof m?"&serverauth=1&user="+d:"")+"&tls1only="+c.tlsv1only);c.socket.onopen=c.xxOnSocketConnected;c.socket.onmessage=c.xxOnMessage;c.socket.onclose=c.xxOnSocketClosed;c.xxStateChange(1)};c.xxOnSocketConnected=function(){urlvars&&urlvars.redirtrace&&console.log("REDIR-CONNECT");c.xxStateChange(2);1==c.protocol&&c.xxSend(c.RedirectStartSol);2==c.protocol&&c.xxSend(c.RedirectStartKvm);3==c.protocol&&c.xxSend(c.RedirectStartIder)};var a=
|
||||
new FileReader,d=!1,e=[];a.readAsBinaryString?a.onload=function(b){c.xxOnSocketData(b.target.result);0==e.length?d=!1:a.readAsBinaryString(new Blob([e.shift()]))}:a.readAsArrayBuffer&&(a.onloadend=function(b){c.xxOnSocketData(b.target.result);0==e.length?d=!1:a.readAsArrayBuffer(e.shift())});c.xxOnMessage=function(b){c.inDataCount++;if("object"==typeof b.data)if(1==d)e.push(b.data);else if(a.readAsBinaryString)d=!0,a.readAsBinaryString(new Blob([b.data]));else if(f.readAsArrayBuffer)d=!0,a.readAsArrayBuffer(b.data);
|
||||
else{var p="";b=new Uint8Array(b.data);for(var r=b.byteLength,m=0;m<r;m++)p+=String.fromCharCode(b[m]);c.xxOnSocketData(p)}else c.xxOnSocketData(b.data)};c.xxOnSocketData=function(a){if(a&&-1!=c.connectstate){if("object"===typeof a){var b="",d=new Uint8Array(a),m=d.byteLength;for(a=0;a<m;a++)b+=String.fromCharCode(d[a]);a=b}else if("string"!==typeof a)return;if((2==c.protocol||3==c.protocol)&&1==c.connectstate)return c.m.ProcessData(a);c.amtaccumulator+=a;for(urlvars&&urlvars.redirtrace&&console.log("REDIR-RECV("+
|
||||
c.amtaccumulator.length+"): "+rstr2hex(c.amtaccumulator));1<=c.amtaccumulator.length;){a=0;switch(c.amtaccumulator.charCodeAt(0)){case 17:if(4>c.amtaccumulator.length)return;switch(c.amtaccumulator.charCodeAt(1)){case 0:if(13>c.amtaccumulator.length)return;b=c.amtaccumulator.charCodeAt(12);if(c.amtaccumulator.length<13+b)return;c.xxSend(String.fromCharCode(19,0,0,0,0,0,0,0,0));a=13+b;break;default:c.Stop()}break;case 20:if(9>c.amtaccumulator.length)return;var g=ReadIntX(c.amtaccumulator,5);if(c.amtaccumulator.length<
|
||||
9+g)return;var m=c.amtaccumulator.charCodeAt(1),b=c.amtaccumulator.charCodeAt(4),e=[];for(a=0;a<g;a++)e.push(c.amtaccumulator.charCodeAt(9+a));d=c.amtaccumulator.substring(9,9+g);a=9+g;if(0==b)0<=e.indexOf(4)?c.xxSend(String.fromCharCode(19,0,0,0,4)+IntToStrX(c.user.length+c.authuri.length+8)+String.fromCharCode(c.user.length)+c.user+String.fromCharCode(0,0)+String.fromCharCode(c.authuri.length)+c.authuri+String.fromCharCode(0,0,0,0)):0<=e.indexOf(3)?c.xxSend(String.fromCharCode(19,0,0,0,3)+IntToStrX(c.user.length+
|
||||
c.authuri.length+7)+String.fromCharCode(c.user.length)+c.user+String.fromCharCode(0,0)+String.fromCharCode(c.authuri.length)+c.authuri+String.fromCharCode(0,0,0)):0<=e.indexOf(1)?c.xxSend(String.fromCharCode(19,0,0,0,1)+IntToStrX(c.user.length+c.pass.length+2)+String.fromCharCode(c.user.length)+c.user+String.fromCharCode(c.pass.length)+c.pass):c.Stop();else if(3!=b&&4!=b||1!=m)0==m?(1==c.protocol&&c.xxSend(String.fromCharCode(32,0,0,0)+IntToStrX(c.amtsequence++)+ShortToStrX(1E4)+ShortToStrX(100)+
|
||||
ShortToStrX(0)+ShortToStrX(1E4)+ShortToStrX(100)+ShortToStrX(0)+IntToStrX(0)),2==c.protocol&&c.xxSend(String.fromCharCode(64,0,0,0,0,0,0,0)),3==c.protocol&&(c.connectstate=1,c.xxStateChange(3))):c.Stop();else{var g=0,e=d.charCodeAt(g),m=d.substring(g+1,g+1+e),g=g+(e+1),l=d.charCodeAt(g),e=d.substring(g+1,g+1+l),g=g+(l+1),l=0,l=null,v=c.xxRandomNonce(32),x="";4==b&&(l=d.charCodeAt(g),l=d.substring(g+1,g+1+l),x="00000002:"+v+":"+l+":");d=hex_md5(hex_md5(c.user+":"+m+":"+c.pass)+":"+e+":"+x+hex_md5("POST:"+
|
||||
c.authuri));g=c.user.length+m.length+e.length+c.authuri.length+v.length+8+d.length+7;4==b&&(g+=l.length+1);d=String.fromCharCode(19,0,0,0,b)+IntToStrX(g)+String.fromCharCode(c.user.length)+c.user+String.fromCharCode(m.length)+m+String.fromCharCode(e.length)+e+String.fromCharCode(c.authuri.length)+c.authuri+String.fromCharCode(v.length)+v+String.fromCharCode(8)+"00000002"+String.fromCharCode(d.length)+d;4==b&&(d+=String.fromCharCode(l.length)+l);c.xxSend(d)}break;case 33:if(23>c.amtaccumulator.length)break;
|
||||
a=23;c.xxSend(String.fromCharCode(39,0,0,0)+IntToStrX(c.amtsequence++)+String.fromCharCode(0,0,27,0,0,0));1==c.protocol&&(c.amtkeepalivetimer=setInterval(c.xxSendAmtKeepAlive,2E3));c.connectstate=1;c.xxStateChange(3);break;case 41:if(10>c.amtaccumulator.length)break;a=10;break;case 42:if(10>c.amtaccumulator.length)break;b=10+((c.amtaccumulator.charCodeAt(9)&255)<<8)+(c.amtaccumulator.charCodeAt(8)&255);if(c.amtaccumulator.length<b)break;c.m.ProcessData(c.amtaccumulator.substring(10,b));a=b;break;
|
||||
case 43:if(8>c.amtaccumulator.length)break;a=8;break;case 65:if(8>c.amtaccumulator.length)break;c.connectstate=1;c.m.Start();8<c.amtaccumulator.length&&c.m.ProcessData(c.amtaccumulator.substring(8));a=c.amtaccumulator.length;break;default:console.log("Unknown Intel AMT command: "+c.amtaccumulator.charCodeAt(0)+" acclen="+c.amtaccumulator.length);c.Stop();return}if(0==a)break;c.amtaccumulator=c.amtaccumulator.substring(a)}}};c.xxSend=function(a){urlvars&&urlvars.redirtrace&&console.log("REDIR-SEND("+
|
||||
a.length+"): "+rstr2hex(a));if(null!=c.socket&&c.socket.readyState==WebSocket.OPEN){for(var b=new Uint8Array(a.length),d=0;d<a.length;++d)b[d]=a.charCodeAt(d);c.socket.send(b.buffer)}};c.Send=function(a){null!=c.socket&&1==c.connectstate&&(1==c.protocol?c.xxSend(String.fromCharCode(40,0,0,0)+IntToStrX(c.amtsequence++)+ShortToStrX(a.length)+a):c.xxSend(a))};c.xxSendAmtKeepAlive=function(){null!=c.socket&&c.xxSend(String.fromCharCode(43,0,0,0)+IntToStrX(c.amtsequence++))};c.xxRandomNonceX="abcdef0123456789";
|
||||
c.xxRandomNonce=function(a){for(var b="",d=0;d<a;d++)b+=c.xxRandomNonceX.charAt(Math.floor(Math.random()*c.xxRandomNonceX.length));return b};c.xxOnSocketClosed=function(){urlvars&&urlvars.redirtrace&&console.log("REDIR-CLOSED");c.Stop()};c.xxStateChange=function(a){if(c.State!=a&&(c.State=a,c.m.xxStateChange(c.State),null!=c.onStateChanged))c.onStateChanged(c,c.State)};c.Stop=function(){c.xxStateChange(0);c.connectstate=-1;c.amtaccumulator="";null!=c.socket&&(c.socket.close(),c.socket=null);null!=
|
||||
c.amtkeepalivetimer&&(clearInterval(c.amtkeepalivetimer),c.amtkeepalivetimer=null)};c.RedirectStartSol=String.fromCharCode(16,0,0,0,83,79,76,32);c.RedirectStartKvm=String.fromCharCode(16,1,0,0,75,86,77,82);c.RedirectStartIder=String.fromCharCode(16,0,0,0,73,68,69,82);return c},WsmanStackCreateService=function(b,c,a,d,e,n){function p(a){for(var b,c={},m=0;m<a.childNodes.length;m++){var g=a.childNodes[m];b=null==g.childElementCount||0==g.childElementCount?g.textContent:p(g);"true"==b&&(b=!0);"false"==
|
||||
b&&(b=!1);parseInt(b)+""===b&&(b=parseInt(b));var h=b;if(null!=g.attributes&&0<g.attributes.length)for(h={Value:b},b=0;b<g.attributes.length;b++)h["@"+g.attributes[b].name]=g.attributes[b].value;c[g.localName]instanceof Array?c[g.localName].push(h):c[g.localName]=null==c[g.localName]?h:[c[g.localName],h]}return c}function r(a){if(!a)return"";var b="",c;for(c in a)a.hasOwnProperty(c)&&0===c.indexOf("@")&&(b+=" "+c.substring(1)+'="'+a[c]+'"');return b}function m(a){if(!a)return"";if("string"==typeof a)return a;
|
||||
if(a.InstanceID)return'<w:SelectorSet><w:Selector Name="InstanceID">'+a.InstanceID+"</w:Selector></w:SelectorSet>";var b="<w:SelectorSet>",c;for(c in a)if(a.hasOwnProperty(c)){b+='<w:Selector Name="'+c+'">';if(a[c].ReferenceParameters){var b=b+"<a:EndpointReference>",b=b+("<a:Address>"+a[c].Address+"</a:Address><a:ReferenceParameters><w:ResourceURI>"+a[c].ReferenceParameters.ResourceURI+"</w:ResourceURI><w:SelectorSet>"),m=a[c].ReferenceParameters.SelectorSet.Selector;if(Array.isArray(m))for(var g=
|
||||
0;g<m.length;g++)b+="<w:Selector"+r(m[g])+">"+m[g].Value+"</w:Selector>";else b+="<w:Selector"+r(m)+">"+m.Value+"</w:Selector>";b+="</w:SelectorSet></a:ReferenceParameters></a:EndpointReference>"}else b+=a[c];b+="</w:Selector>"}return b+"</w:SelectorSet>"}var g={NextMessageId:1,Address:"/wsman"};g.comm=CreateWsmanComm(b,c,a,d,e,n);g.PerformAjax=function(a,b,c,m,d){null==d&&(d="");g.comm.PerformAjax('<?xml version="1.0" encoding="utf-8"?><Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:a="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:w="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd" xmlns="http://www.w3.org/2003/05/soap-envelope" '+
|
||||
d+"><Header><a:Action>"+a,function(a,c,m){200!=c?b(g,null,{Header:{HttpError:c}},c,m):(a=g.ParseWsman(a))&&null!=a?b(g,a.Header.ResourceURI,a,200,m):b(g,null,{Header:{HttpError:c}},601,m)},c,m)};g.CancelAllQueries=function(a){g.comm.CancelAllQueries(a)};g.GetNameFromUrl=function(a){var b=a.lastIndexOf("/");return-1==b?a:a.substring(b+1)};g.ExecSubscribe=function(a,b,c,d,k,h,e,q,C,B){var y="",I="";q="";null!=C&&null!=B&&(y='<t:IssuedTokens xmlns:t="http://schemas.xmlsoap.org/ws/2005/02/trust" xmlns:se="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"><t:RequestSecurityTokenResponse><t:TokenType>http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#UsernameToken</t:TokenType><t:RequestedSecurityToken><se:UsernameToken><se:Username>'+
|
||||
C+'</se:Username><se:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd#PasswordText">'+B+"</se:Password></se:UsernameToken></t:RequestedSecurityToken></t:RequestSecurityTokenResponse></t:IssuedTokens>",I='<w:Auth Profile="http://schemas.dmtf.org/wbem/wsman/1/wsman/secprofile/http/digest"/>');null!=q&&(q="<a:ReferenceParameters><m:arg>"+q+"</m:arg></a:ReferenceParameters>");"PushWithAck"==b?b="dmtf.org/wbem/wsman/1/wsman/PushWithAck":"Push"==b&&(b="xmlsoap.org/ws/2004/08/eventing/DeliveryModes/Push");
|
||||
a="http://schemas.xmlsoap.org/ws/2004/08/eventing/Subscribe</a:Action><a:To>"+g.Address+"</a:To><w:ResourceURI>"+a+"</w:ResourceURI><a:MessageID>"+g.NextMessageId++ +"</a:MessageID><a:ReplyTo><a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address></a:ReplyTo>"+m(e)+y+'</Header><Body><e:Subscribe><e:Delivery Mode="http://schemas.'+b+'"><e:NotifyTo><a:Address>'+c+"</a:Address>"+q+"</e:NotifyTo>"+I+"</e:Delivery></e:Subscribe>";g.PerformAjax(a+"</Body></Envelope>",d,k,
|
||||
|
Loading…
Reference in New Issue
Block a user