Fixed Intel AMT server IDE-redirect session not closing correctly.

This commit is contained in:
Ylian Saint-Hilaire 2022-07-05 22:12:11 -07:00
parent 08feb51616
commit 2189b92745
3 changed files with 11 additions and 15 deletions

View File

@ -122,7 +122,7 @@ module.exports.CreateAmtRemoteIder = function (webserver, meshcentral) {
} }
obj.Start = function () { obj.Start = function () {
if (obj.debug) { console.log("IDER-Start"); console.log(obj.floppy, obj.cdrom); } if (obj.debug) { console.log('IDER-Start'); console.log(obj.floppy, obj.cdrom); }
obj.bytesToAmt = 0; obj.bytesToAmt = 0;
obj.bytesFromAmt = 0; obj.bytesFromAmt = 0;
obj.inSequence = 0; obj.inSequence = 0;
@ -143,7 +143,7 @@ module.exports.CreateAmtRemoteIder = function (webserver, meshcentral) {
} }
obj.Stop = function () { obj.Stop = function () {
if (obj.debug) console.log("IDER-Stop"); if (obj.debug) console.log('IDER-Stop');
//if (obj.pingTimer) { clearInterval(obj.pingTimer); obj.pingTimer = null; } //if (obj.pingTimer) { clearInterval(obj.pingTimer); obj.pingTimer = null; }
obj.parent.Stop(); obj.parent.Stop();
} }

View File

@ -127,8 +127,8 @@ module.exports.CreateAmtIderSession = function (parent, db, ws, req, args, domai
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.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); } 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. // 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.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; } if ((command.args.cdromPath != null) && (command.args.cdromPath.indexOf('..') >= 0)) { delete command.args.cdromPath; }
// Get the disk image paths // Get the disk image paths
var domainx = 'domain' + ((domain.id == '') ? '' : ('-' + domain.id)); var domainx = 'domain' + ((domain.id == '') ? '' : ('-' + domain.id));
@ -148,7 +148,7 @@ module.exports.CreateAmtIderSession = function (parent, db, ws, req, args, domai
var iderError = obj.ider.m.diskSetup(floppyPath, cdromPath); var iderError = obj.ider.m.diskSetup(floppyPath, cdromPath);
// Error with the disk images, unable to start IDER // Error with the disk images, unable to start IDER
if (iderError != 0) { try { ws.send(JSON.stringify({ action: "error", code: iderError })); } catch (ex) { } break; } if (iderError != 0) { try { ws.send(JSON.stringify({ action: 'error', code: iderError })); } catch (ex) { } break; }
// Start the IDER session // Start the IDER session
obj.ider.Start(req.query.host, req.query.port, req.query.tls); obj.ider.Start(req.query.host, req.query.port, req.query.tls);

View File

@ -479,16 +479,12 @@ module.exports.CreateAmtRedirect = function (module, domain, user, webserver, me
obj.xxSend = function (x) { obj.xxSend = function (x) {
if (typeof x == 'string') { if (typeof x == 'string') {
//if (obj.redirTrace) { if (obj.redirTrace) { console.log("REDIR-SEND(" + x.length + "): " + Buffer.from(x, 'binary').toString('hex'), typeof x); }
//console.log("REDIR-SEND1(" + x.length + "): " + Buffer.from(x, 'binary').toString('hex'), typeof x);
//}
//obj.Debug("Send(" + x.length + "): " + webserver.common.rstr2hex(x)); //obj.Debug("Send(" + x.length + "): " + webserver.common.rstr2hex(x));
//obj.forwardclient.write(x); // FIXES CIRA //obj.forwardclient.write(x); // FIXES CIRA
obj.forwardclient.write(Buffer.from(x, 'binary')); obj.forwardclient.write(Buffer.from(x, 'binary'));
} else { } else {
//if (obj.redirTrace) { if (obj.redirTrace) { console.log("REDIR-SEND(" + x.length + "): " + x.toString('hex'), typeof x); }
//console.log("REDIR-SEND2(" + x.length + "): " + x.toString('hex'), typeof x);
//}
//obj.Debug("Send(" + x.length + "): " + webserver.common.rstr2hex(x)); //obj.Debug("Send(" + x.length + "): " + webserver.common.rstr2hex(x));
//obj.forwardclient.write(x); // FIXES CIRA //obj.forwardclient.write(x); // FIXES CIRA
obj.forwardclient.write(x); obj.forwardclient.write(x);
@ -508,7 +504,7 @@ module.exports.CreateAmtRedirect = function (module, domain, user, webserver, me
obj.xxRandomValueHex = function(len) { return obj.crypto.randomBytes(Math.ceil(len / 2)).toString('hex').slice(0, len); } obj.xxRandomValueHex = function(len) { return obj.crypto.randomBytes(Math.ceil(len / 2)).toString('hex').slice(0, len); }
obj.xxOnSocketClosed = function () { obj.xxOnSocketClosed = function () {
if (obj.redirTrace) { console.log("REDIR-CLOSED"); } if (obj.redirTrace) { console.log('REDIR-CLOSED'); }
//obj.Debug("Socket Closed"); //obj.Debug("Socket Closed");
obj.Stop(); obj.Stop();
} }
@ -521,12 +517,12 @@ module.exports.CreateAmtRedirect = function (module, domain, user, webserver, me
} }
obj.Stop = function () { obj.Stop = function () {
if (obj.redirTrace) { console.log("REDIR-CLOSED"); } if (obj.redirTrace) { console.log('REDIR-CLOSED'); }
//obj.Debug("Socket Stopped"); //obj.Debug("Socket Stopped");
obj.xxStateChange(0); obj.xxStateChange(0);
obj.connectstate = -1; obj.connectstate = -1;
obj.amtaccumulator = ""; obj.amtaccumulator = '';
if (obj.forwardclient != null) { try { obj.forwardclient.close(); } catch (ex) { } delete obj.forwardclient; } if (obj.forwardclient != null) { try { obj.forwardclient.destroy(); } catch (ex) { } delete obj.forwardclient; }
if (obj.amtkeepalivetimer != null) { clearInterval(obj.amtkeepalivetimer); delete obj.amtkeepalivetimer; } if (obj.amtkeepalivetimer != null) { clearInterval(obj.amtkeepalivetimer); delete obj.amtkeepalivetimer; }
} }