Fixes Intel AMT MEI calls.
Ylian Saint-Hilaire committed
Nov 24, 2020 at 19:56 UTC
39541f875532aea427e7973e0da1da21027ab555
10 files changed
+48
-34
agents/MeshCmd-signed.exe
Binary files a/agents/MeshCmd-signed.exe and b/agents/MeshCmd-signed.exe differ
agents/MeshCmd64-signed.exe
Binary files a/agents/MeshCmd64-signed.exe and b/agents/MeshCmd64-signed.exe differ
agents/MeshService-signed.exe
Binary files a/agents/MeshService-signed.exe and b/agents/MeshService-signed.exe differ
agents/MeshService64-signed.exe
Binary files a/agents/MeshService64-signed.exe and b/agents/MeshService64-signed.exe differ
agents/meshcmd.js
+4
-1
@@ -498,7 +498,10 @@ function run(argv) {
498
exitOnCount = handles.length;
499
for (var i = 0; i < handles.length; ++i) {
500
this.getCertHashEntry(handles[i], function (result) {
501
- console.log(result.name + ', (' + (result.isDefault ? 'Default' : '') + (result.isActive ? ', Active' : ', Disabled') + ')\r\n ' + result.hashAlgorithmStr + ': ' + result.certificateHash);
501
+ var certState = [];
502
+ if (result.isDefault) { certState.push('Default'); }
503
+ if (result.isActive) { certState.push('Active'); } else { certState.push('Disabled'); }
504
+ console.log(result.name + ', (' + certState.join(', ') + ')\r\n ' + result.hashAlgorithmStr + ': ' + result.certificateHash);
505
if (--exitOnCount == 0) { exit(1); }
506
});
507
}
agents/modules_meshcmd/amt-mei.js
+15
-15
@@ -365,30 +365,30 @@ function amt_heci() {
365
fn.apply(this, opt);
366
}, callback, optional);
367
}
368
- this.startConfiguration = function startConfiguration() {
368
+ this.startConfiguration = function startConfiguration(callback) {
369
var optional = [];
370
- for (var i = 2; i < arguments.length; ++i) { optional.push(arguments[i]); }
371
- this.sendCommand(0x29, data, function (header, fn, opt) { opt.unshift(header.Status); fn.apply(this, opt); }, callback, optional);
370
+ for (var i = 1; i < arguments.length; ++i) { optional.push(arguments[i]); }
371
+ this.sendCommand(0x29, null, function (header, fn, opt) { opt.unshift(header.Status); fn.apply(this, opt); }, callback, optional);
372
}
373
- this.stopConfiguration = function stopConfiguration() {
373
+ this.stopConfiguration = function stopConfiguration(callback) {
374
var optional = [];
375
- for (var i = 2; i < arguments.length; ++i) { optional.push(arguments[i]); }
376
- this.sendCommand(0x5E, data, function (header, fn, opt) { opt.unshift(header.Status); fn.apply(this, opt); }, callback, optional);
375
+ for (var i = 1; i < arguments.length; ++i) { optional.push(arguments[i]); }
376
+ this.sendCommand(0x5E, null, function (header, fn, opt) { opt.unshift(header.Status); fn.apply(this, opt); }, callback, optional);
377
}
378
- this.openUserInitiatedConnection = function openUserInitiatedConnection() {
378
+ this.openUserInitiatedConnection = function openUserInitiatedConnection(callback) {
379
var optional = [];
380
- for (var i = 2; i < arguments.length; ++i) { optional.push(arguments[i]); }
381
- this.sendCommand(0x44, data, function (header, fn, opt) { opt.unshift(header.Status); fn.apply(this, opt); }, callback, optional);
380
+ for (var i = 1; i < arguments.length; ++i) { optional.push(arguments[i]); }
381
+ this.sendCommand(0x44, null, function (header, fn, opt) { opt.unshift(header.Status); fn.apply(this, opt); }, callback, optional);
382
}
383
- this.closeUserInitiatedConnection = function closeUnserInitiatedConnected() {
383
+ this.closeUserInitiatedConnection = function closeUnserInitiatedConnected(callback) {
384
var optional = [];
385
- for (var i = 2; i < arguments.length; ++i) { optional.push(arguments[i]); }
386
- this.sendCommand(0x45, data, function (header, fn, opt) { opt.unshift(header.Status); fn.apply(this, opt); }, callback, optional);
385
+ for (var i = 1; i < arguments.length; ++i) { optional.push(arguments[i]); }
386
+ this.sendCommand(0x45, null, function (header, fn, opt) { opt.unshift(header.Status); fn.apply(this, opt); }, callback, optional);
387
}
388
- this.getRemoteAccessConnectionStatus = function getRemoteAccessConnectionStatus() {
388
+ this.getRemoteAccessConnectionStatus = function getRemoteAccessConnectionStatus(callback) {
389
var optional = [];
390
- for (var i = 2; i < arguments.length; ++i) { optional.push(arguments[i]); }
391
- this.sendCommand(0x46, data, function (header, fn, opt) {
390
+ for (var i = 1; i < arguments.length; ++i) { optional.push(arguments[i]); }
391
+ this.sendCommand(0x46, null, function (header, fn, opt) {
392
if (header.Status == 0) {
393
var hostname = v.slice(14, header.Data.readUInt16LE(12) + 14).toString()
394
opt.unshift({ status: header.Status, networkStatus: header.Data.readUInt32LE(0), remoteAccessStatus: header.Data.readUInt32LE(4), remoteAccessTrigger: header.Data.readUInt32LE(8), mpsHostname: hostname, raw: header.Data });
agents/modules_meshcore/amt-manage.js
+1
-1
@@ -97,7 +97,7 @@ function AmtManager(agent, db, isdebug) {
97
}
98
}
99
amtMei.getProvisioningMode(function (result) { if (result) { amtMeiTmpState.ProvisioningMode = result.mode; } });
100
- amtMei.getProvisioningState(function (result) { if (result) { amtMeiTmpState.ProvisioningState = result.state; } }); // 0: "Not Activated (Pre)", 1: "Not Activated (In)", 2: "Activated"
100
+ amtMei.getProvisioningState(function (result) { if (result) { amtMeiTmpState.ProvisioningState = result.state; if (result.state != 2) { amtMei.stopConfiguration(function () { }); } } }); // 0: "Not Activated (Pre)", 1: "Not Activated (In)", 2: "Activated". Make sure to stop remote configuration if needed.
101
amtMei.getEHBCState(function (result) { if ((result != null) && (result.EHBC == true)) { amtMeiTmpState.Flags += 1; } });
102
amtMei.getControlMode(function (result) { if (result != null) { if (result.controlMode == 1) { amtMeiTmpState.Flags += 2; } if (result.controlMode == 2) { amtMeiTmpState.Flags += 4; } } }); // Flag 2 = CCM, 4 = ACM
103
//amtMei.getMACAddresses(function (result) { if (result) { amtMeiTmpState.mac = result; } });
agents/modules_meshcore/amt-mei.js
+15
-15
@@ -365,30 +365,30 @@ function amt_heci() {
365
fn.apply(this, opt);
366
}, callback, optional);
367
}
368
- this.startConfiguration = function startConfiguration() {
368
+ this.startConfiguration = function startConfiguration(callback) {
369
var optional = [];
370
- for (var i = 2; i < arguments.length; ++i) { optional.push(arguments[i]); }
371
- this.sendCommand(0x29, data, function (header, fn, opt) { opt.unshift(header.Status); fn.apply(this, opt); }, callback, optional);
370
+ for (var i = 1; i < arguments.length; ++i) { optional.push(arguments[i]); }
371
+ this.sendCommand(0x29, null, function (header, fn, opt) { opt.unshift(header.Status); fn.apply(this, opt); }, callback, optional);
372
}
373
- this.stopConfiguration = function stopConfiguration() {
373
+ this.stopConfiguration = function stopConfiguration(callback) {
374
var optional = [];
375
- for (var i = 2; i < arguments.length; ++i) { optional.push(arguments[i]); }
376
- this.sendCommand(0x5E, data, function (header, fn, opt) { opt.unshift(header.Status); fn.apply(this, opt); }, callback, optional);
375
+ for (var i = 1; i < arguments.length; ++i) { optional.push(arguments[i]); }
376
+ this.sendCommand(0x5E, null, function (header, fn, opt) { opt.unshift(header.Status); fn.apply(this, opt); }, callback, optional);
377
}
378
- this.openUserInitiatedConnection = function openUserInitiatedConnection() {
378
+ this.openUserInitiatedConnection = function openUserInitiatedConnection(callback) {
379
var optional = [];
380
- for (var i = 2; i < arguments.length; ++i) { optional.push(arguments[i]); }
381
- this.sendCommand(0x44, data, function (header, fn, opt) { opt.unshift(header.Status); fn.apply(this, opt); }, callback, optional);
380
+ for (var i = 1; i < arguments.length; ++i) { optional.push(arguments[i]); }
381
+ this.sendCommand(0x44, null, function (header, fn, opt) { opt.unshift(header.Status); fn.apply(this, opt); }, callback, optional);
382
}
383
- this.closeUserInitiatedConnection = function closeUnserInitiatedConnected() {
383
+ this.closeUserInitiatedConnection = function closeUnserInitiatedConnected(callback) {
384
var optional = [];
385
- for (var i = 2; i < arguments.length; ++i) { optional.push(arguments[i]); }
386
- this.sendCommand(0x45, data, function (header, fn, opt) { opt.unshift(header.Status); fn.apply(this, opt); }, callback, optional);
385
+ for (var i = 1; i < arguments.length; ++i) { optional.push(arguments[i]); }
386
+ this.sendCommand(0x45, null, function (header, fn, opt) { opt.unshift(header.Status); fn.apply(this, opt); }, callback, optional);
387
}
388
- this.getRemoteAccessConnectionStatus = function getRemoteAccessConnectionStatus() {
388
+ this.getRemoteAccessConnectionStatus = function getRemoteAccessConnectionStatus(callback) {
389
var optional = [];
390
- for (var i = 2; i < arguments.length; ++i) { optional.push(arguments[i]); }
391
- this.sendCommand(0x46, data, function (header, fn, opt) {
390
+ for (var i = 1; i < arguments.length; ++i) { optional.push(arguments[i]); }
391
+ this.sendCommand(0x46, null, function (header, fn, opt) {
392
if (header.Status == 0) {
393
var hostname = v.slice(14, header.Data.readUInt16LE(12) + 14).toString()
394
opt.unshift({ status: header.Status, networkStatus: header.Data.readUInt32LE(0), remoteAccessStatus: header.Data.readUInt32LE(4), remoteAccessTrigger: header.Data.readUInt32LE(8), mpsHostname: hostname, raw: header.Data });
certoperations.js
+10
@@ -251,6 +251,16 @@ module.exports.CertificateOperations = function (parent) {
251
v.value = 'rootcert.meshcentral.com';
252
setupbin.records[0].variables.push(v);
253
254
+ /*
255
+ // Create "ME Provision Halt Active" variable
256
+ v = {};
257
+ v.moduleid = 2;
258
+ v.varid = 28;
259
+ v.length = -1;
260
+ v.value = 1;
261
+ setupbin.records[0].variables.push(v);
262
+ */
263
+
264
// Write to log file
265
obj.logAmtActivation(domain, { time: new Date(), action: 'setupbin', domain: domain.id, userid: user._id, oldmebx: oldmebxpass, newmebx: newmebxpass, rootname: certRootName, hash: wildcardCertSha256, dns: 'rootcert.meshcentral.com' });
266
db.js
+3
-2
@@ -1604,8 +1604,9 @@ module.exports.CreateDB = function (parent, func) {
1604
mesh.nolog = 1;
1605
delete mesh.type;
1606
delete mesh._id;
1607
- if (mesh.amt != null) {
1608
- if (delete mesh.amt.password != null) { mesh.amt.password = 1; } // Remove the Intel AMT password if present
1607
+ if ((mesh.amt != null) && (mesh.amt.password != null)) {
1608
+ mesh.amt = Object.assign({}, mesh.amt); // Shallow clone
1609
+ if (mesh.amt.password != null) { mesh.amt.password = 1; } // Remove the Intel AMT password if present
1610
}
1611
parent.DispatchEvent(['*', mesh.meshid], obj, mesh);
1612
}