From 81d903672aa78eaabdb405730a5a4abe921131f0 Mon Sep 17 00:00:00 2001 From: Ylian Saint-Hilaire Date: Thu, 1 Jul 2021 13:21:24 -0700 Subject: [PATCH] Updated MeshCMD with MEI hang workaround. --- agents/MeshCmd-signed.exe | Bin 4173672 -> 4175072 bytes agents/MeshCmd64-signed.exe | Bin 3788136 -> 3789536 bytes agents/meshcmd.js | 273 +++++++++++++++++++----------------- 3 files changed, 143 insertions(+), 130 deletions(-) diff --git a/agents/MeshCmd-signed.exe b/agents/MeshCmd-signed.exe index 30111ee70477533d9d29e030d219ae333e0ad42d..db912e6db5ce4a2250ba7ba2f7019a9e6af5644b 100644 GIT binary patch delta 3422 zcmbW2c~q0v62J`t24qJGX|-h4@`*#G)+&M)VinS1BXoqOj_--YMA zOE;eLI`VlYzl>d_=24Sv?^k#7YCCxxCdgpK6fr~0ks$~lu|O=5p@Q@Bf}97gh4zJFT@-1L41)Bh#%sQ1Rx`kKtzm;LV^$p zB1M9c5M3uPG@)Co57p|!wEA$ZK0>R1L#rRH)sNBY$7=PFyY*2iVY+u8MO|4A>$PH2 z@W`d+kdsBjz+(xq0%0Bgb<`4Xh;AkPmsUHtQA=hI(8bk}-!xAESWzd~kLSlHYWN2K>dO}AHae%wa zxuC0vIaqPwXDuV1oNgF2FC$4HeHhG#^)=KKZZ9Km7!A?}@}|*n@pozg>~f5whST9R zhTFdx99~Xr;eG=d_xiZ30pgD3B$k^o!RT~cBaw1nK2Y97__~%x;=qHuXK4^O#R^`u z5li^Bi6lTJ5Ie-#lK zKCNIvGnr-#VpB5_8z&xXCNl=O7}Y{zUPi-*mKHqESE+HYVxu6`f(kgDElg=8)M!m; zB^J=yN+LP;R&cVF>@>!2*n~lM1V}umn*_0KmJbyLO{-s+@)^hIN0=sr@#Wlp8i+e1%wUc1Z;0J0I<#2QBZK`o)7os9o?{w{w_Ty;;{$r`f?iG+!fXUGZ* zzuvJ2q-d~; zR&T(oZ&!tdW;nQ>4MYcadnq3lZ^W}*Uq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Pb)CN8%S?DXZE(<+_2NpH{yH}X5?L}nXT0>aq+(1QZsPp z*_>sariuTQ@Sw>(c2`U~r7AFOfBQ@VD0v2*OCntN>q{)ad1 zU+?AQH+h-ThTedn_pihI663wSIMzXq9Sa*iq+R>{UvJX8?rEJ+m~2*cKaYv-FWb-< z&=FF&sp0YkQNQO~JwxI16Wp88G1bJKu_osk4JcyXRw`SFK&3#V!St?J9OVg4cq$XOK$%k^7xxC diff --git a/agents/MeshCmd64-signed.exe b/agents/MeshCmd64-signed.exe index ee436c7cbdb62368ed64a207d1e42f0ddf3529ae..602dc320631b8b372ab02a74b1f9113bb9b9bf0f 100644 GIT binary patch delta 3434 zcmb7_d03QH7r-4FkU<6p*&*;{00CKMVY&AOK_K~(FHk_x6g9R12XO|6Vfzw6z(FgO z06l6VD53K`z&?~bK{VfwmP`-_YiVmJ-;d_K zIu-<+eZ+@*1L96l++Bp-pkO!c47(c;@1;UH(11c2FJ;)ghjxI&b!aLKZ@?tz8l(q? z>hRMVk%M-OY9aQk8c`hZE8O&U6D3HJahnszq*zK-!~#_=st)zFzi4g&=?JAM*Nral*Gpj1{8gQ zSdiIq7n^l%S1+EYpX}hltO=bC{xJ z9Y&@MjjSZ@9kibi){0_YOwxzCR^*{Iak>>Pm|)Da4TVk!PE*V+ZR9|_EUR4&JrlfL zu!T0!sCE>n)sin3Y;8vYT1Wlus7;%WCMQjVCqF@v>aqVqcn1ob;CE{W@?(2YE^(3- z5^1i)WobM_bs%%N(t%!oF)c@HIA4hre~l^8PPMuJ0H>2wvHw$KHz9a37N`~-A)yml zY>gyGvzv!?)n&JX%m|tdHJwPH%ca~YS6CM6W@j^to0zgvED>kPWr=dB%!}*Kl}V*? zFRmL1T(Fhejy@drB?s|y9=3$Ydc+3Lsk8xX>_l(;OGB40AY0|{ooI({A&*Ceijotv zvqY3Ml}eUra#8XMu_TQOiHuc`%0*PFSe7OCVjED}pDmRp zl1GZf^VLdMz6X_>ElHM(iEGz97#HAqu-^)^St2Shk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)lvj274~hmYc{PseLi=coc)O@!ry9wOX7jrd zFkE`OKh}=ZQ9Rw&xg{WFZp7W|meVA0i)ZA1S8if@=clmL3e7m%upFDo`&{x=PDQH) zC`5<4?sBzWdAND>$GZtVn^KkRlK%VWgMgAkiNmp3j=X`P?%^tN 0) && (mestate.mpsHostname != null) && (mestate.mpsHostname.length > 0)) { + str += ' to ' + mestate.mpsHostname + ', ' + ['User initiated', 'Alert', 'Periodic', 'Provisioning'][mestate.remoteAccessTrigger]; + } + } + console.log(str + '.'); + } else { + console.log('Intel(R) AMT not supported.'); } - } - if (typeof mestate.networkStatus == 'number') { - str += '\r\nConnection Status: ' + ['Direct', 'VPN', 'Outside'][mestate.networkStatus]; - str += ', CIRA: ' + ['Disconnected', 'Connecting', 'Connected'][mestate.remoteAccessStatus]; - if ((mestate.remoteAccessStatus > 0) && (mestate.mpsHostname != null) && (mestate.mpsHostname.length > 0)) { - str += ' to ' + mestate.mpsHostname + ', ' + ['User initiated', 'Alert', 'Periodic', 'Provisioning'][mestate.remoteAccessTrigger]; - } - } - console.log(str + '.'); + exit(1); + }); } else { - console.log('Intel(R) AMT not supported.'); + console.log("Unable to perform MEI operations, try running as " + ((process.platform == 'win32')?"administrator.":"root.")); + exit(1); return; } - exit(1); }); - } catch (ex) { console.log("Unable to perform MEI operations, try running as administrator."); exit(1); return; } + } 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') { // 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 @@ -590,10 +593,14 @@ function run(argv) { saveEntireAmtState(); } else if ((settings.action == 'microlms') || (settings.action == 'amtlms') || (settings.action == 'lms')) { // Start Intel AMT MicroLMS - startLms(function (state) { - console.log(['MicroLMS did not start. Must run as administrator or LMS already active.', 'MicroLMS started.', 'MicroLMS started, MeshCommander on HTTP/16994.', 'MEI error'][state]); - if (((state == 0) || (state == 3)) && (settings.noconsole === true)) { exit(0); } else { console.log('Press ctrl-c to exit.'); } - }, settings.noconsole !== true); + // Because of a bug in MEI on Linux, LMS will jam if not root. To work around this, start by checking AMT state first. + getMeiState(0, function (xstate) { // Flags: 1 = Versions, 2 = OsAdmin, 4 = Hashes, 8 = Network + if (xstate == null) { console.log("Unable to get Intel AMT state, try running as " + ((process.platform == 'win32')?"administrator.":"root.")); exit(1); return; } + startLms(function (state) { + console.log(['MicroLMS did not start. Must run as administrator or LMS already active.', 'MicroLMS started.', 'MicroLMS started, MeshCommander on HTTP/16994.', 'MEI error'][state]); + if (((state == 0) || (state == 3)) && (settings.noconsole === true)) { exit(0); } else { console.log('Press ctrl-c to exit.'); } + }, false, xstate); + }); } else if (settings.action == 'amtpresence') { // Heartbeat a Intel AMT watchdog if ((settings.password == null) || (typeof settings.password != 'string') || (settings.password == '')) { console.log('No or invalid \"password\" specified, use --password [password].'); exit(1); return; } @@ -1110,56 +1117,57 @@ function startMeshCommander() { function configureAmt() { settings.noconsole = true; - startLms(configureAmt2, amtMei); + // Due to a bug in MEI handling, we have to pull MEI state first before starting LMS. + getMeiState(15, function (state) { // Flags: 1 = Versions, 2 = OsAdmin, 4 = Hashes, 8 = Network + if (state == null) { console.log("Unable to get Intel AMT state, try running as " + ((process.platform == 'win32')?"administrator.":"root.")); exit(1); return; } + if (state.ProvisioningState == null) { console.log('Intel AMT not ready for configuration.'); exit(1); return; } + startLms(configureAmt2, false, state); + }); } -function configureAmt2() { - getMeiState(15, function (state) { // Flags: 1 = Versions, 2 = OsAdmin, 4 = Hashes, 8 = Network - if (state == null) { console.log('Unable to get Intel AMT state, try running as administrator.'); exit(1); return; } - if (state.ProvisioningState == null) { console.log('Intel AMT not ready for configuration.'); exit(1); return; } - console.log('Starting Intel AMT configuration...'); +function configureAmt2(err, state) { + console.log('Starting Intel AMT configuration...'); - // Add indication if the device is battery powered, this is used to show a mobile icon when adding the device - state.isBatteryPowered = (require('identifiers').isBatteryPowered && require('identifiers').isBatteryPowered()); + // Add indication if the device is battery powered, this is used to show a mobile icon when adding the device + state.isBatteryPowered = (require('identifiers').isBatteryPowered && require('identifiers').isBatteryPowered()); - // Add Intel AMT credentials if provided - if ((typeof settings.password == 'string') && (settings.password != '')) { - state.amtpass = settings.password; - state.amtuser = 'admin'; - if ((typeof settings.username == 'string') && (settings.username != '')) { state.amtuser = settings.username; } - } + // Add Intel AMT credentials if provided + if ((typeof settings.password == 'string') && (settings.password != '')) { + state.amtpass = settings.password; + state.amtuser = 'admin'; + if ((typeof settings.username == 'string') && (settings.username != '')) { state.amtuser = settings.username; } + } - // If a description is provided, send it to the server - if ((typeof settings.desc == 'string') && (settings.desc != '')) { state.desc = settings.desc; } + // If a description is provided, send it to the server + if ((typeof settings.desc == 'string') && (settings.desc != '')) { state.desc = settings.desc; } - // Connect to MPS and start APF relay - var apfarg = { - mpsurl: settings.url, - mpsuser: settings.id.substring(0, 16), - mpspass: settings.id.substring(0, 16), - mpskeepalive: 60000, - clientname: state.OsHostname, - clientaddress: '127.0.0.1', - clientuuid: state.UUID, - conntype: 2, // 0 = CIRA, 1 = Relay, 2 = LMS. The correct value is 2 since we are performing an LMS relay. - meiState: state - }; - if ((apfarg.clientuuid == null) || (apfarg.clientuuid.length != 36)) { - console.log("Unable to get Intel AMT UUID: " + apfarg.clientuuid); + // Connect to MPS and start APF relay + var apfarg = { + mpsurl: settings.url, + mpsuser: settings.id.substring(0, 16), + mpspass: settings.id.substring(0, 16), + mpskeepalive: 60000, + clientname: state.OsHostname, + clientaddress: '127.0.0.1', + clientuuid: state.UUID, + conntype: 2, // 0 = CIRA, 1 = Relay, 2 = LMS. The correct value is 2 since we are performing an LMS relay. + meiState: state + }; + if ((apfarg.clientuuid == null) || (apfarg.clientuuid.length != 36)) { + console.log("Unable to get Intel AMT UUID: " + apfarg.clientuuid); + exit(1); return; + } else { + settings.apftunnel = require('amt-apfclient')({ debug: (settings.debuglevel > 0) }, apfarg); + settings.apftunnel.onJsonControl = configureJsonControl; + settings.apftunnel.onChannelClosed = function () { exit(0); } + try { + settings.apftunnel.connect(); + console.log("Started APF tunnel..."); + } catch (e) { + console.log(JSON.stringify(e)); exit(1); return; - } else { - settings.apftunnel = require('amt-apfclient')({ debug: (settings.debuglevel > 0) }, apfarg); - settings.apftunnel.onJsonControl = configureJsonControl; - settings.apftunnel.onChannelClosed = function () { exit(0); } - try { - settings.apftunnel.connect(); - console.log("Started APF tunnel..."); - } catch (e) { - console.log(JSON.stringify(e)); - exit(1); return; - } } - }); + } } function configureJsonControl(data) { @@ -1476,7 +1484,7 @@ function startLms(func, lmscommander, tag) { try { amtLms = new lme_heci({ debug: settings.lmsdebug }); } catch (ex) { if (func != null) { func(0, tag); } return; } amtLms.promise = ret; amtLms.on('error', function (e) { - //console.log('LME connection failed', e); + console.log('LME connection failed', e); if (lmscommander === true) { //settings.noconsole !== true) { startMeshCommanderLms(); //console.log("LMS started, MeshCommander on HTTP/16994."); @@ -2745,33 +2753,38 @@ function getMeiState(flags, func) { amtMei.on('error', function (e) { func(null); return; }); try { var amtMeiTmpState = { 'core-ver': 1, OsHostname: require('os').hostname(), Flags: 0 }; // Flags: 1=EHBC, 2=CCM, 4=ACM - amtMei.getProtocolVersion(function (result) { if (result != null) { amtMeiTmpState.MeiVersion = result; } }); - if ((flags & 1) != 0) { amtMei.getVersion(function (result) { if (result) { amtMeiTmpState.Versions = {}; for (var version in result.Versions) { amtMeiTmpState.Versions[result.Versions[version].Description] = result.Versions[version].Version; } } }); } - amtMei.getProvisioningMode(function (result) { if (result) { amtMeiTmpState.ProvisioningMode = result.mode; } }); - amtMei.getProvisioningState(function (result) { if (result) { amtMeiTmpState.ProvisioningState = result.state; } }); // 0: "Not Activated (Pre)", 1: "Not Activated (In)", 2: "Activated" - amtMei.getEHBCState(function (result) { if ((result != null) && (result.EHBC == true)) { amtMeiTmpState.Flags += 1; } }); - 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 - //amtMei.getMACAddresses(function (result) { if (result) { amtMeiTmpState.mac = result; } }); - if ((flags & 8) != 0) { - amtMei.getLanInterfaceSettings(0, function (result) { - if (result) { - amtMeiTmpState.net0 = result; - var fqdn = null, interfaces = require('os').networkInterfaces(); // Look for the DNS suffix for the Intel AMT Ethernet interface - for (var i in interfaces) { for (var j in interfaces[i]) { if ((interfaces[i][j].mac == amtMeiTmpState.net0.mac) && (interfaces[i][j].fqdn != null) && (interfaces[i][j].fqdn != '')) { amtMeiTmpState.OsDnsSuffix = interfaces[i][j].fqdn; } } } - } - }); - amtMei.getLanInterfaceSettings(1, function (result) { if (result) { amtMeiTmpState.net1 = result; } }); - } - amtMei.getUuid(function (result) { if ((result != null) && (result.uuid != null)) { amtMeiTmpState.UUID = result.uuid; } }); - if ((flags & 2) != 0) { amtMei.getLocalSystemAccount(function (x) { if ((x != null) && x.user && x.pass) { amtMeiTmpState.OsAdmin = { user: x.user, pass: x.pass }; } }); } - amtMei.getDnsSuffix(function (result) { if (result != null) { amtMeiTmpState.DnsSuffix = result; } if ((flags & 4) == 0) { if (func != null) { func(amtMeiTmpState); } } }); - if ((flags & 4) != 0) { - amtMei.getHashHandles(function (handles) { - if ((handles != null) && (handles.length > 0)) { amtMeiTmpState.Hashes = []; } else { func(amtMeiTmpState); } - var exitOnCount = handles.length; - for (var i = 0; i < handles.length; ++i) { this.getCertHashEntry(handles[i], function (hashresult) { amtMeiTmpState.Hashes.push(hashresult); if (--exitOnCount == 0) { if (func != null) { func(amtMeiTmpState); } } }); } - }); - } + amtMei.getVersion(function (result) { + if (result == null) { func(null); return; } + amtMeiTmpState.Versions = {}; for (var version in result.Versions) { amtMeiTmpState.Versions[result.Versions[version].Description] = result.Versions[version].Version; } + + amtMei.getProtocolVersion(function (result) { if (result != null) { amtMeiTmpState.MeiVersion = result; } }); + //if ((flags & 1) != 0) { amtMei.getVersion(function (result) { if (result) { } }); } + amtMei.getProvisioningMode(function (result) { if (result) { amtMeiTmpState.ProvisioningMode = result.mode; } }); + amtMei.getProvisioningState(function (result) { if (result) { amtMeiTmpState.ProvisioningState = result.state; } }); // 0: "Not Activated (Pre)", 1: "Not Activated (In)", 2: "Activated" + amtMei.getEHBCState(function (result) { if ((result != null) && (result.EHBC == true)) { amtMeiTmpState.Flags += 1; } }); + 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 + //amtMei.getMACAddresses(function (result) { if (result) { amtMeiTmpState.mac = result; } }); + if ((flags & 8) != 0) { + amtMei.getLanInterfaceSettings(0, function (result) { + if (result) { + amtMeiTmpState.net0 = result; + var fqdn = null, interfaces = require('os').networkInterfaces(); // Look for the DNS suffix for the Intel AMT Ethernet interface + for (var i in interfaces) { for (var j in interfaces[i]) { if ((interfaces[i][j].mac == amtMeiTmpState.net0.mac) && (interfaces[i][j].fqdn != null) && (interfaces[i][j].fqdn != '')) { amtMeiTmpState.OsDnsSuffix = interfaces[i][j].fqdn; } } } + } + }); + amtMei.getLanInterfaceSettings(1, function (result) { if (result) { amtMeiTmpState.net1 = result; } }); + } + amtMei.getUuid(function (result) { if ((result != null) && (result.uuid != null)) { amtMeiTmpState.UUID = result.uuid; } }); + if ((flags & 2) != 0) { amtMei.getLocalSystemAccount(function (x) { if ((x != null) && x.user && x.pass) { amtMeiTmpState.OsAdmin = { user: x.user, pass: x.pass }; } }); } + amtMei.getDnsSuffix(function (result) { if (result != null) { amtMeiTmpState.DnsSuffix = result; } if ((flags & 4) == 0) { if (func != null) { func(amtMeiTmpState); } } }); + if ((flags & 4) != 0) { + amtMei.getHashHandles(function (handles) { + if ((handles != null) && (handles.length > 0)) { amtMeiTmpState.Hashes = []; } else { func(amtMeiTmpState); } + var exitOnCount = handles.length; + for (var i = 0; i < handles.length; ++i) { this.getCertHashEntry(handles[i], function (hashresult) { amtMeiTmpState.Hashes.push(hashresult); if (--exitOnCount == 0) { if (func != null) { func(amtMeiTmpState); } } }); } + }); + } + }); } catch (e) { if (func != null) { func(null); } return; } }