From b4fef4bc2c50030f221ca470ab601d4bc43aea5c Mon Sep 17 00:00:00 2001 From: Ylian Saint-Hilaire Date: Tue, 16 Jul 2019 12:25:21 -0700 Subject: [PATCH] Improved MeshCMD AMTNETWORK command. --- agents/MeshCmd-signed.exe | Bin 4113368 -> 4114296 bytes agents/MeshCmd64-signed.exe | Bin 3696088 -> 3697016 bytes agents/meshcmd.js | 56 +++++++++++++++++++++++------------- agents/meshcmd.min.js | 56 +++++++++++++++++++++++------------- package.json | 2 +- 5 files changed, 73 insertions(+), 41 deletions(-) diff --git a/agents/MeshCmd-signed.exe b/agents/MeshCmd-signed.exe index 16be673d582d829cbf3599e66dbf0659e793cdfa..480af74f278ce8b348b6aa34f44674149564fbb9 100644 GIT binary patch delta 2026 zcmbW#X;4#F6ae5Pgf%1-fdobIx&eU*VG$I_RSc+6P}WgFi~%AaCqAI*RK62E~c33lgQ&1wpIhuDDFct>Q8&ic3$VptiO@`eweF_s%`{opYB9Wxdp% zs$QyLDb=F<2Cgol3TSr>B_?W_iE2gz7Jv>cffcX@Hoz9x0S2%KOuzyT;0xdg1_3AF z3|s&kaDXcq42A$VFcb^}?qE1TU<4QmMuE{_4DbM+zzcAJH}C;GFc$b4O;o?h)5~bl zet-}BK>!E@L0}vR1|eWPm;gdSn2{D8elByWELT;eNJlArl%qucsi^-EW=Ry8Ql!q3 zqC%Ncnt?>I3FbtVRIQdNGEt5Ki4r zNFYE9C32ONi#$A#mqeMV^8IVu1u*34@5$w&B}ns`iAb%?mxiJKja-9WiJ=NxCV#$& zIr(2|@c*O6``-Rhgidbe<2vF{h2&i-NLLb^xjCPsNf{YAO&B|Hrsl1JRgl$xgbyKIh1ibp zwb-3380$gr`&?6qM}73!pvA)nK79t>7(`wO)A%a|PNb>;^GMeN0gGG_hdVGdJQT!3 zo(T4XEPER6L=Kl@7J2t27LlbZFr74{2&@TjAvAb>1H4Tt#)D}{M9?X7`dy%9wc5UV3XqoI3Un`uI5`I^M#B|br!;?FWWpY zFt2|!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4ZO+x|;_>4tS&m_`S^U$H1*y|V+G`oD7sv88 z9E`mE!nh{IKkq|{^_tGZ38Q;cW3O!_k8}%)g~x+x`~=U1b)m%L6N`3l-?`3`M9$(e zmlomf@Z_$}+#ciIm%V(Vj@*1*+VjK=M@8-vcWpGd(4~m{_{H{5u6y`NZke_AJt`k4 z?=srl)AY?1ZVW46gZHFUia?6Rue7%4NdEyErWdjR diff --git a/agents/meshcmd.js b/agents/meshcmd.js index afa9d3c1..eb51f458 100644 --- a/agents/meshcmd.js +++ b/agents/meshcmd.js @@ -318,6 +318,7 @@ function run(argv) { console.log('\r\nOptional arguments:\r\n'); console.log(' --user [username] The Intel AMT login username, admin is default.'); console.log(' --tls Specifies that TLS must be used.'); + console.log(' --ipsync [0 or 1] Change the wired IPSync setting on Intel AMT 7+'); console.log(' --dhcp Change IPv4 wired interface to DHCP mode'); console.log(' --static Change IPv4 wired interface to static IP mode'); console.log(' --ip [1.2.3.4] Static IPv4 address (required)'); @@ -2215,46 +2216,61 @@ function performAmtNetConfig1(stack, name, response, status, args) { // Check if configuration change is required if (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"]; + + if ((y['IpSyncEnabled'] == false) && (args.ipsync === '1')) { x['IpSyncEnabled'] = true; docall = true; } + if ((y['IpSyncEnabled'] == true) && (args.ipsync === '0')) { x['IpSyncEnabled'] = false; docall = true; } if (args.dhcp && (amtwiredif != -1) && (response['AMT_EthernetPortSettings'].responses[amtwiredif].DHCPEnabled == false)) { // Change to DHCP - pendingAmtConfigActions++; - var x = response['AMT_EthernetPortSettings'].responses[amtwiredif]; x['DHCPEnabled'] = true; - delete x["IPAddress"]; - delete x["SubnetMask"]; - delete x["DefaultGateway"]; - delete x["PrimaryDNS"]; - delete x["SecondaryDNS"]; - amtstack.Put("AMT_EthernetPortSettings", x, function (stack, name, response, status) { if (--pendingAmtConfigActions == 0) { performAmtNetConfig0(); } }); + docall = true; } else if (args.static && (amtwiredif != -1) && (response['AMT_EthernetPortSettings'].responses[amtwiredif].DHCPEnabled == true)) { // Change to STATIC - pendingAmtConfigActions++; - var x = response['AMT_EthernetPortSettings'].responses[amtwiredif]; x['DHCPEnabled'] = false; - delete x["IPAddress"]; - delete x["SubnetMask"]; - delete x["DefaultGateway"]; - delete x["PrimaryDNS"]; - delete x["SecondaryDNS"]; 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; } - amtstack.Put("AMT_EthernetPortSettings", x, function (stack, name, response, status) { console.log(status); if (--pendingAmtConfigActions == 0) { performAmtNetConfig0(); } }); + docall = true; + } + if (docall) { + 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); } } if (pendingAmtConfigActions == 0) { + var maxlen = 0; + if (amtwiredif != -1) { for (var i in response['AMT_EthernetPortSettings'].responses[amtwiredif]) { if (i.length > maxlen) { maxlen = i.length; } } } + if (amtwirelessif != -1) { for (var i in response['AMT_EthernetPortSettings'].responses[amtwirelessif]) { if (i.length > maxlen) { maxlen = i.length; } } } + if (amtwiredif != -1) { // Wired var z = response['AMT_EthernetPortSettings'].responses[amtwiredif]; console.log('--WIRED---'); for (var i in z) { if (['ElementName', 'InstanceID'].indexOf(i) == -1) { var name = i; - while (name.length < 16) { name += ' '; } - console.log(name + ': ' + z[i]); + while (name.length < maxlen) { name += ' '; } + console.log(name + ' : ' + z[i]); } } } @@ -2264,8 +2280,8 @@ function performAmtNetConfig1(stack, name, response, status, args) { for (var i in z) { if (['ElementName', 'InstanceID'].indexOf(i) == -1) { var name = i; - while (name.length < 16) { name += ' '; } - console.log(name + ': ' + z[i]); + while (name.length < maxlen) { name += ' '; } + console.log(name + ' : ' + z[i]); } } } diff --git a/agents/meshcmd.min.js b/agents/meshcmd.min.js index afa9d3c1..eb51f458 100644 --- a/agents/meshcmd.min.js +++ b/agents/meshcmd.min.js @@ -318,6 +318,7 @@ function run(argv) { console.log('\r\nOptional arguments:\r\n'); console.log(' --user [username] The Intel AMT login username, admin is default.'); console.log(' --tls Specifies that TLS must be used.'); + console.log(' --ipsync [0 or 1] Change the wired IPSync setting on Intel AMT 7+'); console.log(' --dhcp Change IPv4 wired interface to DHCP mode'); console.log(' --static Change IPv4 wired interface to static IP mode'); console.log(' --ip [1.2.3.4] Static IPv4 address (required)'); @@ -2215,46 +2216,61 @@ function performAmtNetConfig1(stack, name, response, status, args) { // Check if configuration change is required if (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"]; + + if ((y['IpSyncEnabled'] == false) && (args.ipsync === '1')) { x['IpSyncEnabled'] = true; docall = true; } + if ((y['IpSyncEnabled'] == true) && (args.ipsync === '0')) { x['IpSyncEnabled'] = false; docall = true; } if (args.dhcp && (amtwiredif != -1) && (response['AMT_EthernetPortSettings'].responses[amtwiredif].DHCPEnabled == false)) { // Change to DHCP - pendingAmtConfigActions++; - var x = response['AMT_EthernetPortSettings'].responses[amtwiredif]; x['DHCPEnabled'] = true; - delete x["IPAddress"]; - delete x["SubnetMask"]; - delete x["DefaultGateway"]; - delete x["PrimaryDNS"]; - delete x["SecondaryDNS"]; - amtstack.Put("AMT_EthernetPortSettings", x, function (stack, name, response, status) { if (--pendingAmtConfigActions == 0) { performAmtNetConfig0(); } }); + docall = true; } else if (args.static && (amtwiredif != -1) && (response['AMT_EthernetPortSettings'].responses[amtwiredif].DHCPEnabled == true)) { // Change to STATIC - pendingAmtConfigActions++; - var x = response['AMT_EthernetPortSettings'].responses[amtwiredif]; x['DHCPEnabled'] = false; - delete x["IPAddress"]; - delete x["SubnetMask"]; - delete x["DefaultGateway"]; - delete x["PrimaryDNS"]; - delete x["SecondaryDNS"]; 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; } - amtstack.Put("AMT_EthernetPortSettings", x, function (stack, name, response, status) { console.log(status); if (--pendingAmtConfigActions == 0) { performAmtNetConfig0(); } }); + docall = true; + } + if (docall) { + 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); } } if (pendingAmtConfigActions == 0) { + var maxlen = 0; + if (amtwiredif != -1) { for (var i in response['AMT_EthernetPortSettings'].responses[amtwiredif]) { if (i.length > maxlen) { maxlen = i.length; } } } + if (amtwirelessif != -1) { for (var i in response['AMT_EthernetPortSettings'].responses[amtwirelessif]) { if (i.length > maxlen) { maxlen = i.length; } } } + if (amtwiredif != -1) { // Wired var z = response['AMT_EthernetPortSettings'].responses[amtwiredif]; console.log('--WIRED---'); for (var i in z) { if (['ElementName', 'InstanceID'].indexOf(i) == -1) { var name = i; - while (name.length < 16) { name += ' '; } - console.log(name + ': ' + z[i]); + while (name.length < maxlen) { name += ' '; } + console.log(name + ' : ' + z[i]); } } } @@ -2264,8 +2280,8 @@ function performAmtNetConfig1(stack, name, response, status, args) { for (var i in z) { if (['ElementName', 'InstanceID'].indexOf(i) == -1) { var name = i; - while (name.length < 16) { name += ' '; } - console.log(name + ': ' + z[i]); + while (name.length < maxlen) { name += ' '; } + console.log(name + ' : ' + z[i]); } } } diff --git a/package.json b/package.json index 3eb303a6..b0efaf1a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "meshcentral", - "version": "0.3.7-v", + "version": "0.3.7-w", "keywords": [ "Remote Management", "Intel AMT",