From f14d405320918cc4373e1fed10c3f99197e24185 Mon Sep 17 00:00:00 2001 From: Ylian Saint-Hilaire Date: Mon, 28 Oct 2019 18:25:35 -0700 Subject: [PATCH] Fixed broken MeshCMD --- agents/MeshCmd-signed.exe | Bin 4468704 -> 4468952 bytes agents/MeshCmd64-signed.exe | Bin 4083680 -> 4083928 bytes agents/meshcmd.js | 208 ++++++++++++++++++------------------ agents/meshcmd.min.js | 208 ++++++++++++++++++------------------ package.json | 2 +- 5 files changed, 209 insertions(+), 209 deletions(-) diff --git a/agents/MeshCmd-signed.exe b/agents/MeshCmd-signed.exe index fab6f6fbcb8d104de390bd9fdec7a4a00ce17a49..fb0f7950c808f9e4c9df337db486106879840994 100644 GIT binary patch delta 3921 zcma);4O~-I8^GNdU&A3?8$oGBw{r2BE_j%4a&-0w~ zoR14ltHl3qUL~$`h{O@*YNseeJi6baU7{Cui3G%e7a#$=0Uy8@@B{pT-asE90FVNK zfD8x%f`Jeq6bJ+4KscZPlt5pgAJ88d01N~ofJlG>q5v8g1VjUaff#@RVgVKK2oMLv z18N`v&;VK>5l8}t@Vi7qCw%mR-{GOaFd!L70aAhCKpHRtcoawnGJui1-{H(JZ}xGr z<#vwcOwQ>niQ1#+|!+<&&txs2>@!4lVKV zM8J^)>(DQq_4jL0v`9*VkLg0m_YFu&+G>$pMDz0XC`1%OBdZ1MQ6+YpjV<9=GfjqX zKnB?Zxz+9xgfDMESCSx@zd#&-2wHA0wS%0+_rp>UG11^JLi-$t#n&XG(doMk3UlT~A~!bxqDPQn*% zM!$n4gWX;RF;Ua(PRhkPXR^+Ogan$mY()X$zD!Qu%%O}BncM7u3PcB$WJX1TU(b>g z%?=bs_-&}rr@bN3C1)u~@#Dyw*KSAG#Ub=4yW3{&7?(0}5Q3%-DZL;m_%U^;*_Rw> zfZ5p9B&-T~>|I1d5nK;L*KK%2LL%SD^5$QB7gdP8nQVOlL&i3uC>f(Mm2+wrXLp*W zvl@m^e;=v*yqUZS9SwqFd$w462s~664-J=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6+(x!gTx`=}gA~Fsr`wk;!>x;5auy1AL(f zIA_VEE(2%#OZ2eG)!e57_n81kT0*)qa6QSJhBc&l8n%wipK74EfmMusQF)bd?C{HN zwH8>3z)3Vag=A#nRf_l0uIN3^czk*Mlj61CU5<~(X@~SKYkXo~hzWS(wKXBJ7k<0j zy}jw1w$p{n3PMXV1KDeta62fPf39+VbGvQUrwiPNTGpFiDD}9ks##w%R8TRG9-8&` zj>tc(ovXdJttQdis9pIZI!9u)cuiw*Fr-fbod=vwQ8>7rOHKz+h4e| zc-_$wlI3423T$pI+k5-^N5p*Ur|#UcRKG*H`#QuMdau>FI#yK9Kfp{`j6b=&vFok( zWP=~78+KIW=L#Fo9j}%Q%#YZoZW<~-nEVb3?T;8T9Ns?D?WX8fg6GWsm!`J7_1n`ivm zXV%{K;d#0!gIvVL@k4jTD(${ap_QGkGgoiyiy!D#_>3#@c&<(^t9edsKfd&_-}z(3 zE4N<#^Lm}){B75Qv%6#dz5w;NXAUeDUpw2@`umF>cJG+%ni^@`U}x#7BcUZ1o6e?~ z)ou#&nMS6tcXL(C%9i2HOZ(iD-wjFWX)f+v^6l{Tj21ygW^b$G;OojkkMFZ)Z_St= z*ER6b&AlOc7n0L7(Yg)q?Fm@1#Z%Uvq`?=q@mHAo#aCMQ_WU(@Mtsqbf>^QVDFZHyde`)6VPY+f#c|~O|D$L!xt4O!HFz3~am$zg&-gxDM zwy=vwH{Tm>Irq;wzkU)vE6eti((_kYdh~`tS*!5y?-3vB-#K}?RuKFB7guhlN#4#1 Jzv|@V^ndy71>XPw diff --git a/agents/meshcmd.js b/agents/meshcmd.js index 01e82364..e8216e54 100644 --- a/agents/meshcmd.js +++ b/agents/meshcmd.js @@ -1997,13 +1997,13 @@ function kvmSetData(x) { } function startLmsWsmanResponse(stack, name, responses, status) { - if (status == 600) { console.log('ERROR: Unable to connect to Intel(R) AMT.'); } - else if (status != 200) { console.log('ERROR: Unable to get object from Intel(R) AMT, status = ' + status + '.'); } + if (status == 600) { console.log("ERROR: Unable to connect to Intel(R) AMT."); } + else if (status != 200) { console.log("ERROR: Unable to get object from Intel(R) AMT, status = " + status + "."); } else { //console.log(JSON.stringify(responses), status); - var amtlogicalelements = responses["CIM_SoftwareIdentity"].responses; + var amtlogicalelements = responses['CIM_SoftwareIdentity'].responses; if (amtlogicalelements.length > 0) { - var v = getInstance(amtlogicalelements, "AMT")["VersionString"]; + var v = getInstance(amtlogicalelements, 'AMT')['VersionString']; amtversion = parseInt(v.split('.')[0]); amtversionmin = parseInt(v.split('.')[1]); //console.log(amtversion, amtversionmin); @@ -2047,7 +2047,7 @@ function processLmsControlData(data) { function startRouter() { tcpserver = net.createServer(OnTcpClientConnected); - tcpserver.on('error', function (e) { console.log('ERROR: ' + JSON.stringify(e)); exit(0); return; }); + tcpserver.on('error', function (e) { console.log("ERROR: " + JSON.stringify(e)); exit(0); return; }); tcpserver.listen(settings.localport, function () { // We started listening. if (settings.remotetarget == null) { @@ -2055,7 +2055,7 @@ function startRouter() { } else { console.log('Redirecting local port ' + settings.localport + ' to ' + settings.remotetarget + ':' + settings.remoteport + '.'); } - console.log('Press ctrl-c to exit.'); + console.log("Press ctrl-c to exit."); // If settings has a "cmd", run it now. //process.exec("notepad.exe"); @@ -2066,19 +2066,19 @@ function startRouter() { function OnTcpClientConnected(c) { try { // 'connection' listener - debug(1, 'Client connected'); - c.on('end', function () { disconnectTunnel(this, this.websocket, 'Client closed'); }); + debug(1, "Client connected"); + c.on('end', function () { disconnectTunnel(this, this.websocket, "Client closed"); }); c.pause(); try { options = http.parseUri(settings.serverurl + '?user=' + settings.username + '&pass=' + settings.password + '&nodeid=' + settings.remotenodeid + '&tcpport=' + settings.remoteport + (settings.remotetarget == null ? '' : '&tcpaddr=' + settings.remotetarget)); - } catch (e) { console.log('Unable to parse \"serverUrl\".'); process.exit(1); return; } + } catch (e) { console.log("Unable to parse \"serverUrl\"."); process.exit(1); return; } options.checkServerIdentity = onVerifyServer; options.rejectUnauthorized = false; c.websocket = http.request(options); c.websocket.tcp = c; c.websocket.tunneling = false; c.websocket.upgrade = OnWebSocket; - c.websocket.on('error', function (e) { console.log('ERROR: ' + JSON.stringify(e)); }); + c.websocket.on('error', function (e) { console.log("ERROR: " + JSON.stringify(e)); }); c.websocket.end(); } catch (e) { debug(2, e); } } @@ -2087,17 +2087,17 @@ function OnTcpClientConnected(c) { function disconnectTunnel(tcp, ws, msg) { if (ws != null) { try { ws.end(); } catch (e) { debug(2, e); } } if (tcp != null) { try { tcp.end(); } catch (e) { debug(2, e); } } - debug(1, 'Tunnel disconnected: ' + msg); + debug(1, "Tunnel disconnected: " + msg); } // Called when the web socket gets connected function OnWebSocket(msg, s, head) { - debug(1, 'Websocket connected'); + debug(1, "Websocket connected"); s.on('data', function (msg) { if (this.parent.tunneling == false) { msg = msg.toString(); if ((msg == 'c') || (msg == 'cr')) { - this.parent.tunneling = true; this.pipe(this.parent.tcp); this.parent.tcp.pipe(this); debug(1, 'Tunnel active'); + this.parent.tunneling = true; this.pipe(this.parent.tcp); this.parent.tcp.pipe(this); debug(1, "Tunnel active"); } else if ((msg.length > 6) && (msg.substring(0, 6) == 'error:')) { console.log(msg.substring(6)); disconnectTunnel(this.tcp, this, msg.substring(6)); @@ -2110,7 +2110,7 @@ function OnWebSocket(msg, s, head) { } // Try to discover the location of the mesh server -function discoverMeshServer() { console.log('Looking for server...'); discoveryInterval = setInterval(discoverMeshServerOnce, 5000); discoverMeshServerOnce(); } +function discoverMeshServer() { console.log("Looking for server..."); discoveryInterval = setInterval(discoverMeshServerOnce, 5000); discoverMeshServerOnce(); } // Try to discover the location of the mesh server only once function discoverMeshServerOnce() { @@ -2119,9 +2119,9 @@ function discoverMeshServerOnce() { if (interfaces.hasOwnProperty(adapter)) { for (var i = 0; i < interfaces[adapter].length; ++i) { var addr = interfaces[adapter][i]; - multicastSockets[i] = dgram.createSocket({ type: (addr.family == "IPv4" ? "udp4" : "udp6") }); + multicastSockets[i] = dgram.createSocket({ type: (addr.family == 'IPv4' ? 'udp4' : 'udp6') }); multicastSockets[i].bind({ address: addr.address, exclusive: false }); - if (addr.family == "IPv4") { + if (addr.family == 'IPv4') { try { multicastSockets[i].addMembership(membershipIPv4); //multicastSockets[i].setMulticastLoopback(true); @@ -2139,7 +2139,7 @@ function OnMulticastMessage(msg, rinfo) { var m = msg.toString().split('|'); if ((m.length == 3) && (m[0] == 'MeshCentral2') && (m[1] == settings.serverid)) { settings.serverurl = m[2].replace('%s', rinfo.address).replace('/agent.ashx', '/meshrelay.ashx'); - console.log('Found server at ' + settings.serverurl + '.'); + console.log("Found server at " + settings.serverurl + "."); if (discoveryInterval != null) { clearInterval(discoveryInterval); discoveryInterval = null; } startRouter(); } @@ -2182,7 +2182,7 @@ function nextStepStorageUpload2(uploadName, linkName) { } else { console.log("Verifying MeshCommander..."); verifyStorage(uploadName, Buffer.from(settings.webapp, 'base64'), function (verified) { - if (verified == true) { console.log('Done.'); } else { console.log('MeshCommander verification failed.'); } + if (verified == true) { console.log("Done."); } else { console.log("MeshCommander verification failed."); } exit(); return; }); } @@ -2200,7 +2200,7 @@ function nextStepStorageUpload3(deleteName) { // Fetch the Intel AMT storage document function getAmtStorage(func, noretry) { - var req = digest.request({ protocol: settings.protocol, method: "GET", host: settings.hostname, path: "/amt-storage/", port: settings.localport }, + var req = digest.request({ protocol: settings.protocol, method: 'GET', host: settings.hostname, path: '/amt-storage/', port: settings.localport }, function (response) { if (response.statusCode != 200) { console.log("Unable to connect to Intel(R) AMT."); func(response.statusCode, null); } response.on('data', function (chunk) { if (response.acc == null) { response.acc = chunk; } else { response.acc += chunk; } }); @@ -2225,7 +2225,7 @@ function getAmtStorage(func, noretry) { // Fetch the Intel AMT storage document function pushToStorage(name, linkname, data, func, ptr) { if (ptr == null) { ptr = 0; } - var req = digest.request({ protocol: settings.protocol, method: "PUT", host: settings.hostname, path: ("/amt-storage/" + name + ((ptr != 0) ? '?append=' : '')), port: settings.localport }); + var req = digest.request({ protocol: settings.protocol, method: 'PUT', host: settings.hostname, path: ('/amt-storage/' + name + ((ptr != 0) ? '?append=' : '')), port: settings.localport }); req.on('error', function (e) { console.log("Error occured: " + JSON.stringify(e)); if (func != null) { func(null); } }); req.on('response', function (response) { debug(1, 'Chunk Done', data.length, ptr); @@ -2240,7 +2240,7 @@ function pushToStorage(name, linkname, data, func, ptr) { // Fetch the Intel AMT storage document function verifyStorage(name, data, func) { - var req = digest.request({ protocol: settings.protocol, method: "GET", host: settings.hostname, path: ("/amt-storage/" + name), port: settings.localport }); + var req = digest.request({ protocol: settings.protocol, method: 'GET', host: settings.hostname, path: ('/amt-storage/' + name), port: settings.localport }); req.on('error', function (e) { console.log("Verify error occured: " + JSON.stringify(e)); if (func != null) { func(null); } }); req.on('response', function (response) { response.ptr = 0; @@ -2253,8 +2253,8 @@ function verifyStorage(name, data, func) { // Fetch the Intel AMT storage document function deleteStorage(name, func, noretry) { - var req = digest.request({ protocol: settings.protocol, method: "DELETE", host: settings.hostname, path: "/amt-storage/" + name, port: settings.localport }); - req.on('error', function (e) { if ((e == 'Error: Socket was unexpectedly closed') && (noretry != true)) { deleteStorage(name, func, true); } else { if (func != null) { if (e.statusCode) { func(e.statusCode); } else { func(null); } } } }); + var req = digest.request({ protocol: settings.protocol, method: 'DELETE', host: settings.hostname, path: '/amt-storage/' + name, port: settings.localport }); + req.on('error', function (e) { if ((e == "Error: Socket was unexpectedly closed") && (noretry != true)) { deleteStorage(name, func, true); } else { if (func != null) { if (e.statusCode) { func(e.statusCode); } else { func(null); } } } }); req.on('response', function (response) { if (func != null) { func(response.statusCode); } }); req.end(); } @@ -2289,11 +2289,11 @@ function performIder() { } catch (ex) { console.log(ex); } } -function onIderStateChange(stack, state) { console.log(['Disconnected', 'Connecting...', 'Connected...', 'Started IDER...'][state]); } +function onIderStateChange(stack, state) { console.log(["Disconnected", "Connecting...", "Connected...", "Started IDER..."][state]); } function iderSectorStats(mode, dev, mediaBlocks, lba, len) { if (iderIdleTimer != null) { clearTimeout(iderIdleTimer); } - iderIdleTimer = setTimeout(function () { console.log('Idle timeout'); process.exit(1); }, 1000 * settings.timeout); + iderIdleTimer = setTimeout(function () { console.log("Idle timeout"); process.exit(1); }, 1000 * settings.timeout); } // @@ -2325,7 +2325,7 @@ function performAmtNetConfig1(stack, name, response, status, args) { for (var y in response['AMT_EthernetPortSettings'].responses) { var z = response['AMT_EthernetPortSettings'].responses[y]; if (z['WLANLinkProtectionLevel'] || (y == 1)) { amtwirelessif = y; } // Set the wireless interface, this seems to cover new wireless only computers and older computers with dual interfaces. - if (y == 0) { if ((amtwirelessif != y) && (z["MACAddress"] != "00-00-00-00-00-00")) { amtwiredif = y; } } // On computers with only wireless, the wired interface will have a null MAC + if (y == 0) { if ((amtwirelessif != y) && (z['MACAddress'] != '00-00-00-00-00-00')) { amtwiredif = y; } } // On computers with only wireless, the wired interface will have a null MAC } // Check if configuration change is required @@ -2333,13 +2333,13 @@ function performAmtNetConfig1(stack, name, response, status, args) { var docall = false; var x = JSON.parse(JSON.stringify(response['AMT_EthernetPortSettings'].responses[amtwiredif])); var y = response['AMT_EthernetPortSettings'].responses[amtwiredif]; - delete x["IpSyncEnabled"]; - delete x["LinkIsUp"]; - delete x["LinkPolicy"]; - delete x["MACAddress"]; - delete x["SharedDynamicIP"]; - delete x["SharedMAC"]; - delete x["SharedStaticIp"]; + delete x['IpSyncEnabled']; + delete x['LinkIsUp']; + delete x['LinkPolicy']; + delete x['MACAddress']; + delete x['SharedDynamicIP']; + delete x['SharedMAC']; + delete x['SharedStaticIp']; if ((y['IpSyncEnabled'] == false) && (args.ipsync === '1')) { x['IpSyncEnabled'] = true; docall = true; } if ((y['IpSyncEnabled'] == true) && (args.ipsync === '0')) { x['IpSyncEnabled'] = false; docall = true; } @@ -2351,24 +2351,24 @@ function performAmtNetConfig1(stack, name, response, status, args) { else if (args.static && (amtwiredif != -1) && (response['AMT_EthernetPortSettings'].responses[amtwiredif].DHCPEnabled == true)) { // Change to STATIC x['DHCPEnabled'] = false; - if (args.ip) { x["IPAddress"] = args.ip; } else { console.log('Missing IPv4 address, use --ip 1.2.3.4'); process.exit(1); } - if (args.subnet) { x["SubnetMask"] = args.subnet; } else { console.log('Missing IPv4 subnet, use --subnet 255.255.255.0'); process.exit(1); } - if (args.gateway) { x["DefaultGateway"] = args.gateway; } - if (args.dns) { x["PrimaryDNS"] = args.dns; } - if (args.dns2) { x["SecondaryDNS"] = args.dns2; } + if (args.ip) { x['IPAddress'] = args.ip; } else { console.log("Missing IPv4 address, use --ip 1.2.3.4"); process.exit(1); } + if (args.subnet) { x['SubnetMask'] = args.subnet; } else { console.log("Missing IPv4 subnet, use --subnet 255.255.255.0"); process.exit(1); } + if (args.gateway) { x['DefaultGateway'] = args.gateway; } + if (args.dns) { x['PrimaryDNS'] = args.dns; } + if (args.dns2) { x['SecondaryDNS'] = args.dns2; } docall = true; } if (docall) { - if (x["DHCPEnabled"] == true) { - delete x["IPAddress"]; - delete x["DefaultGateway"]; - delete x["PrimaryDNS"]; - delete x["SecondaryDNS"]; - delete x["SubnetMask"]; + if (x['DHCPEnabled'] == true) { + delete x['IPAddress']; + delete x['DefaultGateway']; + delete x['PrimaryDNS']; + delete x['SecondaryDNS']; + delete x['SubnetMask']; } pendingAmtConfigActions++; //console.log(JSON.stringify(x, 4, ' ')); - amtstack.Put("AMT_EthernetPortSettings", x, function (stack, name, response, status) { if (status != 200) { console.log('Error, status ' + status + '.'); } if (--pendingAmtConfigActions == 0) { performAmtNetConfig0(); } }, null, 0, x); + amtstack.Put('AMT_EthernetPortSettings', x, function (stack, name, response, status) { if (status != 200) { console.log("Error, status " + status + "."); } if (--pendingAmtConfigActions == 0) { performAmtNetConfig0(); } }, null, 0, x); } } @@ -2379,7 +2379,7 @@ function performAmtNetConfig1(stack, name, response, status, args) { if (amtwiredif != -1) { // Wired var z = response['AMT_EthernetPortSettings'].responses[amtwiredif]; - console.log('--WIRED---'); + console.log("--WIRED---"); for (var i in z) { if (['ElementName', 'InstanceID'].indexOf(i) == -1) { var name = i; @@ -2390,7 +2390,7 @@ function performAmtNetConfig1(stack, name, response, status, args) { } if (amtwirelessif != -1) { // Wireless var z = response['AMT_EthernetPortSettings'].responses[amtwirelessif]; - console.log('--WIRELESS---'); + console.log("--WIRELESS---"); for (var i in z) { if (['ElementName', 'InstanceID'].indexOf(i) == -1) { var name = i; @@ -2402,7 +2402,7 @@ function performAmtNetConfig1(stack, name, response, status, args) { process.exit(0); } } else { - console.log('Error, status ' + status + '.'); + console.log("Error, status " + status + "."); process.exit(1); } } @@ -2432,35 +2432,35 @@ function performAmtFeatureConfig0(state, args) { function performAmtFeatureConfig1(stack, name, response, status, args) { if (status == 200) { // User consent - var optinrequired = response['IPS_OptInService'].response["OptInRequired"]; + var optinrequired = response['IPS_OptInService'].response['OptInRequired']; if (args) { if ((args.userconsent == 'none') && (optinrequired != 0)) { pendingAmtConfigActions++; - response['IPS_OptInService'].response["OptInRequired"] = 0; - amtstack.Put("IPS_OptInService", response['IPS_OptInService'].response, function (stack, name, response, status) { if (--pendingAmtConfigActions == 0) { performAmtFeatureConfig0(); } }); + response['IPS_OptInService'].response['OptInRequired'] = 0; + amtstack.Put('IPS_OptInService', response['IPS_OptInService'].response, function (stack, name, response, status) { if (--pendingAmtConfigActions == 0) { performAmtFeatureConfig0(); } }); } else if ((args.userconsent == 'kvm') && (optinrequired != 1)) { pendingAmtConfigActions++; - response['IPS_OptInService'].response["OptInRequired"] = 1; - amtstack.Put("IPS_OptInService", response['IPS_OptInService'].response, function (stack, name, response, status) { if (--pendingAmtConfigActions == 0) { performAmtFeatureConfig0(); } }); + response['IPS_OptInService'].response['OptInRequired'] = 1; + amtstack.Put('IPS_OptInService', response['IPS_OptInService'].response, function (stack, name, response, status) { if (--pendingAmtConfigActions == 0) { performAmtFeatureConfig0(); } }); } else if ((args.userconsent == 'all') && (optinrequired != 0xFFFFFFFF)) { pendingAmtConfigActions++; - response['IPS_OptInService'].response["OptInRequired"] = 0xFFFFFFFF; - amtstack.Put("IPS_OptInService", response['IPS_OptInService'].response, function (stack, name, response, status) { if (--pendingAmtConfigActions == 0) { performAmtFeatureConfig0(); } }); + response['IPS_OptInService'].response['OptInRequired'] = 0xFFFFFFFF; + amtstack.Put('IPS_OptInService', response['IPS_OptInService'].response, function (stack, name, response, status) { if (--pendingAmtConfigActions == 0) { performAmtFeatureConfig0(); } }); } } // Redirection ports var redirportchange = false; var redirchange = false; - var redir = (response['AMT_RedirectionService'].response["ListenerEnabled"] == true); + var redir = (response['AMT_RedirectionService'].response['ListenerEnabled'] == true); - var sol = ((response['AMT_RedirectionService'].response["EnabledState"] & 2) != 0); - var ider = ((response['AMT_RedirectionService'].response["EnabledState"] & 1) != 0); + var sol = ((response['AMT_RedirectionService'].response['EnabledState'] & 2) != 0); + var ider = ((response['AMT_RedirectionService'].response['EnabledState'] & 1) != 0); if (args) { - if ((redir == false) && ((args.redir == 'enabled') || (args.redir == 1))) { response['AMT_RedirectionService'].response["ListenerEnabled"] = true; redirportchange = true; } - if ((redir == true) && ((args.redir == 'disabled') || (args.redir == 0))) { response['AMT_RedirectionService'].response["ListenerEnabled"] = false; redirportchange = true; } + if ((redir == false) && ((args.redir == 'enabled') || (args.redir == 1))) { response['AMT_RedirectionService'].response['ListenerEnabled'] = true; redirportchange = true; } + if ((redir == true) && ((args.redir == 'disabled') || (args.redir == 0))) { response['AMT_RedirectionService'].response['ListenerEnabled'] = false; redirportchange = true; } if ((sol == false) && ((args.sol == 'enabled') || (args.sol == 1))) { sol = true; redirchange = true; } if ((sol == true) && ((args.sol == 'disabled') || (args.sol == 0))) { sol = false; redirchange = true; } if ((ider == false) && ((args.ider == 'enabled') || (args.ider == 1))) { ider = true; redirchange = true; } @@ -2473,7 +2473,7 @@ function performAmtFeatureConfig1(stack, name, response, status, args) { var kvm = false; var kvmchange = false; if (response['CIM_KVMRedirectionSAP'] != null) { - kvm = ((response['CIM_KVMRedirectionSAP'].response["EnabledState"] == 6 && response['CIM_KVMRedirectionSAP'].response["RequestedState"] == 2) || response['CIM_KVMRedirectionSAP'].response["EnabledState"] == 2 || response['CIM_KVMRedirectionSAP'].response["EnabledState"] == 6); + kvm = ((response['CIM_KVMRedirectionSAP'].response["EnabledState"] == 6 && response['CIM_KVMRedirectionSAP'].response['RequestedState'] == 2) || response['CIM_KVMRedirectionSAP'].response['EnabledState'] == 2 || response['CIM_KVMRedirectionSAP'].response['EnabledState'] == 6); if (args) { if ((kvm == false) && ((args.kvm == 'enabled') || (args.kvm == 1))) { kvm = true; kvmchange = true; } if ((kvm == true) && ((args.kvm == 'disabled') || (args.kvm == 0))) { kvm = false; kvmchange = true; } @@ -2482,18 +2482,18 @@ function performAmtFeatureConfig1(stack, name, response, status, args) { } if (pendingAmtConfigActions == 0) { - if (optinrequired == 0) { console.log('User Consent : None'); } - else if (optinrequired == 1) { console.log('User Consent : KVM'); } - else if (optinrequired == 0xFFFFFFFF) { console.log('User Consent : All'); } - else { console.log('User Consent : ' + optinrequired); } - console.log('Redirection Port : ' + (redir ? 'Enabled' : 'Disabled')); - console.log('Serial-over-LAN : ' + (sol ? 'Enabled' : 'Disabled')); - console.log('IDE Redirection : ' + (ider ? 'Enabled' : 'Disabled')); - if (response['CIM_KVMRedirectionSAP'] != null) { console.log('Remote desktop (KVM) : ' + (kvm ? 'Enabled' : 'Disabled')); } + if (optinrequired == 0) { console.log("User Consent : None"); } + else if (optinrequired == 1) { console.log("User Consent : KVM"); } + else if (optinrequired == 0xFFFFFFFF) { console.log("User Consent : All"); } + else { console.log("User Consent : " + optinrequired); } + console.log("Redirection Port : " + (redir ? "Enabled" : "Disabled")); + console.log("Serial-over-LAN : " + (sol ? "Enabled" : "Disabled")); + console.log("IDE Redirection : " + (ider ? "Enabled" : 'Disabled')); + if (response['CIM_KVMRedirectionSAP'] != null) { console.log("Remote desktop (KVM) : " + (kvm ? "Enabled" : "Disabled")); } process.exit(0); } } else { - console.log('Error, status ' + status + '.'); + console.log("Error, status " + status + "."); process.exit(1); } } @@ -2514,7 +2514,7 @@ function performAmtPowerAction() { amtstack.RequestPowerStateChange(settings.poweraction, performAmtPowerActionEx); } else { // Get the power state - amtstack.Get("CIM_AssociatedPowerManagementService", performAmtPowerActionEx2, 0, 1); + amtstack.Get('CIM_AssociatedPowerManagementService', performAmtPowerActionEx2, 0, 1); } } @@ -2523,23 +2523,23 @@ function performAmtPowerActionEx(stack, name, response, status) { console.log(response.Body.ReturnValueStr.split('_').join(' ')); process.exit(0); } else { - console.log('Error, status ' + status + '.'); + console.log("Error, status " + status + "."); process.exit(1); } } -var DMTFPowerStates = ["", "", "Power on", "Light sleep", "Deep sleep", "Power cycle (Soft off)", "Off - Hard", "Hibernate (Off soft)", "Soft off", "Power cycle (Off-hard)", "Master bus reset", "Diagnostic interrupt (NMI)", "Not applicable", "Off - Soft graceful", "Off - Hard graceful", "Master bus reset graceful", "Power cycle (Off - Soft graceful)", "Power cycle (Off - Hard graceful)", "Diagnostic interrupt (INIT)"]; +var DMTFPowerStates = ['', '', "Power on", "Light sleep", "Deep sleep", "Power cycle (Soft off)", "Off - Hard", "Hibernate (Off soft)", "Soft off", "Power cycle (Off-hard)", "Master bus reset", "Diagnostic interrupt (NMI)", "Not applicable", "Off - Soft graceful", "Off - Hard graceful", "Master bus reset graceful", "Power cycle (Off - Soft graceful)", "Power cycle (Off - Hard graceful)", "Diagnostic interrupt (INIT)"]; function performAmtPowerActionEx2(stack, name, response, status) { if (status == 200) { var powerNumber = parseInt(response.Body.PowerState); if ((powerNumber >= DMTFPowerStates.length) && (powerNumber > 1)) { - console.log('Unknown power state: ' + response.Body.PowerState); + console.log("Unknown power state: " + response.Body.PowerState); } else { - console.log('Current power state: ' + DMTFPowerStates[powerNumber]); + console.log("Current power state: " + DMTFPowerStates[powerNumber]); } process.exit(0); } else { - console.log('Error, status ' + status + '.'); + console.log("Error, status " + status + "."); process.exit(1); } } @@ -2571,16 +2571,16 @@ for (var i in process.argv) { if (process.argv[i].toLowerCase() == 'uninstall') { process.argv[i] = '-uninstall'; } if ((process.argv[i].toLowerCase() == 'microlms') || (process.argv[i].toLowerCase() == 'amtlms') || (process.argv[i].toLowerCase() == 'lms')) { serviceName = 'MicroLMS'; - serviceDisplayName = 'MicroLMS Service for Intel(R) AMT'; - serviceDesc = 'Intel AMT Micro Local Manageability Service (MicroLMS)'; + serviceDisplayName = "MicroLMS Service for Intel(R) AMT"; + serviceDesc = "Intel AMT Micro Local Manageability Service (MicroLMS)"; } else if ((process.argv[i].toLowerCase() == 'intellms')) { serviceName = 'LMS'; - serviceDisplayName = 'Intel(R) Management and Security Application Local Management Service'; - serviceDesc = 'Intel(R) Management and Security Application Local Management Service - Provides OS-related Intel(R) ME functionality.'; + serviceDisplayName = "Intel(R) Management and Security Application Local Management Service"; + serviceDesc = "Intel(R) Management and Security Application Local Management Service - Provides OS-related Intel(R) ME functionality."; } else if ((process.argv[i].toLowerCase() == 'meshcommander') || (process.argv[i].toLowerCase() == 'commander')) { serviceName = 'MeshCommander'; - serviceDisplayName = 'MeshCommander, Intel AMT Management console'; - serviceDesc = 'MeshCommander is a Intel AMT management console.'; + serviceDisplayName = "MeshCommander, Intel AMT Management console"; + serviceDesc = "MeshCommander is a Intel AMT management console."; } } @@ -2589,29 +2589,29 @@ if (serviceName == null) { else if (process.execPath.includes('LMS')) { serviceName = 'LMS'; } else if (process.execPath.includes('MeshCommander')) { serviceName = 'MeshCommander'; } if (serviceName == null) { for (var i in process.argv) { if ((process.argv[i].toLowerCase() == '-install') || (process.argv[i].toLowerCase() == '-uninstall')) { console.log('In order to install/uninstall, a service type must be specified.'); process.exit(); } } } - if (serviceName == null) { try { run(process.argv); } catch (e) { console.log('ERROR: ' + e); } process.exit(); } -} + if (serviceName == null) { try { run(process.argv); } catch (e) { console.log("ERROR: " + e); } } +} else { + var serviceHost = require('service-host'); + var meshcmdService = new serviceHost({ name: serviceName, displayName: serviceDisplayName, startType: 'AUTO_START', description: serviceDesc }); -var serviceHost = require('service-host'); -var meshcmdService = new serviceHost({ name: serviceName, displayName: serviceDisplayName, startType: 'AUTO_START', description: serviceDesc }); + // Called when the background service is started. + meshcmdService.on('serviceStart', function onStart() { + //process.coreDumpLocation = 'C:\\tmp\\meshcommander.dmp'; + //process.on('exit', function () { console.log('exit3'); _debugCrash(); }); + console.setDestination(console.Destinations.DISABLED); // Disable console.log(). + //console.setDestination(console.Destinations.LOGFILE); + //attachDebuger({ webport: 0, wait: 1 }).then(console.log, console.log); -// Called when the background service is started. -meshcmdService.on('serviceStart', function onStart() { - //process.coreDumpLocation = 'C:\\tmp\\meshcommander.dmp'; - //process.on('exit', function () { console.log('exit3'); _debugCrash(); }); - console.setDestination(console.Destinations.DISABLED); // Disable console.log(). - //console.setDestination(console.Destinations.LOGFILE); - //attachDebuger({ webport: 0, wait: 1 }).then(console.log, console.log); + if (process.execPath.includes('MicroLMS')) { run([process.execPath, 'microlms']); } // Start MicroLMS + else if (process.execPath.includes('LMS')) { run([process.execPath, 'microlms']); } // Start MicroLMS + else if (process.execPath.includes('MeshCommander')) { run([process.execPath, 'meshcommander']); } // Start MeshCommander + else { console.log("Aborting Service Start, because unknown binary: " + process.execPath); process.exit(1); } + }); - if (process.execPath.includes('MicroLMS')) { run([process.execPath, 'microlms']); } // Start MicroLMS - else if (process.execPath.includes('LMS')) { run([process.execPath, 'microlms']); } // Start MicroLMS - else if (process.execPath.includes('MeshCommander')) { run([process.execPath, 'meshcommander']); } // Start MeshCommander - else { console.log('Aborting Service Start, because unknown binary: ' + process.execPath); process.exit(1); } -}); + // Called when the background service is stopping + meshcmdService.on('serviceStop', function onStop() { console.log("Stopping service"); process.exit(); }); // The console.log() is for debugging, will be ignored unless "console.setDestination()" is set. -// Called when the background service is stopping -meshcmdService.on('serviceStop', function onStop() { console.log('Stopping service'); process.exit(); }); // The console.log() is for debugging, will be ignored unless "console.setDestination()" is set. - -// Called when the executable is not running as a service, run normally. -meshcmdService.on('normalStart', function onNormalStart() { try { run(process.argv); } catch (e) { console.log('ERROR: ' + e); } }); -meshcmdService.run(); + // Called when the executable is not running as a service, run normally. + meshcmdService.on('normalStart', function onNormalStart() { try { run(process.argv); } catch (e) { console.log("ERROR: " + e); } }); + meshcmdService.run(); +} \ No newline at end of file diff --git a/agents/meshcmd.min.js b/agents/meshcmd.min.js index 01e82364..e8216e54 100644 --- a/agents/meshcmd.min.js +++ b/agents/meshcmd.min.js @@ -1997,13 +1997,13 @@ function kvmSetData(x) { } function startLmsWsmanResponse(stack, name, responses, status) { - if (status == 600) { console.log('ERROR: Unable to connect to Intel(R) AMT.'); } - else if (status != 200) { console.log('ERROR: Unable to get object from Intel(R) AMT, status = ' + status + '.'); } + if (status == 600) { console.log("ERROR: Unable to connect to Intel(R) AMT."); } + else if (status != 200) { console.log("ERROR: Unable to get object from Intel(R) AMT, status = " + status + "."); } else { //console.log(JSON.stringify(responses), status); - var amtlogicalelements = responses["CIM_SoftwareIdentity"].responses; + var amtlogicalelements = responses['CIM_SoftwareIdentity'].responses; if (amtlogicalelements.length > 0) { - var v = getInstance(amtlogicalelements, "AMT")["VersionString"]; + var v = getInstance(amtlogicalelements, 'AMT')['VersionString']; amtversion = parseInt(v.split('.')[0]); amtversionmin = parseInt(v.split('.')[1]); //console.log(amtversion, amtversionmin); @@ -2047,7 +2047,7 @@ function processLmsControlData(data) { function startRouter() { tcpserver = net.createServer(OnTcpClientConnected); - tcpserver.on('error', function (e) { console.log('ERROR: ' + JSON.stringify(e)); exit(0); return; }); + tcpserver.on('error', function (e) { console.log("ERROR: " + JSON.stringify(e)); exit(0); return; }); tcpserver.listen(settings.localport, function () { // We started listening. if (settings.remotetarget == null) { @@ -2055,7 +2055,7 @@ function startRouter() { } else { console.log('Redirecting local port ' + settings.localport + ' to ' + settings.remotetarget + ':' + settings.remoteport + '.'); } - console.log('Press ctrl-c to exit.'); + console.log("Press ctrl-c to exit."); // If settings has a "cmd", run it now. //process.exec("notepad.exe"); @@ -2066,19 +2066,19 @@ function startRouter() { function OnTcpClientConnected(c) { try { // 'connection' listener - debug(1, 'Client connected'); - c.on('end', function () { disconnectTunnel(this, this.websocket, 'Client closed'); }); + debug(1, "Client connected"); + c.on('end', function () { disconnectTunnel(this, this.websocket, "Client closed"); }); c.pause(); try { options = http.parseUri(settings.serverurl + '?user=' + settings.username + '&pass=' + settings.password + '&nodeid=' + settings.remotenodeid + '&tcpport=' + settings.remoteport + (settings.remotetarget == null ? '' : '&tcpaddr=' + settings.remotetarget)); - } catch (e) { console.log('Unable to parse \"serverUrl\".'); process.exit(1); return; } + } catch (e) { console.log("Unable to parse \"serverUrl\"."); process.exit(1); return; } options.checkServerIdentity = onVerifyServer; options.rejectUnauthorized = false; c.websocket = http.request(options); c.websocket.tcp = c; c.websocket.tunneling = false; c.websocket.upgrade = OnWebSocket; - c.websocket.on('error', function (e) { console.log('ERROR: ' + JSON.stringify(e)); }); + c.websocket.on('error', function (e) { console.log("ERROR: " + JSON.stringify(e)); }); c.websocket.end(); } catch (e) { debug(2, e); } } @@ -2087,17 +2087,17 @@ function OnTcpClientConnected(c) { function disconnectTunnel(tcp, ws, msg) { if (ws != null) { try { ws.end(); } catch (e) { debug(2, e); } } if (tcp != null) { try { tcp.end(); } catch (e) { debug(2, e); } } - debug(1, 'Tunnel disconnected: ' + msg); + debug(1, "Tunnel disconnected: " + msg); } // Called when the web socket gets connected function OnWebSocket(msg, s, head) { - debug(1, 'Websocket connected'); + debug(1, "Websocket connected"); s.on('data', function (msg) { if (this.parent.tunneling == false) { msg = msg.toString(); if ((msg == 'c') || (msg == 'cr')) { - this.parent.tunneling = true; this.pipe(this.parent.tcp); this.parent.tcp.pipe(this); debug(1, 'Tunnel active'); + this.parent.tunneling = true; this.pipe(this.parent.tcp); this.parent.tcp.pipe(this); debug(1, "Tunnel active"); } else if ((msg.length > 6) && (msg.substring(0, 6) == 'error:')) { console.log(msg.substring(6)); disconnectTunnel(this.tcp, this, msg.substring(6)); @@ -2110,7 +2110,7 @@ function OnWebSocket(msg, s, head) { } // Try to discover the location of the mesh server -function discoverMeshServer() { console.log('Looking for server...'); discoveryInterval = setInterval(discoverMeshServerOnce, 5000); discoverMeshServerOnce(); } +function discoverMeshServer() { console.log("Looking for server..."); discoveryInterval = setInterval(discoverMeshServerOnce, 5000); discoverMeshServerOnce(); } // Try to discover the location of the mesh server only once function discoverMeshServerOnce() { @@ -2119,9 +2119,9 @@ function discoverMeshServerOnce() { if (interfaces.hasOwnProperty(adapter)) { for (var i = 0; i < interfaces[adapter].length; ++i) { var addr = interfaces[adapter][i]; - multicastSockets[i] = dgram.createSocket({ type: (addr.family == "IPv4" ? "udp4" : "udp6") }); + multicastSockets[i] = dgram.createSocket({ type: (addr.family == 'IPv4' ? 'udp4' : 'udp6') }); multicastSockets[i].bind({ address: addr.address, exclusive: false }); - if (addr.family == "IPv4") { + if (addr.family == 'IPv4') { try { multicastSockets[i].addMembership(membershipIPv4); //multicastSockets[i].setMulticastLoopback(true); @@ -2139,7 +2139,7 @@ function OnMulticastMessage(msg, rinfo) { var m = msg.toString().split('|'); if ((m.length == 3) && (m[0] == 'MeshCentral2') && (m[1] == settings.serverid)) { settings.serverurl = m[2].replace('%s', rinfo.address).replace('/agent.ashx', '/meshrelay.ashx'); - console.log('Found server at ' + settings.serverurl + '.'); + console.log("Found server at " + settings.serverurl + "."); if (discoveryInterval != null) { clearInterval(discoveryInterval); discoveryInterval = null; } startRouter(); } @@ -2182,7 +2182,7 @@ function nextStepStorageUpload2(uploadName, linkName) { } else { console.log("Verifying MeshCommander..."); verifyStorage(uploadName, Buffer.from(settings.webapp, 'base64'), function (verified) { - if (verified == true) { console.log('Done.'); } else { console.log('MeshCommander verification failed.'); } + if (verified == true) { console.log("Done."); } else { console.log("MeshCommander verification failed."); } exit(); return; }); } @@ -2200,7 +2200,7 @@ function nextStepStorageUpload3(deleteName) { // Fetch the Intel AMT storage document function getAmtStorage(func, noretry) { - var req = digest.request({ protocol: settings.protocol, method: "GET", host: settings.hostname, path: "/amt-storage/", port: settings.localport }, + var req = digest.request({ protocol: settings.protocol, method: 'GET', host: settings.hostname, path: '/amt-storage/', port: settings.localport }, function (response) { if (response.statusCode != 200) { console.log("Unable to connect to Intel(R) AMT."); func(response.statusCode, null); } response.on('data', function (chunk) { if (response.acc == null) { response.acc = chunk; } else { response.acc += chunk; } }); @@ -2225,7 +2225,7 @@ function getAmtStorage(func, noretry) { // Fetch the Intel AMT storage document function pushToStorage(name, linkname, data, func, ptr) { if (ptr == null) { ptr = 0; } - var req = digest.request({ protocol: settings.protocol, method: "PUT", host: settings.hostname, path: ("/amt-storage/" + name + ((ptr != 0) ? '?append=' : '')), port: settings.localport }); + var req = digest.request({ protocol: settings.protocol, method: 'PUT', host: settings.hostname, path: ('/amt-storage/' + name + ((ptr != 0) ? '?append=' : '')), port: settings.localport }); req.on('error', function (e) { console.log("Error occured: " + JSON.stringify(e)); if (func != null) { func(null); } }); req.on('response', function (response) { debug(1, 'Chunk Done', data.length, ptr); @@ -2240,7 +2240,7 @@ function pushToStorage(name, linkname, data, func, ptr) { // Fetch the Intel AMT storage document function verifyStorage(name, data, func) { - var req = digest.request({ protocol: settings.protocol, method: "GET", host: settings.hostname, path: ("/amt-storage/" + name), port: settings.localport }); + var req = digest.request({ protocol: settings.protocol, method: 'GET', host: settings.hostname, path: ('/amt-storage/' + name), port: settings.localport }); req.on('error', function (e) { console.log("Verify error occured: " + JSON.stringify(e)); if (func != null) { func(null); } }); req.on('response', function (response) { response.ptr = 0; @@ -2253,8 +2253,8 @@ function verifyStorage(name, data, func) { // Fetch the Intel AMT storage document function deleteStorage(name, func, noretry) { - var req = digest.request({ protocol: settings.protocol, method: "DELETE", host: settings.hostname, path: "/amt-storage/" + name, port: settings.localport }); - req.on('error', function (e) { if ((e == 'Error: Socket was unexpectedly closed') && (noretry != true)) { deleteStorage(name, func, true); } else { if (func != null) { if (e.statusCode) { func(e.statusCode); } else { func(null); } } } }); + var req = digest.request({ protocol: settings.protocol, method: 'DELETE', host: settings.hostname, path: '/amt-storage/' + name, port: settings.localport }); + req.on('error', function (e) { if ((e == "Error: Socket was unexpectedly closed") && (noretry != true)) { deleteStorage(name, func, true); } else { if (func != null) { if (e.statusCode) { func(e.statusCode); } else { func(null); } } } }); req.on('response', function (response) { if (func != null) { func(response.statusCode); } }); req.end(); } @@ -2289,11 +2289,11 @@ function performIder() { } catch (ex) { console.log(ex); } } -function onIderStateChange(stack, state) { console.log(['Disconnected', 'Connecting...', 'Connected...', 'Started IDER...'][state]); } +function onIderStateChange(stack, state) { console.log(["Disconnected", "Connecting...", "Connected...", "Started IDER..."][state]); } function iderSectorStats(mode, dev, mediaBlocks, lba, len) { if (iderIdleTimer != null) { clearTimeout(iderIdleTimer); } - iderIdleTimer = setTimeout(function () { console.log('Idle timeout'); process.exit(1); }, 1000 * settings.timeout); + iderIdleTimer = setTimeout(function () { console.log("Idle timeout"); process.exit(1); }, 1000 * settings.timeout); } // @@ -2325,7 +2325,7 @@ function performAmtNetConfig1(stack, name, response, status, args) { for (var y in response['AMT_EthernetPortSettings'].responses) { var z = response['AMT_EthernetPortSettings'].responses[y]; if (z['WLANLinkProtectionLevel'] || (y == 1)) { amtwirelessif = y; } // Set the wireless interface, this seems to cover new wireless only computers and older computers with dual interfaces. - if (y == 0) { if ((amtwirelessif != y) && (z["MACAddress"] != "00-00-00-00-00-00")) { amtwiredif = y; } } // On computers with only wireless, the wired interface will have a null MAC + if (y == 0) { if ((amtwirelessif != y) && (z['MACAddress'] != '00-00-00-00-00-00')) { amtwiredif = y; } } // On computers with only wireless, the wired interface will have a null MAC } // Check if configuration change is required @@ -2333,13 +2333,13 @@ function performAmtNetConfig1(stack, name, response, status, args) { var docall = false; var x = JSON.parse(JSON.stringify(response['AMT_EthernetPortSettings'].responses[amtwiredif])); var y = response['AMT_EthernetPortSettings'].responses[amtwiredif]; - delete x["IpSyncEnabled"]; - delete x["LinkIsUp"]; - delete x["LinkPolicy"]; - delete x["MACAddress"]; - delete x["SharedDynamicIP"]; - delete x["SharedMAC"]; - delete x["SharedStaticIp"]; + delete x['IpSyncEnabled']; + delete x['LinkIsUp']; + delete x['LinkPolicy']; + delete x['MACAddress']; + delete x['SharedDynamicIP']; + delete x['SharedMAC']; + delete x['SharedStaticIp']; if ((y['IpSyncEnabled'] == false) && (args.ipsync === '1')) { x['IpSyncEnabled'] = true; docall = true; } if ((y['IpSyncEnabled'] == true) && (args.ipsync === '0')) { x['IpSyncEnabled'] = false; docall = true; } @@ -2351,24 +2351,24 @@ function performAmtNetConfig1(stack, name, response, status, args) { else if (args.static && (amtwiredif != -1) && (response['AMT_EthernetPortSettings'].responses[amtwiredif].DHCPEnabled == true)) { // Change to STATIC x['DHCPEnabled'] = false; - if (args.ip) { x["IPAddress"] = args.ip; } else { console.log('Missing IPv4 address, use --ip 1.2.3.4'); process.exit(1); } - if (args.subnet) { x["SubnetMask"] = args.subnet; } else { console.log('Missing IPv4 subnet, use --subnet 255.255.255.0'); process.exit(1); } - if (args.gateway) { x["DefaultGateway"] = args.gateway; } - if (args.dns) { x["PrimaryDNS"] = args.dns; } - if (args.dns2) { x["SecondaryDNS"] = args.dns2; } + if (args.ip) { x['IPAddress'] = args.ip; } else { console.log("Missing IPv4 address, use --ip 1.2.3.4"); process.exit(1); } + if (args.subnet) { x['SubnetMask'] = args.subnet; } else { console.log("Missing IPv4 subnet, use --subnet 255.255.255.0"); process.exit(1); } + if (args.gateway) { x['DefaultGateway'] = args.gateway; } + if (args.dns) { x['PrimaryDNS'] = args.dns; } + if (args.dns2) { x['SecondaryDNS'] = args.dns2; } docall = true; } if (docall) { - if (x["DHCPEnabled"] == true) { - delete x["IPAddress"]; - delete x["DefaultGateway"]; - delete x["PrimaryDNS"]; - delete x["SecondaryDNS"]; - delete x["SubnetMask"]; + if (x['DHCPEnabled'] == true) { + delete x['IPAddress']; + delete x['DefaultGateway']; + delete x['PrimaryDNS']; + delete x['SecondaryDNS']; + delete x['SubnetMask']; } pendingAmtConfigActions++; //console.log(JSON.stringify(x, 4, ' ')); - amtstack.Put("AMT_EthernetPortSettings", x, function (stack, name, response, status) { if (status != 200) { console.log('Error, status ' + status + '.'); } if (--pendingAmtConfigActions == 0) { performAmtNetConfig0(); } }, null, 0, x); + amtstack.Put('AMT_EthernetPortSettings', x, function (stack, name, response, status) { if (status != 200) { console.log("Error, status " + status + "."); } if (--pendingAmtConfigActions == 0) { performAmtNetConfig0(); } }, null, 0, x); } } @@ -2379,7 +2379,7 @@ function performAmtNetConfig1(stack, name, response, status, args) { if (amtwiredif != -1) { // Wired var z = response['AMT_EthernetPortSettings'].responses[amtwiredif]; - console.log('--WIRED---'); + console.log("--WIRED---"); for (var i in z) { if (['ElementName', 'InstanceID'].indexOf(i) == -1) { var name = i; @@ -2390,7 +2390,7 @@ function performAmtNetConfig1(stack, name, response, status, args) { } if (amtwirelessif != -1) { // Wireless var z = response['AMT_EthernetPortSettings'].responses[amtwirelessif]; - console.log('--WIRELESS---'); + console.log("--WIRELESS---"); for (var i in z) { if (['ElementName', 'InstanceID'].indexOf(i) == -1) { var name = i; @@ -2402,7 +2402,7 @@ function performAmtNetConfig1(stack, name, response, status, args) { process.exit(0); } } else { - console.log('Error, status ' + status + '.'); + console.log("Error, status " + status + "."); process.exit(1); } } @@ -2432,35 +2432,35 @@ function performAmtFeatureConfig0(state, args) { function performAmtFeatureConfig1(stack, name, response, status, args) { if (status == 200) { // User consent - var optinrequired = response['IPS_OptInService'].response["OptInRequired"]; + var optinrequired = response['IPS_OptInService'].response['OptInRequired']; if (args) { if ((args.userconsent == 'none') && (optinrequired != 0)) { pendingAmtConfigActions++; - response['IPS_OptInService'].response["OptInRequired"] = 0; - amtstack.Put("IPS_OptInService", response['IPS_OptInService'].response, function (stack, name, response, status) { if (--pendingAmtConfigActions == 0) { performAmtFeatureConfig0(); } }); + response['IPS_OptInService'].response['OptInRequired'] = 0; + amtstack.Put('IPS_OptInService', response['IPS_OptInService'].response, function (stack, name, response, status) { if (--pendingAmtConfigActions == 0) { performAmtFeatureConfig0(); } }); } else if ((args.userconsent == 'kvm') && (optinrequired != 1)) { pendingAmtConfigActions++; - response['IPS_OptInService'].response["OptInRequired"] = 1; - amtstack.Put("IPS_OptInService", response['IPS_OptInService'].response, function (stack, name, response, status) { if (--pendingAmtConfigActions == 0) { performAmtFeatureConfig0(); } }); + response['IPS_OptInService'].response['OptInRequired'] = 1; + amtstack.Put('IPS_OptInService', response['IPS_OptInService'].response, function (stack, name, response, status) { if (--pendingAmtConfigActions == 0) { performAmtFeatureConfig0(); } }); } else if ((args.userconsent == 'all') && (optinrequired != 0xFFFFFFFF)) { pendingAmtConfigActions++; - response['IPS_OptInService'].response["OptInRequired"] = 0xFFFFFFFF; - amtstack.Put("IPS_OptInService", response['IPS_OptInService'].response, function (stack, name, response, status) { if (--pendingAmtConfigActions == 0) { performAmtFeatureConfig0(); } }); + response['IPS_OptInService'].response['OptInRequired'] = 0xFFFFFFFF; + amtstack.Put('IPS_OptInService', response['IPS_OptInService'].response, function (stack, name, response, status) { if (--pendingAmtConfigActions == 0) { performAmtFeatureConfig0(); } }); } } // Redirection ports var redirportchange = false; var redirchange = false; - var redir = (response['AMT_RedirectionService'].response["ListenerEnabled"] == true); + var redir = (response['AMT_RedirectionService'].response['ListenerEnabled'] == true); - var sol = ((response['AMT_RedirectionService'].response["EnabledState"] & 2) != 0); - var ider = ((response['AMT_RedirectionService'].response["EnabledState"] & 1) != 0); + var sol = ((response['AMT_RedirectionService'].response['EnabledState'] & 2) != 0); + var ider = ((response['AMT_RedirectionService'].response['EnabledState'] & 1) != 0); if (args) { - if ((redir == false) && ((args.redir == 'enabled') || (args.redir == 1))) { response['AMT_RedirectionService'].response["ListenerEnabled"] = true; redirportchange = true; } - if ((redir == true) && ((args.redir == 'disabled') || (args.redir == 0))) { response['AMT_RedirectionService'].response["ListenerEnabled"] = false; redirportchange = true; } + if ((redir == false) && ((args.redir == 'enabled') || (args.redir == 1))) { response['AMT_RedirectionService'].response['ListenerEnabled'] = true; redirportchange = true; } + if ((redir == true) && ((args.redir == 'disabled') || (args.redir == 0))) { response['AMT_RedirectionService'].response['ListenerEnabled'] = false; redirportchange = true; } if ((sol == false) && ((args.sol == 'enabled') || (args.sol == 1))) { sol = true; redirchange = true; } if ((sol == true) && ((args.sol == 'disabled') || (args.sol == 0))) { sol = false; redirchange = true; } if ((ider == false) && ((args.ider == 'enabled') || (args.ider == 1))) { ider = true; redirchange = true; } @@ -2473,7 +2473,7 @@ function performAmtFeatureConfig1(stack, name, response, status, args) { var kvm = false; var kvmchange = false; if (response['CIM_KVMRedirectionSAP'] != null) { - kvm = ((response['CIM_KVMRedirectionSAP'].response["EnabledState"] == 6 && response['CIM_KVMRedirectionSAP'].response["RequestedState"] == 2) || response['CIM_KVMRedirectionSAP'].response["EnabledState"] == 2 || response['CIM_KVMRedirectionSAP'].response["EnabledState"] == 6); + kvm = ((response['CIM_KVMRedirectionSAP'].response["EnabledState"] == 6 && response['CIM_KVMRedirectionSAP'].response['RequestedState'] == 2) || response['CIM_KVMRedirectionSAP'].response['EnabledState'] == 2 || response['CIM_KVMRedirectionSAP'].response['EnabledState'] == 6); if (args) { if ((kvm == false) && ((args.kvm == 'enabled') || (args.kvm == 1))) { kvm = true; kvmchange = true; } if ((kvm == true) && ((args.kvm == 'disabled') || (args.kvm == 0))) { kvm = false; kvmchange = true; } @@ -2482,18 +2482,18 @@ function performAmtFeatureConfig1(stack, name, response, status, args) { } if (pendingAmtConfigActions == 0) { - if (optinrequired == 0) { console.log('User Consent : None'); } - else if (optinrequired == 1) { console.log('User Consent : KVM'); } - else if (optinrequired == 0xFFFFFFFF) { console.log('User Consent : All'); } - else { console.log('User Consent : ' + optinrequired); } - console.log('Redirection Port : ' + (redir ? 'Enabled' : 'Disabled')); - console.log('Serial-over-LAN : ' + (sol ? 'Enabled' : 'Disabled')); - console.log('IDE Redirection : ' + (ider ? 'Enabled' : 'Disabled')); - if (response['CIM_KVMRedirectionSAP'] != null) { console.log('Remote desktop (KVM) : ' + (kvm ? 'Enabled' : 'Disabled')); } + if (optinrequired == 0) { console.log("User Consent : None"); } + else if (optinrequired == 1) { console.log("User Consent : KVM"); } + else if (optinrequired == 0xFFFFFFFF) { console.log("User Consent : All"); } + else { console.log("User Consent : " + optinrequired); } + console.log("Redirection Port : " + (redir ? "Enabled" : "Disabled")); + console.log("Serial-over-LAN : " + (sol ? "Enabled" : "Disabled")); + console.log("IDE Redirection : " + (ider ? "Enabled" : 'Disabled')); + if (response['CIM_KVMRedirectionSAP'] != null) { console.log("Remote desktop (KVM) : " + (kvm ? "Enabled" : "Disabled")); } process.exit(0); } } else { - console.log('Error, status ' + status + '.'); + console.log("Error, status " + status + "."); process.exit(1); } } @@ -2514,7 +2514,7 @@ function performAmtPowerAction() { amtstack.RequestPowerStateChange(settings.poweraction, performAmtPowerActionEx); } else { // Get the power state - amtstack.Get("CIM_AssociatedPowerManagementService", performAmtPowerActionEx2, 0, 1); + amtstack.Get('CIM_AssociatedPowerManagementService', performAmtPowerActionEx2, 0, 1); } } @@ -2523,23 +2523,23 @@ function performAmtPowerActionEx(stack, name, response, status) { console.log(response.Body.ReturnValueStr.split('_').join(' ')); process.exit(0); } else { - console.log('Error, status ' + status + '.'); + console.log("Error, status " + status + "."); process.exit(1); } } -var DMTFPowerStates = ["", "", "Power on", "Light sleep", "Deep sleep", "Power cycle (Soft off)", "Off - Hard", "Hibernate (Off soft)", "Soft off", "Power cycle (Off-hard)", "Master bus reset", "Diagnostic interrupt (NMI)", "Not applicable", "Off - Soft graceful", "Off - Hard graceful", "Master bus reset graceful", "Power cycle (Off - Soft graceful)", "Power cycle (Off - Hard graceful)", "Diagnostic interrupt (INIT)"]; +var DMTFPowerStates = ['', '', "Power on", "Light sleep", "Deep sleep", "Power cycle (Soft off)", "Off - Hard", "Hibernate (Off soft)", "Soft off", "Power cycle (Off-hard)", "Master bus reset", "Diagnostic interrupt (NMI)", "Not applicable", "Off - Soft graceful", "Off - Hard graceful", "Master bus reset graceful", "Power cycle (Off - Soft graceful)", "Power cycle (Off - Hard graceful)", "Diagnostic interrupt (INIT)"]; function performAmtPowerActionEx2(stack, name, response, status) { if (status == 200) { var powerNumber = parseInt(response.Body.PowerState); if ((powerNumber >= DMTFPowerStates.length) && (powerNumber > 1)) { - console.log('Unknown power state: ' + response.Body.PowerState); + console.log("Unknown power state: " + response.Body.PowerState); } else { - console.log('Current power state: ' + DMTFPowerStates[powerNumber]); + console.log("Current power state: " + DMTFPowerStates[powerNumber]); } process.exit(0); } else { - console.log('Error, status ' + status + '.'); + console.log("Error, status " + status + "."); process.exit(1); } } @@ -2571,16 +2571,16 @@ for (var i in process.argv) { if (process.argv[i].toLowerCase() == 'uninstall') { process.argv[i] = '-uninstall'; } if ((process.argv[i].toLowerCase() == 'microlms') || (process.argv[i].toLowerCase() == 'amtlms') || (process.argv[i].toLowerCase() == 'lms')) { serviceName = 'MicroLMS'; - serviceDisplayName = 'MicroLMS Service for Intel(R) AMT'; - serviceDesc = 'Intel AMT Micro Local Manageability Service (MicroLMS)'; + serviceDisplayName = "MicroLMS Service for Intel(R) AMT"; + serviceDesc = "Intel AMT Micro Local Manageability Service (MicroLMS)"; } else if ((process.argv[i].toLowerCase() == 'intellms')) { serviceName = 'LMS'; - serviceDisplayName = 'Intel(R) Management and Security Application Local Management Service'; - serviceDesc = 'Intel(R) Management and Security Application Local Management Service - Provides OS-related Intel(R) ME functionality.'; + serviceDisplayName = "Intel(R) Management and Security Application Local Management Service"; + serviceDesc = "Intel(R) Management and Security Application Local Management Service - Provides OS-related Intel(R) ME functionality."; } else if ((process.argv[i].toLowerCase() == 'meshcommander') || (process.argv[i].toLowerCase() == 'commander')) { serviceName = 'MeshCommander'; - serviceDisplayName = 'MeshCommander, Intel AMT Management console'; - serviceDesc = 'MeshCommander is a Intel AMT management console.'; + serviceDisplayName = "MeshCommander, Intel AMT Management console"; + serviceDesc = "MeshCommander is a Intel AMT management console."; } } @@ -2589,29 +2589,29 @@ if (serviceName == null) { else if (process.execPath.includes('LMS')) { serviceName = 'LMS'; } else if (process.execPath.includes('MeshCommander')) { serviceName = 'MeshCommander'; } if (serviceName == null) { for (var i in process.argv) { if ((process.argv[i].toLowerCase() == '-install') || (process.argv[i].toLowerCase() == '-uninstall')) { console.log('In order to install/uninstall, a service type must be specified.'); process.exit(); } } } - if (serviceName == null) { try { run(process.argv); } catch (e) { console.log('ERROR: ' + e); } process.exit(); } -} + if (serviceName == null) { try { run(process.argv); } catch (e) { console.log("ERROR: " + e); } } +} else { + var serviceHost = require('service-host'); + var meshcmdService = new serviceHost({ name: serviceName, displayName: serviceDisplayName, startType: 'AUTO_START', description: serviceDesc }); -var serviceHost = require('service-host'); -var meshcmdService = new serviceHost({ name: serviceName, displayName: serviceDisplayName, startType: 'AUTO_START', description: serviceDesc }); + // Called when the background service is started. + meshcmdService.on('serviceStart', function onStart() { + //process.coreDumpLocation = 'C:\\tmp\\meshcommander.dmp'; + //process.on('exit', function () { console.log('exit3'); _debugCrash(); }); + console.setDestination(console.Destinations.DISABLED); // Disable console.log(). + //console.setDestination(console.Destinations.LOGFILE); + //attachDebuger({ webport: 0, wait: 1 }).then(console.log, console.log); -// Called when the background service is started. -meshcmdService.on('serviceStart', function onStart() { - //process.coreDumpLocation = 'C:\\tmp\\meshcommander.dmp'; - //process.on('exit', function () { console.log('exit3'); _debugCrash(); }); - console.setDestination(console.Destinations.DISABLED); // Disable console.log(). - //console.setDestination(console.Destinations.LOGFILE); - //attachDebuger({ webport: 0, wait: 1 }).then(console.log, console.log); + if (process.execPath.includes('MicroLMS')) { run([process.execPath, 'microlms']); } // Start MicroLMS + else if (process.execPath.includes('LMS')) { run([process.execPath, 'microlms']); } // Start MicroLMS + else if (process.execPath.includes('MeshCommander')) { run([process.execPath, 'meshcommander']); } // Start MeshCommander + else { console.log("Aborting Service Start, because unknown binary: " + process.execPath); process.exit(1); } + }); - if (process.execPath.includes('MicroLMS')) { run([process.execPath, 'microlms']); } // Start MicroLMS - else if (process.execPath.includes('LMS')) { run([process.execPath, 'microlms']); } // Start MicroLMS - else if (process.execPath.includes('MeshCommander')) { run([process.execPath, 'meshcommander']); } // Start MeshCommander - else { console.log('Aborting Service Start, because unknown binary: ' + process.execPath); process.exit(1); } -}); + // Called when the background service is stopping + meshcmdService.on('serviceStop', function onStop() { console.log("Stopping service"); process.exit(); }); // The console.log() is for debugging, will be ignored unless "console.setDestination()" is set. -// Called when the background service is stopping -meshcmdService.on('serviceStop', function onStop() { console.log('Stopping service'); process.exit(); }); // The console.log() is for debugging, will be ignored unless "console.setDestination()" is set. - -// Called when the executable is not running as a service, run normally. -meshcmdService.on('normalStart', function onNormalStart() { try { run(process.argv); } catch (e) { console.log('ERROR: ' + e); } }); -meshcmdService.run(); + // Called when the executable is not running as a service, run normally. + meshcmdService.on('normalStart', function onNormalStart() { try { run(process.argv); } catch (e) { console.log("ERROR: " + e); } }); + meshcmdService.run(); +} \ No newline at end of file diff --git a/package.json b/package.json index 7fedf70c..83796b34 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "meshcentral", - "version": "0.4.3-j", + "version": "0.4.3-l", "keywords": [ "Remote Management", "Intel AMT",