From 5e8c69f89afc59c8ff2dc12e7bd6d136e977d7dd Mon Sep 17 00:00:00 2001 From: Bryan Roe Date: Tue, 2 Nov 2021 10:34:32 -0700 Subject: [PATCH] Fixed bug with PTHI and AMTUUID --- agents/meshcmd.js | 20 ++++++++++++++++++-- agents/modules_meshcmd/amt-wsman-duk.js | 7 +++++-- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/agents/meshcmd.js b/agents/meshcmd.js index 74b3870c..48bd731a 100644 --- a/agents/meshcmd.js +++ b/agents/meshcmd.js @@ -668,7 +668,8 @@ function run(argv) { performAmtAgentPresence(); } else if (settings.action == 'amtuuid') { // Start running - if (settings.hostname != null) { + if (settings.hostname != null) + { if ((settings.password == null) || (typeof settings.password != 'string') || (settings.password == '')) { console.log('No or invalid \"password\" specified, use --password [password].'); exit(1); return; } if ((settings.username == null) || (typeof settings.username != 'string') || (settings.username == '')) { settings.username = 'admin'; } } @@ -1398,7 +1399,17 @@ function getTrustedHashes(amtMei, func, tag) { // Called to get the UUID of Intel AMT, start by setting up MicroLMS if we are doing the operation on the local computer function getAmtUuid() { - if ((settings.hostname == null) || (settings.hostname == '127.0.0.1') || (settings.hostname.toLowerCase() == 'localhost')) { settings.noconsole = true; startLms(getAmtUuidEx); return; } else { getAmtUuidEx(); } + if ((settings.hostname == null) || (settings.hostname == '127.0.0.1') || (settings.hostname.toLowerCase() == 'localhost')) + { + settings.hostname = '127.0.0.1'; + settings.noconsole = true; + startLms(getAmtUuidEx); + return; + } + else + { + getAmtUuidEx(); + } } // Fetch the computer's UUID by fetching the CIM_ComputerSystemPackage WSMAN object. @@ -1667,6 +1678,11 @@ function setupMeiOsAdmin(func, state, tag) { var transport = require('amt-wsman-duk'); var wsman = require('amt-wsman'); var amt = require('amt'); + + settings.username = x.user; + settings.password = x.pass; + settings.tls = false; + oswsstack = new wsman(transport, '127.0.0.1', 16992, x.user, x.pass, false); osamtstack = new amt(oswsstack); if (func) { func(state, tag); } diff --git a/agents/modules_meshcmd/amt-wsman-duk.js b/agents/modules_meshcmd/amt-wsman-duk.js index 47e9707b..954d548b 100644 --- a/agents/modules_meshcmd/amt-wsman-duk.js +++ b/agents/modules_meshcmd/amt-wsman-duk.js @@ -66,7 +66,8 @@ function CreateWsmanComm(/*host, port, user, pass, tls, extra*/) { } // Private method - obj.PerformAjaxEx = function (postdata, callback, tag, url, action) { + obj.PerformAjaxEx = function (postdata, callback, tag, url, action) + { if (obj.FailAllError != 0) { if (obj.FailAllError != 999) { obj.gotNextMessagesError({ status: obj.FailAllError }, 'error', null, [postdata, callback, tag]); } return; } if (!postdata) postdata = ""; if (globalDebugFlags & 1) { console.log("SEND: " + postdata + "\r\n\r\n"); } // DEBUG @@ -80,9 +81,11 @@ function CreateWsmanComm(/*host, port, user, pass, tls, extra*/) { } obj.digest.http = require('http'); } - var request = { protocol: (obj.tls == 1 ? 'https:' : 'http:'), method: 'POST', host: obj.host, path: '/wsman', port: obj.port, rejectUnauthorized: false, checkServerIdentity: function (cert) { /*console.log('checkServerIdentity', JSON.stringify(cert));*/ } }; + var request = { delayWrite: true, protocol: (obj.tls == 1 ? 'https:' : 'http:'), method: 'POST', host: obj.host, path: '/wsman', port: obj.port, rejectUnauthorized: false, checkServerIdentity: function (cert) { /*console.log('checkServerIdentity', JSON.stringify(cert));*/ } }; var req = obj.digest.request(request); //console.log('Request ' + (obj.RequestCount++)); + if (globalDebugFlags & 1) { console.log('Request ' + (obj.RequestCount++)); } // DEBUG + req.on('error', function (e) { obj.gotNextMessagesError({ status: 600 }, 'error', null, [postdata, callback, tag]); }); req.on('response', function (response) { //console.log(JSON.stringify(response, null, 2));