Added MeshCMD AmtNetwork command

Ylian Saint-Hilaire committed Jul 15, 2019 at 14:45 UTC f27c3b143005ab04c0bc23fba11debe4863b5118
5 files changed +307 -55
agents/MeshCmd-signed.exe
Binary files a/agents/MeshCmd-signed.exe and b/agents/MeshCmd-signed.exe differ
agents/MeshCmd64-signed.exe
Binary files a/agents/MeshCmd64-signed.exe and b/agents/MeshCmd64-signed.exe differ
agents/meshcmd.js
+153 -27
@@ -46,6 +46,7 @@ var oswsstack = null, osamtstack = null;
46 var amtMeiTmpState = null;
47 var SMBiosTables = null;
48 var globalDebugFlags = 0; // 1 = IDER Debug
49 +var pendingAmtConfigActions = 0;
50 const RCSMessageProtocolVersion = 1; // RCS Message Protocol Version. Needs to be less than or equal to RCS server Message Protocol Version
51
52 // MeshCommander for Firmware (GZIP'ed, Base64) v0.7.8
@@ -113,7 +114,7 @@ function run(argv) {
114 //console.log('addedModules = ' + JSON.stringify(addedModules));
115 var actionpath = 'meshaction.txt';
116 if (args.actionfile != null) { actionpath = args.actionfile; }
116 - var actions = ['HELP', 'ROUTE', 'MICROLMS', 'AMTPOWER', 'AMTFEATURES', 'AMTLOADWEBAPP', 'AMTLOADSMALLWEBAPP', 'AMTLOADLARGEWEBAPP', 'AMTCLEARWEBAPP', 'AMTSTORAGESTATE', 'AMTINFO', 'AMTINFODEBUG', 'AMTVERSIONS', 'AMTHASHES', 'AMTSAVESTATE', 'AMTSCRIPT', 'AMTUUID', 'AMTCCM', 'AMTACM', 'AMTDEACTIVATE', 'AMTACMDEACTIVATE', 'SMBIOS', 'RAWSMBIOS', 'MESHCOMMANDER', 'AMTAUDITLOG', 'AMTPRESENCE'];
117 + var actions = ['HELP', 'ROUTE', 'MICROLMS', 'AMTPOWER', 'AMTFEATURES', 'AMTNETWORK', 'AMTLOADWEBAPP', 'AMTLOADSMALLWEBAPP', 'AMTLOADLARGEWEBAPP', 'AMTCLEARWEBAPP', 'AMTSTORAGESTATE', 'AMTINFO', 'AMTINFODEBUG', 'AMTVERSIONS', 'AMTHASHES', 'AMTSAVESTATE', 'AMTSCRIPT', 'AMTUUID', 'AMTCCM', 'AMTACM', 'AMTDEACTIVATE', 'AMTACMDEACTIVATE', 'SMBIOS', 'RAWSMBIOS', 'MESHCOMMANDER', 'AMTAUDITLOG', 'AMTPRESENCE'];
118
119 // Load the action file
120 var actionfile = null;
@@ -190,6 +191,7 @@ function run(argv) {
191 console.log(' AmtScript - Run .mescript on Intel AMT.');
192 console.log(' AmtIDER - Mount local disk image to remote computer.');
193 console.log(' AmtFeatures - Intel AMT features & user consent.');
194 + console.log(' AmtNetwork - Intel AMT network interface settings.');
195 console.log('\r\nHelp on a specific action using:\r\n');
196 console.log(' meshcmd help [action]');
197 exit(1); return;
@@ -300,12 +302,27 @@ function run(argv) {
302 } else if (action == 'amtpower') {
303 console.log('AmtPower will get current pwoer state or send a reboot command to a remote Intel AMT device. Example usage:\r\n\r\n meshcmd amtpower --reset --host 1.2.3.4 --user admin --pass mypassword --tls');
304 console.log('\r\nRequired arguments:\r\n');
303 - console.log(' --host [hostname] The IP address or DNS name of Intel AMT, 127.0.0.1 is default.');
305 + console.log(' --host [hostname] The IP address or DNS name of Intel AMT.');
306 console.log(' --pass [password] The Intel AMT login password.');
307 console.log('\r\nOptional arguments:\r\n');
308 console.log(' --reset, --poweron, --poweroff, --powercycle, --sleep, --hibernate');
309 console.log(' --user [username] The Intel AMT login username, admin is default.');
310 console.log(' --tls Specifies that TLS must be used.');
311 + } else if (action == 'amtnetwork') {
312 + console.log('AmtNetwork is used to get/set Intel AMT network interface configuration. Example usage:\r\n\r\n meshcmd amtnetwork --host 1.2.3.4 --user admin --pass mypassword --dhcp');
313 + console.log('\r\nRequired arguments:\r\n');
314 + console.log(' --host [hostname] The IP address or DNS name of Intel AMT, 127.0.0.1 is default.');
315 + console.log(' --pass [password] The Intel AMT login password.');
316 + console.log('\r\nOptional arguments:\r\n');
317 + console.log(' --user [username] The Intel AMT login username, admin is default.');
318 + console.log(' --tls Specifies that TLS must be used.');
319 + console.log(' --dhcp Change IPv4 wired interface to DHCP mode');
320 + console.log(' --static Change IPv4 wired interface to static IP mode');
321 + console.log(' --ip [1.2.3.4] Static IPv4 address (required)');
322 + console.log(' --subnet [1.2.3.4] Static IPv4 subnet mask');
323 + console.log(' --gateway [1.2.3.4] Static IPv4 default gateway');
324 + console.log(' --dns [1.2.3.4] Primary DNS IPv4 address');
325 + console.log(' --dns2 [1.2.3.4] Secondary DNS IPv4 address');
326 } else if (action == 'amtfeatures') {
327 console.log('AmtFeatures is used to get/set Intel AMT feature configuration. Example usage:\r\n\r\n meshcmd amtfeatures --host 1.2.3.4 --user admin --pass mypassword --tls --redir 1');
328 console.log('\r\nRequired arguments:\r\n');
@@ -596,8 +613,13 @@ function run(argv) {
613 if ((settings.cdrom == null) || (typeof settings.cdrom != 'string') || (settings.cdrom == '')) { settings.cdrom = null; }
614 if ((settings.floppy == null) && (settings.cdrom == null)) { console.log('No or invalid \"floppy\" or \"cdrom\" specified, use --floppy [file] or --cdrom [file].'); exit(1); return; }
615 performIder();
616 + } else if (settings.action == 'amtnetwork') { // Perform remote Intel AMT wired IPv4 configuration operation
617 + if (settings.hostname == null) { settings.hostname = '127.0.0.1'; }
618 + if ((settings.password == null) || (typeof settings.password != 'string') || (settings.password == '')) { console.log('No or invalid \"password\" specified, use --password [password].'); exit(1); return; }
619 + if ((settings.username == null) || (typeof settings.username != 'string') || (settings.username == '')) { settings.username = 'admin'; }
620 + performAmtNetConfig(args);
621 } else if (settings.action == 'amtfeatures') { // Perform remote Intel AMT feature configuration operation
600 - if ((settings.hostname == null) || (typeof settings.hostname != 'string') || (settings.hostname == '')) { console.log('No or invalid \"hostname\" specified, use --hostname [host].'); exit(1); return; }
622 + if (settings.hostname == null) { settings.hostname = '127.0.0.1'; }
623 if ((settings.password == null) || (typeof settings.password != 'string') || (settings.password == '')) { console.log('No or invalid \"password\" specified, use --password [password].'); exit(1); return; }
624 if ((settings.username == null) || (typeof settings.username != 'string') || (settings.username == '')) { settings.username = 'admin'; }
625 performAmtFeatureConfig(args);
@@ -1374,11 +1396,11 @@ var lmsNotifications = [];
1396 var amtLms = null;
1397 var promise = require('promise');
1398
1377 -function startLms(func, lmscommander) {
1399 +function startLms(func, lmscommander, tag) {
1400 var ret = new promise(function (res, rej) { this._res = res; this._rej = rej; });
1401 var lme_heci = null
1402 try { lme_heci = require('amt-lme'); } catch (ex) { }
1381 - if (lme_heci == null) { if (func != null) { func(func, 0); } this.promise._res(); return; }
1403 + if (lme_heci == null) { if (func != null) { func(0, tag); } this.promise._res(); return; }
1404
1405 //var amtLms = null;
1406 var http = require('http');
@@ -1396,10 +1418,10 @@ function startLms(func, lmscommander) {
1418 if (lmscommander === true) { //settings.noconsole !== true) {
1419 startMeshCommanderLms();
1420 //console.log("LMS started, MeshCommander on HTTP/16994.");
1399 - tempTimer = setTimeout(function () { delete tempTimer; setupMeiOsAdmin(func, 2); }, 100);
1421 + tempTimer = setTimeout(function () { delete tempTimer; setupMeiOsAdmin(func, 2, tag); }, 100);
1422 } else {
1423 //console.log('LME connection failed: ' + JSON.stringify(e));
1402 - tempTimer = setTimeout(function () { delete tempTimer; setupMeiOsAdmin(func, 0); }, 100);
1424 + tempTimer = setTimeout(function () { delete tempTimer; setupMeiOsAdmin(func, 0, tag); }, 100);
1425 }
1426 this.promise._res();
1427 });
@@ -1425,11 +1447,11 @@ function startLms(func, lmscommander) {
1447 if (settings.noconsole !== true) {
1448 startMeshCommanderLms();
1449 //console.log("LMS started, MeshCommander on HTTP/16994.");
1428 - tempTimer = setTimeout(function () { delete tempTimer; setupMeiOsAdmin(func, 2); }, 100);
1450 + tempTimer = setTimeout(function () { delete tempTimer; setupMeiOsAdmin(func, 2, tag); }, 100);
1451 //console.logReferenceCount(tempTimer);
1452 } else {
1453 //console.log("LMS started.");
1432 - tempTimer = setTimeout(function () { delete tempTimer; setupMeiOsAdmin(func, 1); }, 100);
1454 + tempTimer = setTimeout(function () { delete tempTimer; setupMeiOsAdmin(func, 1, tag); }, 100);
1455 //console.logReferenceCount(tempTimer);
1456 }
1457
@@ -1500,9 +1522,9 @@ function startMeshCommanderLms() {
1522 });
1523 }
1524
1503 -function setupMeiOsAdmin(func, state) {
1525 +function setupMeiOsAdmin(func, state, tag) {
1526 if (amtMei == null) {
1505 - if (func) { func(state); }
1527 + if (func) { func(state, tag); }
1528 } else {
1529 amtMei.getLocalSystemAccount(function (x) {
1530 var transport = require('amt-wsman-duk');
@@ -1510,7 +1532,7 @@ function setupMeiOsAdmin(func, state) {
1532 var amt = require('amt');
1533 oswsstack = new wsman(transport, '127.0.0.1', 16992, x.user, x.pass, false);
1534 osamtstack = new amt(oswsstack);
1513 - if (func) { func(state); }
1535 + if (func) { func(state, tag); }
1536
1537 //var AllWsman = "CIM_SoftwareIdentity,IPS_SecIOService,IPS_ScreenSettingData,IPS_ProvisioningRecordLog,IPS_HostBasedSetupService,IPS_HostIPSettings,IPS_IPv6PortSettings".split(',');
1538 //osamtstack.BatchEnum(null, AllWsman, startLmsWsmanResponse, null, true);
@@ -2088,11 +2110,116 @@ function iderSectorStats(mode, dev, mediaBlocks, lba, len) {
2110 iderIdleTimer = setTimeout(function () { console.log('Idle timeout'); process.exit(1); }, 1000 * settings.timeout);
2111 }
2112
2113 +//
2114 +// Intel AMT IPv4 wired configuration
2115 +//
2116 +
2117 +function performAmtNetConfig(args) {
2118 + if ((settings.hostname == '127.0.0.1') || (settings.hostname.toLowerCase() == 'localhost')) {
2119 + settings.noconsole = true; startLms(performAmtNetConfig0, false, args);
2120 + } else {
2121 + performAmtNetConfig0(1, args);
2122 + }
2123 +}
2124 +
2125 +function performAmtNetConfig0(state, args) {
2126 + var transport = require('amt-wsman-duk');
2127 + var wsman = require('amt-wsman');
2128 + var amt = require('amt');
2129 + wsstack = new wsman(transport, settings.hostname, settings.tls ? 16993 : 16992, settings.username, settings.password, settings.tls);
2130 + amtstack = new amt(wsstack);
2131 + amtstack.BatchEnum(null, ['AMT_EthernetPortSettings'], performAmtNetConfig1, args);
2132 +}
2133 +
2134 +function performAmtNetConfig1(stack, name, response, status, args) {
2135 + if (status == 200) {
2136 + // Set wired and wireless interfaces
2137 + var amtwirelessif = -1;
2138 + var amtwiredif = -1;
2139 + for (var y in response['AMT_EthernetPortSettings'].responses) {
2140 + var z = response['AMT_EthernetPortSettings'].responses[y];
2141 + 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.
2142 + 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
2143 + }
2144 +
2145 + // Check if configuration change is required
2146 + if (args) {
2147 + if (args.dhcp && (amtwiredif != -1) && (response['AMT_EthernetPortSettings'].responses[amtwiredif].DHCPEnabled == false)) {
2148 + // Change to DHCP
2149 + pendingAmtConfigActions++;
2150 + var x = response['AMT_EthernetPortSettings'].responses[amtwiredif];
2151 + x['DHCPEnabled'] = true;
2152 + delete x["IPAddress"];
2153 + delete x["SubnetMask"];
2154 + delete x["DefaultGateway"];
2155 + delete x["PrimaryDNS"];
2156 + delete x["SecondaryDNS"];
2157 + amtstack.Put("AMT_EthernetPortSettings", x, function (stack, name, response, status) { if (--pendingAmtConfigActions == 0) { performAmtNetConfig0(); } });
2158 + }
2159 + else if (args.static && (amtwiredif != -1) && (response['AMT_EthernetPortSettings'].responses[amtwiredif].DHCPEnabled == true)) {
2160 + // Change to STATIC
2161 + pendingAmtConfigActions++;
2162 + var x = response['AMT_EthernetPortSettings'].responses[amtwiredif];
2163 + x['DHCPEnabled'] = false;
2164 + delete x["IPAddress"];
2165 + delete x["SubnetMask"];
2166 + delete x["DefaultGateway"];
2167 + delete x["PrimaryDNS"];
2168 + delete x["SecondaryDNS"];
2169 + if (args.ip) { x["IPAddress"] = args.ip; } else { console.log('Missing IPv4 address, use --ip 1.2.3.4'); process.exit(1); }
2170 + if (args.subnet) { x["SubnetMask"] = args.subnet; } else { console.log('Missing IPv4 subnet, use --subnet 255.255.255.0'); process.exit(1); }
2171 + if (args.gateway) { x["DefaultGateway"] = args.gateway; }
2172 + if (args.dns) { x["PrimaryDNS"] = args.dns; }
2173 + if (args.dns2) { x["SecondaryDNS"] = args.dns2; }
2174 + amtstack.Put("AMT_EthernetPortSettings", x, function (stack, name, response, status) { console.log(status); if (--pendingAmtConfigActions == 0) { performAmtNetConfig0(); } });
2175 + }
2176 + }
2177 +
2178 + if (pendingAmtConfigActions == 0) {
2179 + if (amtwiredif != -1) { // Wired
2180 + var z = response['AMT_EthernetPortSettings'].responses[amtwiredif];
2181 + console.log('--WIRED---');
2182 + for (var i in z) {
2183 + if (['ElementName', 'InstanceID'].indexOf(i) == -1) {
2184 + var name = i;
2185 + while (name.length < 16) { name += ' '; }
2186 + console.log(name + ': ' + z[i]);
2187 + }
2188 + }
2189 + }
2190 + if (amtwirelessif != -1) { // Wireless
2191 + var z = response['AMT_EthernetPortSettings'].responses[amtwirelessif];
2192 + console.log('--WIRELESS---');
2193 + for (var i in z) {
2194 + if (['ElementName', 'InstanceID'].indexOf(i) == -1) {
2195 + var name = i;
2196 + while (name.length < 16) { name += ' '; }
2197 + console.log(name + ': ' + z[i]);
2198 + }
2199 + }
2200 + }
2201 + process.exit(0);
2202 + }
2203 + } else {
2204 + console.log('Error, status ' + status + '.');
2205 + process.exit(1);
2206 + }
2207 +}
2208 +
2209 +
2210 //
2211 // Intel AMT feature configuration action
2212 //
2213
2214 function performAmtFeatureConfig(args) {
2215 + if ((settings.hostname == '127.0.0.1') || (settings.hostname.toLowerCase() == 'localhost')) {
2216 + settings.noconsole = true; startLms(performAmtFeatureConfig0, false, args);
2217 + } else {
2218 + performAmtFeatureConfig0(1, args);
2219 + }
2220 +}
2221 +
2222 +function performAmtFeatureConfig0(state, args) {
2223 var transport = require('amt-wsman-duk');
2224 var wsman = require('amt-wsman');
2225 var amt = require('amt');
@@ -2101,7 +2228,6 @@ function performAmtFeatureConfig(args) {
2228 amtstack.BatchEnum(null, ['*IPS_OptInService', '*AMT_RedirectionService', '*CIM_KVMRedirectionSAP'], performAmtFeatureConfig1, args);
2229 }
2230
2104 -var pendingAmtConfigActions = 0;
2231 function performAmtFeatureConfig1(stack, name, response, status, args) {
2232 if (status == 200) {
2233 // User consent
@@ -2110,17 +2236,17 @@ function performAmtFeatureConfig1(stack, name, response, status, args) {
2236 if ((args.userconsent == 'none') && (optinrequired != 0)) {
2237 pendingAmtConfigActions++;
2238 response['IPS_OptInService'].response["OptInRequired"] = 0;
2113 - amtstack.Put("IPS_OptInService", response['IPS_OptInService'].response, function (stack, name, response, status) { if (--pendingAmtConfigActions == 0) { performAmtFeatureConfig(); } });
2239 + amtstack.Put("IPS_OptInService", response['IPS_OptInService'].response, function (stack, name, response, status) { if (--pendingAmtConfigActions == 0) { performAmtFeatureConfig0(); } });
2240 }
2241 else if ((args.userconsent == 'kvm') && (optinrequired != 1)) {
2242 pendingAmtConfigActions++;
2243 response['IPS_OptInService'].response["OptInRequired"] = 1;
2118 - amtstack.Put("IPS_OptInService", response['IPS_OptInService'].response, function (stack, name, response, status) { if (--pendingAmtConfigActions == 0) { performAmtFeatureConfig(); } });
2244 + amtstack.Put("IPS_OptInService", response['IPS_OptInService'].response, function (stack, name, response, status) { if (--pendingAmtConfigActions == 0) { performAmtFeatureConfig0(); } });
2245 }
2246 else if ((args.userconsent == 'all') && (optinrequired != 0xFFFFFFFF)) {
2247 pendingAmtConfigActions++;
2248 response['IPS_OptInService'].response["OptInRequired"] = 0xFFFFFFFF;
2123 - amtstack.Put("IPS_OptInService", response['IPS_OptInService'].response, function (stack, name, response, status) { if (--pendingAmtConfigActions == 0) { performAmtFeatureConfig(); } });
2249 + amtstack.Put("IPS_OptInService", response['IPS_OptInService'].response, function (stack, name, response, status) { if (--pendingAmtConfigActions == 0) { performAmtFeatureConfig0(); } });
2250 }
2251 }
2252
@@ -2138,8 +2264,8 @@ function performAmtFeatureConfig1(stack, name, response, status, args) {
2264 if ((sol == true) && ((args.sol == 'disabled') || (args.sol == 0))) { sol = false; redirchange = true; }
2265 if ((ider == false) && ((args.ider == 'enabled') || (args.ider == 1))) { ider = true; redirchange = true; }
2266 if ((ider == true) && ((args.ider == 'disabled') || (args.ider == 0))) { ider = false; redirchange = true; }
2141 - if (redirportchange) { pendingAmtConfigActions++; amtstack.Put("AMT_RedirectionService", response['AMT_RedirectionService'].response, function (stack, name, response, status) { if (--pendingAmtConfigActions == 0) { performAmtFeatureConfig(); } }); }
2142 - if (redirchange) { pendingAmtConfigActions++; amtstack.AMT_RedirectionService_RequestStateChange((32768 + ((ider ? 1 : 0) + (sol ? 2 : 0))), function (stack, name, response, status) { if (--pendingAmtConfigActions == 0) { performAmtFeatureConfig(); } }); }
2267 + if (redirportchange) { pendingAmtConfigActions++; amtstack.Put("AMT_RedirectionService", response['AMT_RedirectionService'].response, function (stack, name, response, status) { if (--pendingAmtConfigActions == 0) { performAmtFeatureConfig0(); } }); }
2268 + if (redirchange) { pendingAmtConfigActions++; amtstack.AMT_RedirectionService_RequestStateChange((32768 + ((ider ? 1 : 0) + (sol ? 2 : 0))), function (stack, name, response, status) { if (--pendingAmtConfigActions == 0) { performAmtFeatureConfig0(); } }); }
2269 }
2270
2271 // KVM
@@ -2150,19 +2276,19 @@ function performAmtFeatureConfig1(stack, name, response, status, args) {
2276 if (args) {
2277 if ((kvm == false) && ((args.kvm == 'enabled') || (args.kvm == 1))) { kvm = true; kvmchange = true; }
2278 if ((kvm == true) && ((args.kvm == 'disabled') || (args.kvm == 0))) { kvm = false; kvmchange = true; }
2153 - if (kvmchange) { pendingAmtConfigActions++; amtstack.CIM_KVMRedirectionSAP_RequestStateChange(kvm ? 2 : 3, 0, function (stack, name, response, status) { if (--pendingAmtConfigActions == 0) { performAmtFeatureConfig(); } }); }
2279 + if (kvmchange) { pendingAmtConfigActions++; amtstack.CIM_KVMRedirectionSAP_RequestStateChange(kvm ? 2 : 3, 0, function (stack, name, response, status) { if (--pendingAmtConfigActions == 0) { performAmtFeatureConfig0(); } }); }
2280 }
2281 }
2282
2283 if (pendingAmtConfigActions == 0) {
2158 - if (optinrequired == 0) { console.log('User Consent: None'); }
2159 - else if (optinrequired == 1) { console.log('User Consent: KVM'); }
2160 - else if (optinrequired == 0xFFFFFFFF) { console.log('User Consent: All'); }
2161 - else { console.log('User Consent: ' + optinrequired); }
2162 - console.log('Redirection Port: ' + (redir ? 'Enabled' : 'Disabled'));
2163 - console.log('Serial-over-LAN: ' + (sol ? 'Enabled' : 'Disabled'));
2164 - console.log('IDE Redirection: ' + (ider ? 'Enabled' : 'Disabled'));
2165 - if (response['CIM_KVMRedirectionSAP'] != null) { console.log('Remote desktop (KVM): ' + (kvm ? 'Enabled' : 'Disabled')); }
2284 + if (optinrequired == 0) { console.log('User Consent : None'); }
2285 + else if (optinrequired == 1) { console.log('User Consent : KVM'); }
2286 + else if (optinrequired == 0xFFFFFFFF) { console.log('User Consent : All'); }
2287 + else { console.log('User Consent : ' + optinrequired); }
2288 + console.log('Redirection Port : ' + (redir ? 'Enabled' : 'Disabled'));
2289 + console.log('Serial-over-LAN : ' + (sol ? 'Enabled' : 'Disabled'));
2290 + console.log('IDE Redirection : ' + (ider ? 'Enabled' : 'Disabled'));
2291 + if (response['CIM_KVMRedirectionSAP'] != null) { console.log('Remote desktop (KVM) : ' + (kvm ? 'Enabled' : 'Disabled')); }
2292 process.exit(0);
2293 }
2294 } else {
agents/meshcmd.min.js
+153 -27
@@ -46,6 +46,7 @@ var oswsstack = null, osamtstack = null;
46 var amtMeiTmpState = null;
47 var SMBiosTables = null;
48 var globalDebugFlags = 0; // 1 = IDER Debug
49 +var pendingAmtConfigActions = 0;
50 const RCSMessageProtocolVersion = 1; // RCS Message Protocol Version. Needs to be less than or equal to RCS server Message Protocol Version
51
52 // MeshCommander for Firmware (GZIP'ed, Base64) v0.7.8
@@ -113,7 +114,7 @@ function run(argv) {
114 //console.log('addedModules = ' + JSON.stringify(addedModules));
115 var actionpath = 'meshaction.txt';
116 if (args.actionfile != null) { actionpath = args.actionfile; }
116 - var actions = ['HELP', 'ROUTE', 'MICROLMS', 'AMTPOWER', 'AMTFEATURES', 'AMTLOADWEBAPP', 'AMTLOADSMALLWEBAPP', 'AMTLOADLARGEWEBAPP', 'AMTCLEARWEBAPP', 'AMTSTORAGESTATE', 'AMTINFO', 'AMTINFODEBUG', 'AMTVERSIONS', 'AMTHASHES', 'AMTSAVESTATE', 'AMTSCRIPT', 'AMTUUID', 'AMTCCM', 'AMTACM', 'AMTDEACTIVATE', 'AMTACMDEACTIVATE', 'SMBIOS', 'RAWSMBIOS', 'MESHCOMMANDER', 'AMTAUDITLOG', 'AMTPRESENCE'];
117 + var actions = ['HELP', 'ROUTE', 'MICROLMS', 'AMTPOWER', 'AMTFEATURES', 'AMTNETWORK', 'AMTLOADWEBAPP', 'AMTLOADSMALLWEBAPP', 'AMTLOADLARGEWEBAPP', 'AMTCLEARWEBAPP', 'AMTSTORAGESTATE', 'AMTINFO', 'AMTINFODEBUG', 'AMTVERSIONS', 'AMTHASHES', 'AMTSAVESTATE', 'AMTSCRIPT', 'AMTUUID', 'AMTCCM', 'AMTACM', 'AMTDEACTIVATE', 'AMTACMDEACTIVATE', 'SMBIOS', 'RAWSMBIOS', 'MESHCOMMANDER', 'AMTAUDITLOG', 'AMTPRESENCE'];
118
119 // Load the action file
120 var actionfile = null;
@@ -190,6 +191,7 @@ function run(argv) {
191 console.log(' AmtScript - Run .mescript on Intel AMT.');
192 console.log(' AmtIDER - Mount local disk image to remote computer.');
193 console.log(' AmtFeatures - Intel AMT features & user consent.');
194 + console.log(' AmtNetwork - Intel AMT network interface settings.');
195 console.log('\r\nHelp on a specific action using:\r\n');
196 console.log(' meshcmd help [action]');
197 exit(1); return;
@@ -300,12 +302,27 @@ function run(argv) {
302 } else if (action == 'amtpower') {
303 console.log('AmtPower will get current pwoer state or send a reboot command to a remote Intel AMT device. Example usage:\r\n\r\n meshcmd amtpower --reset --host 1.2.3.4 --user admin --pass mypassword --tls');
304 console.log('\r\nRequired arguments:\r\n');
303 - console.log(' --host [hostname] The IP address or DNS name of Intel AMT, 127.0.0.1 is default.');
305 + console.log(' --host [hostname] The IP address or DNS name of Intel AMT.');
306 console.log(' --pass [password] The Intel AMT login password.');
307 console.log('\r\nOptional arguments:\r\n');
308 console.log(' --reset, --poweron, --poweroff, --powercycle, --sleep, --hibernate');
309 console.log(' --user [username] The Intel AMT login username, admin is default.');
310 console.log(' --tls Specifies that TLS must be used.');
311 + } else if (action == 'amtnetwork') {
312 + console.log('AmtNetwork is used to get/set Intel AMT network interface configuration. Example usage:\r\n\r\n meshcmd amtnetwork --host 1.2.3.4 --user admin --pass mypassword --dhcp');
313 + console.log('\r\nRequired arguments:\r\n');
314 + console.log(' --host [hostname] The IP address or DNS name of Intel AMT, 127.0.0.1 is default.');
315 + console.log(' --pass [password] The Intel AMT login password.');
316 + console.log('\r\nOptional arguments:\r\n');
317 + console.log(' --user [username] The Intel AMT login username, admin is default.');
318 + console.log(' --tls Specifies that TLS must be used.');
319 + console.log(' --dhcp Change IPv4 wired interface to DHCP mode');
320 + console.log(' --static Change IPv4 wired interface to static IP mode');
321 + console.log(' --ip [1.2.3.4] Static IPv4 address (required)');
322 + console.log(' --subnet [1.2.3.4] Static IPv4 subnet mask');
323 + console.log(' --gateway [1.2.3.4] Static IPv4 default gateway');
324 + console.log(' --dns [1.2.3.4] Primary DNS IPv4 address');
325 + console.log(' --dns2 [1.2.3.4] Secondary DNS IPv4 address');
326 } else if (action == 'amtfeatures') {
327 console.log('AmtFeatures is used to get/set Intel AMT feature configuration. Example usage:\r\n\r\n meshcmd amtfeatures --host 1.2.3.4 --user admin --pass mypassword --tls --redir 1');
328 console.log('\r\nRequired arguments:\r\n');
@@ -596,8 +613,13 @@ function run(argv) {
613 if ((settings.cdrom == null) || (typeof settings.cdrom != 'string') || (settings.cdrom == '')) { settings.cdrom = null; }
614 if ((settings.floppy == null) && (settings.cdrom == null)) { console.log('No or invalid \"floppy\" or \"cdrom\" specified, use --floppy [file] or --cdrom [file].'); exit(1); return; }
615 performIder();
616 + } else if (settings.action == 'amtnetwork') { // Perform remote Intel AMT wired IPv4 configuration operation
617 + if (settings.hostname == null) { settings.hostname = '127.0.0.1'; }
618 + if ((settings.password == null) || (typeof settings.password != 'string') || (settings.password == '')) { console.log('No or invalid \"password\" specified, use --password [password].'); exit(1); return; }
619 + if ((settings.username == null) || (typeof settings.username != 'string') || (settings.username == '')) { settings.username = 'admin'; }
620 + performAmtNetConfig(args);
621 } else if (settings.action == 'amtfeatures') { // Perform remote Intel AMT feature configuration operation
600 - if ((settings.hostname == null) || (typeof settings.hostname != 'string') || (settings.hostname == '')) { console.log('No or invalid \"hostname\" specified, use --hostname [host].'); exit(1); return; }
622 + if (settings.hostname == null) { settings.hostname = '127.0.0.1'; }
623 if ((settings.password == null) || (typeof settings.password != 'string') || (settings.password == '')) { console.log('No or invalid \"password\" specified, use --password [password].'); exit(1); return; }
624 if ((settings.username == null) || (typeof settings.username != 'string') || (settings.username == '')) { settings.username = 'admin'; }
625 performAmtFeatureConfig(args);
@@ -1374,11 +1396,11 @@ var lmsNotifications = [];
1396 var amtLms = null;
1397 var promise = require('promise');
1398
1377 -function startLms(func, lmscommander) {
1399 +function startLms(func, lmscommander, tag) {
1400 var ret = new promise(function (res, rej) { this._res = res; this._rej = rej; });
1401 var lme_heci = null
1402 try { lme_heci = require('amt-lme'); } catch (ex) { }
1381 - if (lme_heci == null) { if (func != null) { func(func, 0); } this.promise._res(); return; }
1403 + if (lme_heci == null) { if (func != null) { func(0, tag); } this.promise._res(); return; }
1404
1405 //var amtLms = null;
1406 var http = require('http');
@@ -1396,10 +1418,10 @@ function startLms(func, lmscommander) {
1418 if (lmscommander === true) { //settings.noconsole !== true) {
1419 startMeshCommanderLms();
1420 //console.log("LMS started, MeshCommander on HTTP/16994.");
1399 - tempTimer = setTimeout(function () { delete tempTimer; setupMeiOsAdmin(func, 2); }, 100);
1421 + tempTimer = setTimeout(function () { delete tempTimer; setupMeiOsAdmin(func, 2, tag); }, 100);
1422 } else {
1423 //console.log('LME connection failed: ' + JSON.stringify(e));
1402 - tempTimer = setTimeout(function () { delete tempTimer; setupMeiOsAdmin(func, 0); }, 100);
1424 + tempTimer = setTimeout(function () { delete tempTimer; setupMeiOsAdmin(func, 0, tag); }, 100);
1425 }
1426 this.promise._res();
1427 });
@@ -1425,11 +1447,11 @@ function startLms(func, lmscommander) {
1447 if (settings.noconsole !== true) {
1448 startMeshCommanderLms();
1449 //console.log("LMS started, MeshCommander on HTTP/16994.");
1428 - tempTimer = setTimeout(function () { delete tempTimer; setupMeiOsAdmin(func, 2); }, 100);
1450 + tempTimer = setTimeout(function () { delete tempTimer; setupMeiOsAdmin(func, 2, tag); }, 100);
1451 //console.logReferenceCount(tempTimer);
1452 } else {
1453 //console.log("LMS started.");
1432 - tempTimer = setTimeout(function () { delete tempTimer; setupMeiOsAdmin(func, 1); }, 100);
1454 + tempTimer = setTimeout(function () { delete tempTimer; setupMeiOsAdmin(func, 1, tag); }, 100);
1455 //console.logReferenceCount(tempTimer);
1456 }
1457
@@ -1500,9 +1522,9 @@ function startMeshCommanderLms() {
1522 });
1523 }
1524
1503 -function setupMeiOsAdmin(func, state) {
1525 +function setupMeiOsAdmin(func, state, tag) {
1526 if (amtMei == null) {
1505 - if (func) { func(state); }
1527 + if (func) { func(state, tag); }
1528 } else {
1529 amtMei.getLocalSystemAccount(function (x) {
1530 var transport = require('amt-wsman-duk');
@@ -1510,7 +1532,7 @@ function setupMeiOsAdmin(func, state) {
1532 var amt = require('amt');
1533 oswsstack = new wsman(transport, '127.0.0.1', 16992, x.user, x.pass, false);
1534 osamtstack = new amt(oswsstack);
1513 - if (func) { func(state); }
1535 + if (func) { func(state, tag); }
1536
1537 //var AllWsman = "CIM_SoftwareIdentity,IPS_SecIOService,IPS_ScreenSettingData,IPS_ProvisioningRecordLog,IPS_HostBasedSetupService,IPS_HostIPSettings,IPS_IPv6PortSettings".split(',');
1538 //osamtstack.BatchEnum(null, AllWsman, startLmsWsmanResponse, null, true);
@@ -2088,11 +2110,116 @@ function iderSectorStats(mode, dev, mediaBlocks, lba, len) {
2110 iderIdleTimer = setTimeout(function () { console.log('Idle timeout'); process.exit(1); }, 1000 * settings.timeout);
2111 }
2112
2113 +//
2114 +// Intel AMT IPv4 wired configuration
2115 +//
2116 +
2117 +function performAmtNetConfig(args) {
2118 + if ((settings.hostname == '127.0.0.1') || (settings.hostname.toLowerCase() == 'localhost')) {
2119 + settings.noconsole = true; startLms(performAmtNetConfig0, false, args);
2120 + } else {
2121 + performAmtNetConfig0(1, args);
2122 + }
2123 +}
2124 +
2125 +function performAmtNetConfig0(state, args) {
2126 + var transport = require('amt-wsman-duk');
2127 + var wsman = require('amt-wsman');
2128 + var amt = require('amt');
2129 + wsstack = new wsman(transport, settings.hostname, settings.tls ? 16993 : 16992, settings.username, settings.password, settings.tls);
2130 + amtstack = new amt(wsstack);
2131 + amtstack.BatchEnum(null, ['AMT_EthernetPortSettings'], performAmtNetConfig1, args);
2132 +}
2133 +
2134 +function performAmtNetConfig1(stack, name, response, status, args) {
2135 + if (status == 200) {
2136 + // Set wired and wireless interfaces
2137 + var amtwirelessif = -1;
2138 + var amtwiredif = -1;
2139 + for (var y in response['AMT_EthernetPortSettings'].responses) {
2140 + var z = response['AMT_EthernetPortSettings'].responses[y];
2141 + 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.
2142 + 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
2143 + }
2144 +
2145 + // Check if configuration change is required
2146 + if (args) {
2147 + if (args.dhcp && (amtwiredif != -1) && (response['AMT_EthernetPortSettings'].responses[amtwiredif].DHCPEnabled == false)) {
2148 + // Change to DHCP
2149 + pendingAmtConfigActions++;
2150 + var x = response['AMT_EthernetPortSettings'].responses[amtwiredif];
2151 + x['DHCPEnabled'] = true;
2152 + delete x["IPAddress"];
2153 + delete x["SubnetMask"];
2154 + delete x["DefaultGateway"];
2155 + delete x["PrimaryDNS"];
2156 + delete x["SecondaryDNS"];
2157 + amtstack.Put("AMT_EthernetPortSettings", x, function (stack, name, response, status) { if (--pendingAmtConfigActions == 0) { performAmtNetConfig0(); } });
2158 + }
2159 + else if (args.static && (amtwiredif != -1) && (response['AMT_EthernetPortSettings'].responses[amtwiredif].DHCPEnabled == true)) {
2160 + // Change to STATIC
2161 + pendingAmtConfigActions++;
2162 + var x = response['AMT_EthernetPortSettings'].responses[amtwiredif];
2163 + x['DHCPEnabled'] = false;
2164 + delete x["IPAddress"];
2165 + delete x["SubnetMask"];
2166 + delete x["DefaultGateway"];
2167 + delete x["PrimaryDNS"];
2168 + delete x["SecondaryDNS"];
2169 + if (args.ip) { x["IPAddress"] = args.ip; } else { console.log('Missing IPv4 address, use --ip 1.2.3.4'); process.exit(1); }
2170 + if (args.subnet) { x["SubnetMask"] = args.subnet; } else { console.log('Missing IPv4 subnet, use --subnet 255.255.255.0'); process.exit(1); }
2171 + if (args.gateway) { x["DefaultGateway"] = args.gateway; }
2172 + if (args.dns) { x["PrimaryDNS"] = args.dns; }
2173 + if (args.dns2) { x["SecondaryDNS"] = args.dns2; }
2174 + amtstack.Put("AMT_EthernetPortSettings", x, function (stack, name, response, status) { console.log(status); if (--pendingAmtConfigActions == 0) { performAmtNetConfig0(); } });
2175 + }
2176 + }
2177 +
2178 + if (pendingAmtConfigActions == 0) {
2179 + if (amtwiredif != -1) { // Wired
2180 + var z = response['AMT_EthernetPortSettings'].responses[amtwiredif];
2181 + console.log('--WIRED---');
2182 + for (var i in z) {
2183 + if (['ElementName', 'InstanceID'].indexOf(i) == -1) {
2184 + var name = i;
2185 + while (name.length < 16) { name += ' '; }
2186 + console.log(name + ': ' + z[i]);
2187 + }
2188 + }
2189 + }
2190 + if (amtwirelessif != -1) { // Wireless
2191 + var z = response['AMT_EthernetPortSettings'].responses[amtwirelessif];
2192 + console.log('--WIRELESS---');
2193 + for (var i in z) {
2194 + if (['ElementName', 'InstanceID'].indexOf(i) == -1) {
2195 + var name = i;
2196 + while (name.length < 16) { name += ' '; }
2197 + console.log(name + ': ' + z[i]);
2198 + }
2199 + }
2200 + }
2201 + process.exit(0);
2202 + }
2203 + } else {
2204 + console.log('Error, status ' + status + '.');
2205 + process.exit(1);
2206 + }
2207 +}
2208 +
2209 +
2210 //
2211 // Intel AMT feature configuration action
2212 //
2213
2214 function performAmtFeatureConfig(args) {
2215 + if ((settings.hostname == '127.0.0.1') || (settings.hostname.toLowerCase() == 'localhost')) {
2216 + settings.noconsole = true; startLms(performAmtFeatureConfig0, false, args);
2217 + } else {
2218 + performAmtFeatureConfig0(1, args);
2219 + }
2220 +}
2221 +
2222 +function performAmtFeatureConfig0(state, args) {
2223 var transport = require('amt-wsman-duk');
2224 var wsman = require('amt-wsman');
2225 var amt = require('amt');
@@ -2101,7 +2228,6 @@ function performAmtFeatureConfig(args) {
2228 amtstack.BatchEnum(null, ['*IPS_OptInService', '*AMT_RedirectionService', '*CIM_KVMRedirectionSAP'], performAmtFeatureConfig1, args);
2229 }
2230
2104 -var pendingAmtConfigActions = 0;
2231 function performAmtFeatureConfig1(stack, name, response, status, args) {
2232 if (status == 200) {
2233 // User consent
@@ -2110,17 +2236,17 @@ function performAmtFeatureConfig1(stack, name, response, status, args) {
2236 if ((args.userconsent == 'none') && (optinrequired != 0)) {
2237 pendingAmtConfigActions++;
2238 response['IPS_OptInService'].response["OptInRequired"] = 0;
2113 - amtstack.Put("IPS_OptInService", response['IPS_OptInService'].response, function (stack, name, response, status) { if (--pendingAmtConfigActions == 0) { performAmtFeatureConfig(); } });
2239 + amtstack.Put("IPS_OptInService", response['IPS_OptInService'].response, function (stack, name, response, status) { if (--pendingAmtConfigActions == 0) { performAmtFeatureConfig0(); } });
2240 }
2241 else if ((args.userconsent == 'kvm') && (optinrequired != 1)) {
2242 pendingAmtConfigActions++;
2243 response['IPS_OptInService'].response["OptInRequired"] = 1;
2118 - amtstack.Put("IPS_OptInService", response['IPS_OptInService'].response, function (stack, name, response, status) { if (--pendingAmtConfigActions == 0) { performAmtFeatureConfig(); } });
2244 + amtstack.Put("IPS_OptInService", response['IPS_OptInService'].response, function (stack, name, response, status) { if (--pendingAmtConfigActions == 0) { performAmtFeatureConfig0(); } });
2245 }
2246 else if ((args.userconsent == 'all') && (optinrequired != 0xFFFFFFFF)) {
2247 pendingAmtConfigActions++;
2248 response['IPS_OptInService'].response["OptInRequired"] = 0xFFFFFFFF;
2123 - amtstack.Put("IPS_OptInService", response['IPS_OptInService'].response, function (stack, name, response, status) { if (--pendingAmtConfigActions == 0) { performAmtFeatureConfig(); } });
2249 + amtstack.Put("IPS_OptInService", response['IPS_OptInService'].response, function (stack, name, response, status) { if (--pendingAmtConfigActions == 0) { performAmtFeatureConfig0(); } });
2250 }
2251 }
2252
@@ -2138,8 +2264,8 @@ function performAmtFeatureConfig1(stack, name, response, status, args) {
2264 if ((sol == true) && ((args.sol == 'disabled') || (args.sol == 0))) { sol = false; redirchange = true; }
2265 if ((ider == false) && ((args.ider == 'enabled') || (args.ider == 1))) { ider = true; redirchange = true; }
2266 if ((ider == true) && ((args.ider == 'disabled') || (args.ider == 0))) { ider = false; redirchange = true; }
2141 - if (redirportchange) { pendingAmtConfigActions++; amtstack.Put("AMT_RedirectionService", response['AMT_RedirectionService'].response, function (stack, name, response, status) { if (--pendingAmtConfigActions == 0) { performAmtFeatureConfig(); } }); }
2142 - if (redirchange) { pendingAmtConfigActions++; amtstack.AMT_RedirectionService_RequestStateChange((32768 + ((ider ? 1 : 0) + (sol ? 2 : 0))), function (stack, name, response, status) { if (--pendingAmtConfigActions == 0) { performAmtFeatureConfig(); } }); }
2267 + if (redirportchange) { pendingAmtConfigActions++; amtstack.Put("AMT_RedirectionService", response['AMT_RedirectionService'].response, function (stack, name, response, status) { if (--pendingAmtConfigActions == 0) { performAmtFeatureConfig0(); } }); }
2268 + if (redirchange) { pendingAmtConfigActions++; amtstack.AMT_RedirectionService_RequestStateChange((32768 + ((ider ? 1 : 0) + (sol ? 2 : 0))), function (stack, name, response, status) { if (--pendingAmtConfigActions == 0) { performAmtFeatureConfig0(); } }); }
2269 }
2270
2271 // KVM
@@ -2150,19 +2276,19 @@ function performAmtFeatureConfig1(stack, name, response, status, args) {
2276 if (args) {
2277 if ((kvm == false) && ((args.kvm == 'enabled') || (args.kvm == 1))) { kvm = true; kvmchange = true; }
2278 if ((kvm == true) && ((args.kvm == 'disabled') || (args.kvm == 0))) { kvm = false; kvmchange = true; }
2153 - if (kvmchange) { pendingAmtConfigActions++; amtstack.CIM_KVMRedirectionSAP_RequestStateChange(kvm ? 2 : 3, 0, function (stack, name, response, status) { if (--pendingAmtConfigActions == 0) { performAmtFeatureConfig(); } }); }
2279 + if (kvmchange) { pendingAmtConfigActions++; amtstack.CIM_KVMRedirectionSAP_RequestStateChange(kvm ? 2 : 3, 0, function (stack, name, response, status) { if (--pendingAmtConfigActions == 0) { performAmtFeatureConfig0(); } }); }
2280 }
2281 }
2282
2283 if (pendingAmtConfigActions == 0) {
2158 - if (optinrequired == 0) { console.log('User Consent: None'); }
2159 - else if (optinrequired == 1) { console.log('User Consent: KVM'); }
2160 - else if (optinrequired == 0xFFFFFFFF) { console.log('User Consent: All'); }
2161 - else { console.log('User Consent: ' + optinrequired); }
2162 - console.log('Redirection Port: ' + (redir ? 'Enabled' : 'Disabled'));
2163 - console.log('Serial-over-LAN: ' + (sol ? 'Enabled' : 'Disabled'));
2164 - console.log('IDE Redirection: ' + (ider ? 'Enabled' : 'Disabled'));
2165 - if (response['CIM_KVMRedirectionSAP'] != null) { console.log('Remote desktop (KVM): ' + (kvm ? 'Enabled' : 'Disabled')); }
2284 + if (optinrequired == 0) { console.log('User Consent : None'); }
2285 + else if (optinrequired == 1) { console.log('User Consent : KVM'); }
2286 + else if (optinrequired == 0xFFFFFFFF) { console.log('User Consent : All'); }
2287 + else { console.log('User Consent : ' + optinrequired); }
2288 + console.log('Redirection Port : ' + (redir ? 'Enabled' : 'Disabled'));
2289 + console.log('Serial-over-LAN : ' + (sol ? 'Enabled' : 'Disabled'));
2290 + console.log('IDE Redirection : ' + (ider ? 'Enabled' : 'Disabled'));
2291 + if (response['CIM_KVMRedirectionSAP'] != null) { console.log('Remote desktop (KVM) : ' + (kvm ? 'Enabled' : 'Disabled')); }
2292 process.exit(0);
2293 }
2294 } else {
package.json
+1 -1
@@ -1,6 +1,6 @@
1 {
2 "name": "meshcentral",
3 - "version": "0.3.7-t",
3 + "version": "0.3.7-u",
4 "keywords": [
5 "Remote Management",
6 "Intel AMT",