diff --git a/agents/MeshCmd-signed.exe b/agents/MeshCmd-signed.exe index 66a99f38..30ead8cb 100644 Binary files a/agents/MeshCmd-signed.exe and b/agents/MeshCmd-signed.exe differ diff --git a/agents/MeshCmd64-signed.exe b/agents/MeshCmd64-signed.exe index 11fd3f6c..847e720c 100644 Binary files a/agents/MeshCmd64-signed.exe and b/agents/MeshCmd64-signed.exe differ diff --git a/agents/MeshService-signed.exe b/agents/MeshService-signed.exe index a691a8d5..6d161a14 100644 Binary files a/agents/MeshService-signed.exe and b/agents/MeshService-signed.exe differ diff --git a/agents/MeshService64-signed.exe b/agents/MeshService64-signed.exe index 759a71e6..f80caa0f 100644 Binary files a/agents/MeshService64-signed.exe and b/agents/MeshService64-signed.exe differ diff --git a/agents/meshcmd.js b/agents/meshcmd.js index 29ca12c9..659e1d91 100644 --- a/agents/meshcmd.js +++ b/agents/meshcmd.js @@ -110,7 +110,7 @@ function run(argv) { //console.log('addedModules = ' + JSON.stringify(addedModules)); var actionpath = 'meshaction.txt'; if (args.actionfile != null) { actionpath = args.actionfile; } - var actions = ['HELP', 'ROUTE', 'MICROLMS', 'AMTCONFIG', 'AMTSCAN', 'AMTPOWER', 'AMTFEATURES', 'AMTNETWORK', 'AMTINFO', 'AMTINFODEBUG', 'AMTVERSIONS', 'AMTHASHES', 'AMTSAVESTATE', 'AMTUUID', 'AMTCCM', 'AMTDEACTIVATE', 'AMTACMDEACTIVATE', 'SMBIOS', 'RAWSMBIOS', 'MESHCOMMANDER', 'AMTAUDITLOG', 'AMTEVENTLOG', 'AMTPRESENCE', 'AMTWIFI', 'AMTWAKE', 'AMTSTARTCONFIG', 'AMTSTOPCONFIG']; + var actions = ['HELP', 'ROUTE', 'MICROLMS', 'AMTCONFIG', 'AMTSCAN', 'AMTPOWER', 'AMTFEATURES', 'AMTNETWORK', 'AMTINFO', 'AMTINFOJSON', 'AMTVERSIONS', 'AMTHASHES', 'AMTSAVESTATE', 'AMTUUID', 'AMTCCM', 'AMTDEACTIVATE', 'AMTACMDEACTIVATE', 'SMBIOS', 'RAWSMBIOS', 'MESHCOMMANDER', 'AMTAUDITLOG', 'AMTEVENTLOG', 'AMTPRESENCE', 'AMTWIFI', 'AMTWAKE', 'AMTSTARTCONFIG', 'AMTSTOPCONFIG']; // Load the action file var actionfile = null; @@ -223,8 +223,12 @@ function run(argv) { console.log(' --output [filename] Optional filename to write the results to.'); } else if (action == 'amtinfo') { console.log('AmtInfo action will get the version and activation state of Intel AMT on this computer. The command must be run on a computer with Intel AMT, must run as administrator and the Intel management driver must be installed. Example usage:\r\n\r\n meshcmd amtinfo'); + console.log('\r\nPossible arguments:\r\n'); + console.log(' --json Display all Intel AMT state in JSON format.'); } else if ((action == 'amtversion') || (action == 'amtversions')) { console.log('AmtVersions will display all version information about Intel AMT on this computer. The command must be run on a computer with Intel AMT, must run as administrator and the Intel management driver must be installed. Example usage:\r\n\r\n meshcmd amtversions'); + console.log('\r\nPossible arguments:\r\n'); + console.log(' --json Display all Intel AMT state in JSON format.'); } else if (action == 'amthashes') { console.log('Amthashes will display all trusted activations hashes for Intel AMT on this computer. The command must be run on a computer with Intel AMT, must run as administrator and the Intel management driver must be installed. These certificates hashes are used by Intel AMT when performing activation into ACM mode. Example usage:\r\n\r\n meshcmd amthashes'); } else if ((action == 'microlms') || (action == 'lms') || (action == 'amtlms')) { @@ -485,15 +489,19 @@ function run(argv) { try { amtMeiModule = require('amt-mei'); amtMei = new amtMeiModule(); } catch (ex) { console.log(ex); exit(1); return; } amtMei.on('error', function (e) { console.log('ERROR: ' + e); exit(1); return; }); amtMei.getVersion(function (val) { - console.log("BIOS Version = " + val.BiosVersion.toString()); - for (var version in val.Versions) { - var extras = '', skuBits = ['', 'iQST', 'ASF', 'AMT', 'ISM', 'TPM', '', '', 'HomeIT', '', 'WOX', '', '', 'AT-p', 'Corporate', 'L3 Mgt Upgrade']; - if (val.Versions[version].Description == 'Sku') { - var n = parseInt(val.Versions[version].Version), x = [], xx = 1; - for (var i = 0; i < skuBits.length; i++) { if ((n & xx) != 0) { x.push(skuBits[i]); } xx = xx << 1; } - if (x.length > 0) { extras = ' (' + x.join(', ') + ')' } + if (args.json) { + console.log(JSON.stringify(val, null, 2)); + } else { + console.log("BIOS Version = " + val.BiosVersion.toString()); + for (var version in val.Versions) { + var extras = '', skuBits = ['', 'iQST', 'ASF', 'AMT', 'ISM', 'TPM', '', '', 'HomeIT', '', 'WOX', '', '', 'AT-p', 'Corporate', 'L3 Mgt Upgrade']; + if (val.Versions[version].Description == 'Sku') { + var n = parseInt(val.Versions[version].Version), x = [], xx = 1; + for (var i = 0; i < skuBits.length; i++) { if ((n & xx) != 0) { x.push(skuBits[i]); } xx = xx << 1; } + if (x.length > 0) { extras = ' (' + x.join(', ') + ')' } + } + console.log(val.Versions[version].Description + " = " + val.Versions[version].Version + extras); } - console.log(val.Versions[version].Description + " = " + val.Versions[version].Version + extras); } exit(1); return; }); @@ -534,7 +542,7 @@ function run(argv) { } amtMei.getProvisioningState(function (result) { if (result) { mestate.ProvisioningState = result; } }); amtMei.getProvisioningMode(function (result) { if (result) { mestate.ProvisioningMode = result; } }); - amtMei.getEHBCState(function (result) { if (result) { mestate.ehbc = result; } }); + amtMei.getEHBCState(function (result) { mestate.ehbc = ((result === true) || (typeof result == 'object') && (result.EHBC === true)); }); amtMei.getControlMode(function (result) { if (result) { mestate.controlmode = result; } }); amtMei.getMACAddresses(function (result) { if (result) { mestate.mac = result; } }); amtMei.getLanInterfaceSettings(0, function (result) { if (result) { mestate.net0 = result; } }); @@ -543,7 +551,9 @@ function run(argv) { amtMei.getRemoteAccessConnectionStatus(function (result) { if ((result != null) && (result.status == 0)) { mestate.networkStatus = result.networkStatus; mestate.remoteAccessStatus = result.remoteAccessStatus; mestate.remoteAccessTrigger = result.remoteAccessTrigger; mestate.mpsHostname = result.mpsHostname; } }); amtMei.getDnsSuffix(function (result) { if (result) { mestate.DnsSuffix = result; } - if (mestate.ver && mestate.ProvisioningState && mestate.ProvisioningMode) { + if (args.json) { + console.log(JSON.stringify(mestate, null, 2)); + } else if (mestate.ver && mestate.ProvisioningState && mestate.ProvisioningMode) { var str = 'Intel ME v' + mestate.ver; if (mestate.sku & 8) { str = 'Intel AMT v' + mestate.ver } else if (mestate.sku & 16) { str = 'Intel SM v' + mestate.ver } @@ -558,7 +568,7 @@ function run(argv) { } } } - if ((mestate.ehbc) && (mestate.ehbc.EHBC == true)) { str += ', EHBC enabled'; } + if (mestate.ehbc) { str += ', EHBC enabled'; } str += '.'; if (mestate.net0 != null) { str += '\r\nWired ' + ((mestate.net0.enabled == 1) ? 'Enabled' : 'Disabled') + ((mestate.net0.dhcpEnabled == 1) ? ', DHCP' : ', Static') + ', ' + mestate.net0.mac + (mestate.net0.address == '0.0.0.0' ? '' : (', ' + mestate.net0.address)); } if (mestate.net1 != null) { str += '\r\nWireless ' + ((mestate.net1.enabled == 1) ? 'Enabled' : 'Disabled') + ((mestate.net1.dhcpEnabled == 1) ? ', DHCP' : ', Static') + ', ' + mestate.net1.mac + (mestate.net1.address == '0.0.0.0' ? '' : (', ' + mestate.net1.address)); } @@ -596,7 +606,7 @@ function run(argv) { } }); } catch (ex) { console.log("Unable to perform MEI operations, try running as " + ((process.platform == 'win32')?"administrator.":"root.")); exit(1); return; } - } else if (settings.action == 'amtinfodebug') { + } else if (settings.action == 'amtinfojson') { // Display Intel AMT version and activation state getMeiState(15, function (state) { console.log(JSON.stringify(state, null, 2)); exit(1); }); // Flags: 1 = Versions, 2 = OsAdmin, 4 = Hashes, 8 = Network } else if (settings.action == 'amtsavestate') { @@ -639,6 +649,7 @@ function run(argv) { // Start Intel AMT configuration if ((settings.url == null) || (typeof settings.url != 'string') || (settings.url == '')) { console.log('No MeshCentral server URL specified, use --url [url].'); exit(1); return; } if ((settings.id == null) || (typeof settings.id != 'string') || (settings.id == '')) { console.log('No device group identifier specified, use --id [identifier].'); exit(1); return; } + settings.id = settings.id.replace('\'', ''); // Remove single quote. debug(1, "Settings: " + JSON.stringify(settings)); configureAmt(); } else if (settings.action == 'amtccm') { diff --git a/agents/modules_meshcmd/amt-mei.js b/agents/modules_meshcmd/amt-mei.js index 8387049f..49811a42 100644 --- a/agents/modules_meshcmd/amt-mei.js +++ b/agents/modules_meshcmd/amt-mei.js @@ -17,6 +17,21 @@ limitations under the License. var Q = require('queue'); var g_internal = null; +function retry_pthi_later() +{ + if (++g_internal.errorCount < 20) + { + g_internal.timeout = setTimeout(function (p) + { + p.connect(require('heci').GUIDS.AMT, { noPipeline: 1 }); + }, 250, this); + } + else + { + this.Parent.emit('error', 'PTHI Connection could not be established'); + } +} + function amt_heci() { var emitterUtils = require('events').inherits(this); @@ -29,7 +44,7 @@ function amt_heci() var that = this; if (g_internal == null) { - g_internal = { _rq: new Q(), _amt: null }; + g_internal = { _rq: new Q(), _amt: null, errorCount: 0 }; g_internal._setupPTHI = function _g_setupPTHI() { console.info1('setupPTHI()'); @@ -42,7 +57,7 @@ function amt_heci() this._amt.on('error', function _amtOnError(e) { console.info1('PTHIError: ' + e); - if (this.Parent._rq.isEmpty()) + if (g_internal._rq.isEmpty()) { console.info1(' Queue is empty'); this.Parent.emit('error', e); // No pending requests, so propagate the error up @@ -51,22 +66,13 @@ function amt_heci() { console.info1(' Queue is NOT empty'); - // There is a pending request, so fail the pending request - var user = this.Parent._rq.deQueue(); - var params = user.optional; - var callback = user.func; - params.unshift({ Status: -1 }); // Relay an error - callback.apply(this.Parent, params); - - if (!this.Parent._rq.isEmpty()) - { - // There are still more pending requests, so try to re-helpconnect MEI - this.connect(heci.GUIDS.AMT, { noPipeline: 1 }); - } + // Try again + retry_pthi_later.call(this); } }); this._amt.on('connect', function _amtOnConnect() { + g_internal.errorCount = 0; this.on('data', function _amtOnData(chunk) { //console.log("Received: " + chunk.length + " bytes"); @@ -125,13 +131,6 @@ function amt_heci() header.writeUInt32LE(arguments[0] | 0x04000000, 4); header.writeUInt32LE(arguments[1] == null ? 0 : arguments[1].length, 8); - //this._rq.enQueue({ cmd: arguments[0], func: arguments[2], optional: args, send: (arguments[1] == null ? header : Buffer.concat([header, arguments[1]])) }); - //if(!this._amt) - //{ - // this._setupPTHI(); - // this._amt.connect(heci.GUIDS.AMT, { noPipeline: 1 }); - //} - g_internal._rq.enQueue({ cmd: arguments[0], func: arguments[2], optional: args, send: (arguments[1] == null ? header : Buffer.concat([header, arguments[1]])) }); if (!g_internal._amt) { diff --git a/agents/modules_meshcore/amt-mei.js b/agents/modules_meshcore/amt-mei.js index 8387049f..49811a42 100644 --- a/agents/modules_meshcore/amt-mei.js +++ b/agents/modules_meshcore/amt-mei.js @@ -17,6 +17,21 @@ limitations under the License. var Q = require('queue'); var g_internal = null; +function retry_pthi_later() +{ + if (++g_internal.errorCount < 20) + { + g_internal.timeout = setTimeout(function (p) + { + p.connect(require('heci').GUIDS.AMT, { noPipeline: 1 }); + }, 250, this); + } + else + { + this.Parent.emit('error', 'PTHI Connection could not be established'); + } +} + function amt_heci() { var emitterUtils = require('events').inherits(this); @@ -29,7 +44,7 @@ function amt_heci() var that = this; if (g_internal == null) { - g_internal = { _rq: new Q(), _amt: null }; + g_internal = { _rq: new Q(), _amt: null, errorCount: 0 }; g_internal._setupPTHI = function _g_setupPTHI() { console.info1('setupPTHI()'); @@ -42,7 +57,7 @@ function amt_heci() this._amt.on('error', function _amtOnError(e) { console.info1('PTHIError: ' + e); - if (this.Parent._rq.isEmpty()) + if (g_internal._rq.isEmpty()) { console.info1(' Queue is empty'); this.Parent.emit('error', e); // No pending requests, so propagate the error up @@ -51,22 +66,13 @@ function amt_heci() { console.info1(' Queue is NOT empty'); - // There is a pending request, so fail the pending request - var user = this.Parent._rq.deQueue(); - var params = user.optional; - var callback = user.func; - params.unshift({ Status: -1 }); // Relay an error - callback.apply(this.Parent, params); - - if (!this.Parent._rq.isEmpty()) - { - // There are still more pending requests, so try to re-helpconnect MEI - this.connect(heci.GUIDS.AMT, { noPipeline: 1 }); - } + // Try again + retry_pthi_later.call(this); } }); this._amt.on('connect', function _amtOnConnect() { + g_internal.errorCount = 0; this.on('data', function _amtOnData(chunk) { //console.log("Received: " + chunk.length + " bytes"); @@ -125,13 +131,6 @@ function amt_heci() header.writeUInt32LE(arguments[0] | 0x04000000, 4); header.writeUInt32LE(arguments[1] == null ? 0 : arguments[1].length, 8); - //this._rq.enQueue({ cmd: arguments[0], func: arguments[2], optional: args, send: (arguments[1] == null ? header : Buffer.concat([header, arguments[1]])) }); - //if(!this._amt) - //{ - // this._setupPTHI(); - // this._amt.connect(heci.GUIDS.AMT, { noPipeline: 1 }); - //} - g_internal._rq.enQueue({ cmd: arguments[0], func: arguments[2], optional: args, send: (arguments[1] == null ? header : Buffer.concat([header, arguments[1]])) }); if (!g_internal._amt) { diff --git a/amtmanager.js b/amtmanager.js index af76aa9e..9e8eb2cf 100644 --- a/amtmanager.js +++ b/amtmanager.js @@ -1875,7 +1875,7 @@ module.exports.CreateAmtManager = function (parent) { function activateIntelAmt(dev) { // Find the Intel AMT policy const mesh = parent.webserver.meshes[dev.meshid]; - if (mesh == null) { dev.consoleMsg("Unable to find device group."); removeAmtDevice(dev, 36); return false; } + if (mesh == null) { dev.consoleMsg("Unable to find device group (" + dev.meshid + ")."); removeAmtDevice(dev, 36); return false; } var amtPolicy = 0; // 0 = Do nothing, 1 = Deactivate CCM, 2 = CCM, 3 = ACM var ccmPolicy = 0; // Only used when in ACM policy: 0 = Do nothing, 1 = Deactivate CCM, 2 = CCM is ACM fails if (mesh.amt != null) { if (typeof mesh.amt.type == 'number') { amtPolicy = mesh.amt.type; } if (typeof mesh.amt.ccm == 'number') { ccmPolicy = mesh.amt.ccm; } } diff --git a/package.json b/package.json index 3b1bb2fb..68e4d8e4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "meshcentral", - "version": "0.8.77", + "version": "0.8.78", "keywords": [ "Remote Device Management", "Remote Device Monitoring", diff --git a/public/scripts/agent-desktop-0.0.2-min.js b/public/scripts/agent-desktop-0.0.2-min.js index 70e31535..7187e059 100644 --- a/public/scripts/agent-desktop-0.0.2-min.js +++ b/public/scripts/agent-desktop-0.0.2-min.js @@ -1 +1 @@ -Uint8Array.prototype.slice||Object.defineProperty(Uint8Array.prototype,"slice",{value:function(e,t){return new Uint8Array(Array.prototype.slice.call(this,e,t))}});var CreateAgentRemoteDesktop=function(e,t){var p={};"string"==typeof(p.CanvasId=e)&&(p.CanvasId=Q(e)),p.Canvas=p.CanvasId.getContext("2d"),p.scrolldiv=t,p.State=0,p.PendingOperations=[],p.tilesReceived=0,p.TilesDrawn=0,p.KillDraw=0,p.ipad=!1,p.tabletKeyboardVisible=!1,p.LastX=0,p.LastY=0,p.touchenabled=0,p.submenuoffset=0,p.touchtimer=null,p.TouchArray={},p.connectmode=0,p.connectioncount=0,p.rotation=0,p.protocol=2,p.debugmode=0,p.firstUpKeys=[],p.stopInput=!1,p.localKeyMap=!0,p.remoteKeyMap=!1,p.pressedKeys=[],p.sessionid=0,p.username,p.oldie=!1,p.CompressionLevel=50,p.ScalingLevel=1024,p.FrameRateTimer=100,p.SwapMouse=!1,p.FirstDraw=!1,p.onRemoteInputLockChanged=null,p.RemoteInputLock=null,p.ScreenWidth=960,p.ScreenHeight=701,p.width=960,p.height=960,p.displays=null,p.selectedDisplay=null,p.onScreenSizeChange=null,p.onMessage=null,p.onConnectCountChanged=null,p.onDebugMessage=null,p.onTouchEnabledChanged=null,p.onDisplayinfo=null;var S=!(p.accumulator=null),v="default";p.mouseCursorActive=function(e){S!=e&&(S=e,p.CanvasId.style.cursor=1==e?v:"default")};var C=["default","progress","crosshair","pointer","help","text","no-drop","move","nesw-resize","ns-resize","nwse-resize","w-resize","alias","wait","none","not-allowed","col-resize","row-resize","copy","zoom-in","zoom-out"];p.Start=function(){p.State=0,p.accumulator=null},p.Stop=function(){p.setRotation(0),p.UnGrabKeyInput(),p.UnGrabMouseInput(),p.touchenabled=0,null!=p.onScreenSizeChange&&p.onScreenSizeChange(p,p.ScreenWidth,p.ScreenHeight,p.CanvasId),p.Canvas.clearRect(0,0,p.CanvasId.width,p.CanvasId.height)},p.xxStateChange=function(e){p.State!=e&&(p.State=e,p.CanvasId.style.cursor="default",0===e&&p.Stop())},p.send=function(e){2