From 6c0751ac828e4eb6f92f3a9755515586b711cfcf Mon Sep 17 00:00:00 2001 From: Ylian Saint-Hilaire Date: Mon, 15 Jul 2019 14:45:36 -0700 Subject: [PATCH] Added MeshCMD AmtNetwork command --- agents/MeshCmd-signed.exe | Bin 4103024 -> 4110112 bytes agents/MeshCmd64-signed.exe | Bin 3685744 -> 3692832 bytes agents/meshcmd.js | 180 ++++++++++++++++++++++++++++++------ agents/meshcmd.min.js | 180 ++++++++++++++++++++++++++++++------ package.json | 2 +- 5 files changed, 307 insertions(+), 55 deletions(-) diff --git a/agents/MeshCmd-signed.exe b/agents/MeshCmd-signed.exe index 403cad3d9c0b27b1834e1b927fdc3de4016d814d..92cbde26c6fefd82afdc6c47b0111c1b6f106e0e 100644 GIT binary patch delta 4958 zcmdT`c~p~E7B>)934-j1@CYqQfP@4P6~6amtx^$CP^p+x0{I}(ki;ac+M?*FwPWjO zPakS)#V(H4DpqT%9zE(zTWc%T+By}crO;ZJPAzS&^%mxDdD!2npN>+zC7gJPEuAya~n= z_z;K)d(2qXw12qp+22qg$32q&0C5J51RAd(=801!kIhzVi{9wB&? zAeKNvASI9y#1X_3BoN366!tTM#O%k{3G)*Ply+gh>Q0wyoyLNDG$_;^K%h()t-B{l zB1k4kA(%ptN-&jR8o_jeG=g;dJqh*2G>?MZl7)ryX4^k3r>Ia|Zll~h3us%t$+8sS z(+yNWxRL**H`-`Rm8OygR@!FM8>_82vw;e?yERhdr{E>WDKVaLlq$62{ghhZ!As$v zj#6R|ULlTcry~7E>cfw>Qz;Jqo>odF)aokDxa}!wGH!i~nrlxwNWCrK4l}P(fzoW9 z##l{*yrQ}kP_MVpS}=4sn+fF1$}R#mCM}KI)>D!AR2wDCwc0c`eI*$6`46giu{{&ShqFA- zQKPXgWd)~lg4G%uU9V{zA?YlrrK>cx1{>fxS>Y5;SZlP75M<7aEczOar4i&56mvo4 zug*$NaY!bO7A>YLO-Ah)vN)rKlHl_J(C0`yb-vP(-nL*E?ak$k2@>uPfRA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xLgfm-wl<&Wf;f8TGX>o|JHwzaj2{=h`W!PPtNw17MyZD(~V8B%v4~oKZruOhzlOvOhwQ;CO_4wG0Z-N_+?wFE=%X-J+$ET?tXVWwf)F7r; z&m{MH;)c=N);zzN9gD?9kDPfetbN;Sw)p<+^#aKrZ{6l_ShHsRy4un&&kW9Gojz8# zB=&|}J@}~Nh}*+P-cG-Fw`bpE$@Xkb^3u6k9P!Awoq59O^^nYA`-bd}<<(8u2IEtv zgXIx+?Ahw3Zj+j@M>F-z`L`#3R4*s}ucc&~d$!J8FUPB2HE4Rz-12U3u{_p#=H!8- Mee;R4N=i!q0-je=SO5S3 diff --git a/agents/MeshCmd64-signed.exe b/agents/MeshCmd64-signed.exe index 2950fff14bb2cd5d1bd080d8a03cad25464bd7e6..16b14ebc106c84d801ca5bccef576d688689d921 100644 GIT binary patch delta 4934 zcmdT{d3aM*7H`^gr3u|g)3WrYrAt(7_mONM766G$~2C0uuqH zPAhI8x2Vh%S4I{Y5K=@@P?SxD;*5&26jT^lL?0E7ZW z05M=BAPf)=hyX+aq5z`+5<+s$;qTx0H5%-=*N>70pvg#+C2G6AKLwx!r~qm}DnJ9!0@45z z0qO4R`!l|x0t=^>R}_^NxcB=Klccy(Lih(2(#|HEy%yo!u|#C7mH%b7I%#{A!AK(q z?R1*0)ef8!OT@bUM-wA5@FRL69^a=Uirl!E&)Uw+i4T(znjyB z@}}n&qdJ?3#%m`Kgj2XvpV3sN%))z4T==I#eoiJ<@5_Y3hmUbbY_p zGR_QpGlR)wryUNYu+#G!m|G^Z_nFAaI~wLeAO`F3mghO@431h>kmLlb4Nkhr&@xEU zThK&T85%53#B;L3>7201>KG)*oEO{8bq0G2$}246g34c=mCW!+rVSM>qm4GJX&70Y zJ)V%`Pqz`F+e?X0jh^(b?IvU)T+Wyv;al5?M6A9+2IB`e61ncpI|!WsYr2RaQ9Tr! z&0d#N=Y;CPHQhuyqi*)F%HjLh$G3p_Bqtf={#!k{M97oWjbuJv-9bd*0vj2N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@s~#KSw}K|w00SObkXIFQRt&LmbR?hE)Iz0#}sbYfa;vUGA%HDJ{pt7CZ6VYjc*JI6N`QcaAy5GDlyy`Wq|r%;}AI1+}@> zU_O)WVLU3N-R6@x=XC}34G~9urX8%e@Or;m6rw{25jrB}CUwuvbHn;TpD^7*qczAEgs`2ti z5!zE@w?zv5gM-bJow|B{)+Y7ZUdE0SVNY6b#Hl)jFZT5;7h95Ed*}7FZ~q)0nR#oT zzVVWO=bOXYV7~%qL6<3NZ{xO(?>tlg+*udAF23ofnt+Sa>Y|I>yYz@MI35R{6)6Ig z3STl&zJO`#RUTG8#lmbE3NFLxc!S$XVMMhyYhBmg){;8soTf~^ob_=C!>nnH5{$OU zX=L=Ofun=^C@*@d`*;jYV1P!mszgr&cw>)DTdV} ziEcZ7=u=kD8c2E@9at4Z^p+SZ*QY687Pq|Gc``ORVzdpcX*d;`e*dT}f%)=?!152b zuf^rc!eyz-}L*CAl}}>8$KB9%j+@Z zovY`(78W+$wwzZyJFa1*4CLp0NxSt2{l*6K?u?|%x{l&4*e(#gQL`+vHa~W^m`0=h E3!0rWS^xk5 diff --git a/agents/meshcmd.js b/agents/meshcmd.js index 2b60f643..0315eb24 100644 --- a/agents/meshcmd.js +++ b/agents/meshcmd.js @@ -46,6 +46,7 @@ var oswsstack = null, osamtstack = null; var amtMeiTmpState = null; var SMBiosTables = null; var globalDebugFlags = 0; // 1 = IDER Debug +var pendingAmtConfigActions = 0; const RCSMessageProtocolVersion = 1; // RCS Message Protocol Version. Needs to be less than or equal to RCS server Message Protocol Version // MeshCommander for Firmware (GZIP'ed, Base64) v0.7.8 @@ -113,7 +114,7 @@ function run(argv) { //console.log('addedModules = ' + JSON.stringify(addedModules)); var actionpath = 'meshaction.txt'; if (args.actionfile != null) { actionpath = args.actionfile; } - var actions = ['HELP', 'ROUTE', 'MICROLMS', 'AMTPOWER', 'AMTFEATURES', 'AMTLOADWEBAPP', 'AMTLOADSMALLWEBAPP', 'AMTLOADLARGEWEBAPP', 'AMTCLEARWEBAPP', 'AMTSTORAGESTATE', 'AMTINFO', 'AMTINFODEBUG', 'AMTVERSIONS', 'AMTHASHES', 'AMTSAVESTATE', 'AMTSCRIPT', 'AMTUUID', 'AMTCCM', 'AMTACM', 'AMTDEACTIVATE', 'AMTACMDEACTIVATE', 'SMBIOS', 'RAWSMBIOS', 'MESHCOMMANDER', 'AMTAUDITLOG', 'AMTPRESENCE']; + 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']; // Load the action file var actionfile = null; @@ -190,6 +191,7 @@ function run(argv) { console.log(' AmtScript - Run .mescript on Intel AMT.'); console.log(' AmtIDER - Mount local disk image to remote computer.'); console.log(' AmtFeatures - Intel AMT features & user consent.'); + console.log(' AmtNetwork - Intel AMT network interface settings.'); console.log('\r\nHelp on a specific action using:\r\n'); console.log(' meshcmd help [action]'); exit(1); return; @@ -300,12 +302,27 @@ function run(argv) { } else if (action == 'amtpower') { 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'); console.log('\r\nRequired arguments:\r\n'); - console.log(' --host [hostname] The IP address or DNS name of Intel AMT, 127.0.0.1 is default.'); + console.log(' --host [hostname] The IP address or DNS name of Intel AMT.'); console.log(' --pass [password] The Intel AMT login password.'); console.log('\r\nOptional arguments:\r\n'); console.log(' --reset, --poweron, --poweroff, --powercycle, --sleep, --hibernate'); console.log(' --user [username] The Intel AMT login username, admin is default.'); console.log(' --tls Specifies that TLS must be used.'); + } else if (action == 'amtnetwork') { + 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'); + console.log('\r\nRequired arguments:\r\n'); + console.log(' --host [hostname] The IP address or DNS name of Intel AMT, 127.0.0.1 is default.'); + console.log(' --pass [password] The Intel AMT login password.'); + 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(' --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)'); + console.log(' --subnet [1.2.3.4] Static IPv4 subnet mask'); + console.log(' --gateway [1.2.3.4] Static IPv4 default gateway'); + console.log(' --dns [1.2.3.4] Primary DNS IPv4 address'); + console.log(' --dns2 [1.2.3.4] Secondary DNS IPv4 address'); } else if (action == 'amtfeatures') { 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'); console.log('\r\nRequired arguments:\r\n'); @@ -596,8 +613,13 @@ function run(argv) { if ((settings.cdrom == null) || (typeof settings.cdrom != 'string') || (settings.cdrom == '')) { settings.cdrom = null; } 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; } performIder(); + } else if (settings.action == 'amtnetwork') { // Perform remote Intel AMT wired IPv4 configuration operation + if (settings.hostname == null) { settings.hostname = '127.0.0.1'; } + if ((settings.password == null) || (typeof settings.password != 'string') || (settings.password == '')) { console.log('No or invalid \"password\" specified, use --password [password].'); exit(1); return; } + if ((settings.username == null) || (typeof settings.username != 'string') || (settings.username == '')) { settings.username = 'admin'; } + performAmtNetConfig(args); } else if (settings.action == 'amtfeatures') { // Perform remote Intel AMT feature configuration operation - if ((settings.hostname == null) || (typeof settings.hostname != 'string') || (settings.hostname == '')) { console.log('No or invalid \"hostname\" specified, use --hostname [host].'); exit(1); return; } + if (settings.hostname == null) { settings.hostname = '127.0.0.1'; } if ((settings.password == null) || (typeof settings.password != 'string') || (settings.password == '')) { console.log('No or invalid \"password\" specified, use --password [password].'); exit(1); return; } if ((settings.username == null) || (typeof settings.username != 'string') || (settings.username == '')) { settings.username = 'admin'; } performAmtFeatureConfig(args); @@ -1374,11 +1396,11 @@ var lmsNotifications = []; var amtLms = null; var promise = require('promise'); -function startLms(func, lmscommander) { +function startLms(func, lmscommander, tag) { var ret = new promise(function (res, rej) { this._res = res; this._rej = rej; }); var lme_heci = null try { lme_heci = require('amt-lme'); } catch (ex) { } - if (lme_heci == null) { if (func != null) { func(func, 0); } this.promise._res(); return; } + if (lme_heci == null) { if (func != null) { func(0, tag); } this.promise._res(); return; } //var amtLms = null; var http = require('http'); @@ -1396,10 +1418,10 @@ function startLms(func, lmscommander) { if (lmscommander === true) { //settings.noconsole !== true) { startMeshCommanderLms(); //console.log("LMS started, MeshCommander on HTTP/16994."); - tempTimer = setTimeout(function () { delete tempTimer; setupMeiOsAdmin(func, 2); }, 100); + tempTimer = setTimeout(function () { delete tempTimer; setupMeiOsAdmin(func, 2, tag); }, 100); } else { //console.log('LME connection failed: ' + JSON.stringify(e)); - tempTimer = setTimeout(function () { delete tempTimer; setupMeiOsAdmin(func, 0); }, 100); + tempTimer = setTimeout(function () { delete tempTimer; setupMeiOsAdmin(func, 0, tag); }, 100); } this.promise._res(); }); @@ -1425,11 +1447,11 @@ function startLms(func, lmscommander) { if (settings.noconsole !== true) { startMeshCommanderLms(); //console.log("LMS started, MeshCommander on HTTP/16994."); - tempTimer = setTimeout(function () { delete tempTimer; setupMeiOsAdmin(func, 2); }, 100); + tempTimer = setTimeout(function () { delete tempTimer; setupMeiOsAdmin(func, 2, tag); }, 100); //console.logReferenceCount(tempTimer); } else { //console.log("LMS started."); - tempTimer = setTimeout(function () { delete tempTimer; setupMeiOsAdmin(func, 1); }, 100); + tempTimer = setTimeout(function () { delete tempTimer; setupMeiOsAdmin(func, 1, tag); }, 100); //console.logReferenceCount(tempTimer); } @@ -1500,9 +1522,9 @@ function startMeshCommanderLms() { }); } -function setupMeiOsAdmin(func, state) { +function setupMeiOsAdmin(func, state, tag) { if (amtMei == null) { - if (func) { func(state); } + if (func) { func(state, tag); } } else { amtMei.getLocalSystemAccount(function (x) { var transport = require('amt-wsman-duk'); @@ -1510,7 +1532,7 @@ function setupMeiOsAdmin(func, state) { var amt = require('amt'); oswsstack = new wsman(transport, '127.0.0.1', 16992, x.user, x.pass, false); osamtstack = new amt(oswsstack); - if (func) { func(state); } + if (func) { func(state, tag); } //var AllWsman = "CIM_SoftwareIdentity,IPS_SecIOService,IPS_ScreenSettingData,IPS_ProvisioningRecordLog,IPS_HostBasedSetupService,IPS_HostIPSettings,IPS_IPv6PortSettings".split(','); //osamtstack.BatchEnum(null, AllWsman, startLmsWsmanResponse, null, true); @@ -2088,11 +2110,116 @@ function iderSectorStats(mode, dev, mediaBlocks, lba, len) { iderIdleTimer = setTimeout(function () { console.log('Idle timeout'); process.exit(1); }, 1000 * settings.timeout); } +// +// Intel AMT IPv4 wired configuration +// + +function performAmtNetConfig(args) { + if ((settings.hostname == '127.0.0.1') || (settings.hostname.toLowerCase() == 'localhost')) { + settings.noconsole = true; startLms(performAmtNetConfig0, false, args); + } else { + performAmtNetConfig0(1, args); + } +} + +function performAmtNetConfig0(state, args) { + var transport = require('amt-wsman-duk'); + var wsman = require('amt-wsman'); + var amt = require('amt'); + wsstack = new wsman(transport, settings.hostname, settings.tls ? 16993 : 16992, settings.username, settings.password, settings.tls); + amtstack = new amt(wsstack); + amtstack.BatchEnum(null, ['AMT_EthernetPortSettings'], performAmtNetConfig1, args); +} + +function performAmtNetConfig1(stack, name, response, status, args) { + if (status == 200) { + // Set wired and wireless interfaces + var amtwirelessif = -1; + var amtwiredif = -1; + 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 + } + + // Check if configuration change is required + if (args) { + 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(); } }); + } + 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(); } }); + } + } + + if (pendingAmtConfigActions == 0) { + 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]); + } + } + } + if (amtwirelessif != -1) { // Wireless + var z = response['AMT_EthernetPortSettings'].responses[amtwirelessif]; + console.log('--WIRELESS---'); + for (var i in z) { + if (['ElementName', 'InstanceID'].indexOf(i) == -1) { + var name = i; + while (name.length < 16) { name += ' '; } + console.log(name + ': ' + z[i]); + } + } + } + process.exit(0); + } + } else { + console.log('Error, status ' + status + '.'); + process.exit(1); + } +} + + // // Intel AMT feature configuration action // function performAmtFeatureConfig(args) { + if ((settings.hostname == '127.0.0.1') || (settings.hostname.toLowerCase() == 'localhost')) { + settings.noconsole = true; startLms(performAmtFeatureConfig0, false, args); + } else { + performAmtFeatureConfig0(1, args); + } +} + +function performAmtFeatureConfig0(state, args) { var transport = require('amt-wsman-duk'); var wsman = require('amt-wsman'); var amt = require('amt'); @@ -2101,7 +2228,6 @@ function performAmtFeatureConfig(args) { amtstack.BatchEnum(null, ['*IPS_OptInService', '*AMT_RedirectionService', '*CIM_KVMRedirectionSAP'], performAmtFeatureConfig1, args); } -var pendingAmtConfigActions = 0; function performAmtFeatureConfig1(stack, name, response, status, args) { if (status == 200) { // User consent @@ -2110,17 +2236,17 @@ function performAmtFeatureConfig1(stack, name, response, status, 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) { performAmtFeatureConfig(); } }); + 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) { performAmtFeatureConfig(); } }); + 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) { performAmtFeatureConfig(); } }); + amtstack.Put("IPS_OptInService", response['IPS_OptInService'].response, function (stack, name, response, status) { if (--pendingAmtConfigActions == 0) { performAmtFeatureConfig0(); } }); } } @@ -2138,8 +2264,8 @@ function performAmtFeatureConfig1(stack, name, response, status, args) { 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; } if ((ider == true) && ((args.ider == 'disabled') || (args.ider == 0))) { ider = false; redirchange = true; } - if (redirportchange) { pendingAmtConfigActions++; amtstack.Put("AMT_RedirectionService", response['AMT_RedirectionService'].response, function (stack, name, response, status) { if (--pendingAmtConfigActions == 0) { performAmtFeatureConfig(); } }); } - if (redirchange) { pendingAmtConfigActions++; amtstack.AMT_RedirectionService_RequestStateChange((32768 + ((ider ? 1 : 0) + (sol ? 2 : 0))), function (stack, name, response, status) { if (--pendingAmtConfigActions == 0) { performAmtFeatureConfig(); } }); } + if (redirportchange) { pendingAmtConfigActions++; amtstack.Put("AMT_RedirectionService", response['AMT_RedirectionService'].response, function (stack, name, response, status) { if (--pendingAmtConfigActions == 0) { performAmtFeatureConfig0(); } }); } + if (redirchange) { pendingAmtConfigActions++; amtstack.AMT_RedirectionService_RequestStateChange((32768 + ((ider ? 1 : 0) + (sol ? 2 : 0))), function (stack, name, response, status) { if (--pendingAmtConfigActions == 0) { performAmtFeatureConfig0(); } }); } } // KVM @@ -2150,19 +2276,19 @@ function performAmtFeatureConfig1(stack, name, response, status, args) { 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; } - if (kvmchange) { pendingAmtConfigActions++; amtstack.CIM_KVMRedirectionSAP_RequestStateChange(kvm ? 2 : 3, 0, function (stack, name, response, status) { if (--pendingAmtConfigActions == 0) { performAmtFeatureConfig(); } }); } + if (kvmchange) { pendingAmtConfigActions++; amtstack.CIM_KVMRedirectionSAP_RequestStateChange(kvm ? 2 : 3, 0, function (stack, name, response, status) { if (--pendingAmtConfigActions == 0) { performAmtFeatureConfig0(); } }); } } } 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 { diff --git a/agents/meshcmd.min.js b/agents/meshcmd.min.js index 2b60f643..0315eb24 100644 --- a/agents/meshcmd.min.js +++ b/agents/meshcmd.min.js @@ -46,6 +46,7 @@ var oswsstack = null, osamtstack = null; var amtMeiTmpState = null; var SMBiosTables = null; var globalDebugFlags = 0; // 1 = IDER Debug +var pendingAmtConfigActions = 0; const RCSMessageProtocolVersion = 1; // RCS Message Protocol Version. Needs to be less than or equal to RCS server Message Protocol Version // MeshCommander for Firmware (GZIP'ed, Base64) v0.7.8 @@ -113,7 +114,7 @@ function run(argv) { //console.log('addedModules = ' + JSON.stringify(addedModules)); var actionpath = 'meshaction.txt'; if (args.actionfile != null) { actionpath = args.actionfile; } - var actions = ['HELP', 'ROUTE', 'MICROLMS', 'AMTPOWER', 'AMTFEATURES', 'AMTLOADWEBAPP', 'AMTLOADSMALLWEBAPP', 'AMTLOADLARGEWEBAPP', 'AMTCLEARWEBAPP', 'AMTSTORAGESTATE', 'AMTINFO', 'AMTINFODEBUG', 'AMTVERSIONS', 'AMTHASHES', 'AMTSAVESTATE', 'AMTSCRIPT', 'AMTUUID', 'AMTCCM', 'AMTACM', 'AMTDEACTIVATE', 'AMTACMDEACTIVATE', 'SMBIOS', 'RAWSMBIOS', 'MESHCOMMANDER', 'AMTAUDITLOG', 'AMTPRESENCE']; + 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']; // Load the action file var actionfile = null; @@ -190,6 +191,7 @@ function run(argv) { console.log(' AmtScript - Run .mescript on Intel AMT.'); console.log(' AmtIDER - Mount local disk image to remote computer.'); console.log(' AmtFeatures - Intel AMT features & user consent.'); + console.log(' AmtNetwork - Intel AMT network interface settings.'); console.log('\r\nHelp on a specific action using:\r\n'); console.log(' meshcmd help [action]'); exit(1); return; @@ -300,12 +302,27 @@ function run(argv) { } else if (action == 'amtpower') { 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'); console.log('\r\nRequired arguments:\r\n'); - console.log(' --host [hostname] The IP address or DNS name of Intel AMT, 127.0.0.1 is default.'); + console.log(' --host [hostname] The IP address or DNS name of Intel AMT.'); console.log(' --pass [password] The Intel AMT login password.'); console.log('\r\nOptional arguments:\r\n'); console.log(' --reset, --poweron, --poweroff, --powercycle, --sleep, --hibernate'); console.log(' --user [username] The Intel AMT login username, admin is default.'); console.log(' --tls Specifies that TLS must be used.'); + } else if (action == 'amtnetwork') { + 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'); + console.log('\r\nRequired arguments:\r\n'); + console.log(' --host [hostname] The IP address or DNS name of Intel AMT, 127.0.0.1 is default.'); + console.log(' --pass [password] The Intel AMT login password.'); + 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(' --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)'); + console.log(' --subnet [1.2.3.4] Static IPv4 subnet mask'); + console.log(' --gateway [1.2.3.4] Static IPv4 default gateway'); + console.log(' --dns [1.2.3.4] Primary DNS IPv4 address'); + console.log(' --dns2 [1.2.3.4] Secondary DNS IPv4 address'); } else if (action == 'amtfeatures') { 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'); console.log('\r\nRequired arguments:\r\n'); @@ -596,8 +613,13 @@ function run(argv) { if ((settings.cdrom == null) || (typeof settings.cdrom != 'string') || (settings.cdrom == '')) { settings.cdrom = null; } 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; } performIder(); + } else if (settings.action == 'amtnetwork') { // Perform remote Intel AMT wired IPv4 configuration operation + if (settings.hostname == null) { settings.hostname = '127.0.0.1'; } + if ((settings.password == null) || (typeof settings.password != 'string') || (settings.password == '')) { console.log('No or invalid \"password\" specified, use --password [password].'); exit(1); return; } + if ((settings.username == null) || (typeof settings.username != 'string') || (settings.username == '')) { settings.username = 'admin'; } + performAmtNetConfig(args); } else if (settings.action == 'amtfeatures') { // Perform remote Intel AMT feature configuration operation - if ((settings.hostname == null) || (typeof settings.hostname != 'string') || (settings.hostname == '')) { console.log('No or invalid \"hostname\" specified, use --hostname [host].'); exit(1); return; } + if (settings.hostname == null) { settings.hostname = '127.0.0.1'; } if ((settings.password == null) || (typeof settings.password != 'string') || (settings.password == '')) { console.log('No or invalid \"password\" specified, use --password [password].'); exit(1); return; } if ((settings.username == null) || (typeof settings.username != 'string') || (settings.username == '')) { settings.username = 'admin'; } performAmtFeatureConfig(args); @@ -1374,11 +1396,11 @@ var lmsNotifications = []; var amtLms = null; var promise = require('promise'); -function startLms(func, lmscommander) { +function startLms(func, lmscommander, tag) { var ret = new promise(function (res, rej) { this._res = res; this._rej = rej; }); var lme_heci = null try { lme_heci = require('amt-lme'); } catch (ex) { } - if (lme_heci == null) { if (func != null) { func(func, 0); } this.promise._res(); return; } + if (lme_heci == null) { if (func != null) { func(0, tag); } this.promise._res(); return; } //var amtLms = null; var http = require('http'); @@ -1396,10 +1418,10 @@ function startLms(func, lmscommander) { if (lmscommander === true) { //settings.noconsole !== true) { startMeshCommanderLms(); //console.log("LMS started, MeshCommander on HTTP/16994."); - tempTimer = setTimeout(function () { delete tempTimer; setupMeiOsAdmin(func, 2); }, 100); + tempTimer = setTimeout(function () { delete tempTimer; setupMeiOsAdmin(func, 2, tag); }, 100); } else { //console.log('LME connection failed: ' + JSON.stringify(e)); - tempTimer = setTimeout(function () { delete tempTimer; setupMeiOsAdmin(func, 0); }, 100); + tempTimer = setTimeout(function () { delete tempTimer; setupMeiOsAdmin(func, 0, tag); }, 100); } this.promise._res(); }); @@ -1425,11 +1447,11 @@ function startLms(func, lmscommander) { if (settings.noconsole !== true) { startMeshCommanderLms(); //console.log("LMS started, MeshCommander on HTTP/16994."); - tempTimer = setTimeout(function () { delete tempTimer; setupMeiOsAdmin(func, 2); }, 100); + tempTimer = setTimeout(function () { delete tempTimer; setupMeiOsAdmin(func, 2, tag); }, 100); //console.logReferenceCount(tempTimer); } else { //console.log("LMS started."); - tempTimer = setTimeout(function () { delete tempTimer; setupMeiOsAdmin(func, 1); }, 100); + tempTimer = setTimeout(function () { delete tempTimer; setupMeiOsAdmin(func, 1, tag); }, 100); //console.logReferenceCount(tempTimer); } @@ -1500,9 +1522,9 @@ function startMeshCommanderLms() { }); } -function setupMeiOsAdmin(func, state) { +function setupMeiOsAdmin(func, state, tag) { if (amtMei == null) { - if (func) { func(state); } + if (func) { func(state, tag); } } else { amtMei.getLocalSystemAccount(function (x) { var transport = require('amt-wsman-duk'); @@ -1510,7 +1532,7 @@ function setupMeiOsAdmin(func, state) { var amt = require('amt'); oswsstack = new wsman(transport, '127.0.0.1', 16992, x.user, x.pass, false); osamtstack = new amt(oswsstack); - if (func) { func(state); } + if (func) { func(state, tag); } //var AllWsman = "CIM_SoftwareIdentity,IPS_SecIOService,IPS_ScreenSettingData,IPS_ProvisioningRecordLog,IPS_HostBasedSetupService,IPS_HostIPSettings,IPS_IPv6PortSettings".split(','); //osamtstack.BatchEnum(null, AllWsman, startLmsWsmanResponse, null, true); @@ -2088,11 +2110,116 @@ function iderSectorStats(mode, dev, mediaBlocks, lba, len) { iderIdleTimer = setTimeout(function () { console.log('Idle timeout'); process.exit(1); }, 1000 * settings.timeout); } +// +// Intel AMT IPv4 wired configuration +// + +function performAmtNetConfig(args) { + if ((settings.hostname == '127.0.0.1') || (settings.hostname.toLowerCase() == 'localhost')) { + settings.noconsole = true; startLms(performAmtNetConfig0, false, args); + } else { + performAmtNetConfig0(1, args); + } +} + +function performAmtNetConfig0(state, args) { + var transport = require('amt-wsman-duk'); + var wsman = require('amt-wsman'); + var amt = require('amt'); + wsstack = new wsman(transport, settings.hostname, settings.tls ? 16993 : 16992, settings.username, settings.password, settings.tls); + amtstack = new amt(wsstack); + amtstack.BatchEnum(null, ['AMT_EthernetPortSettings'], performAmtNetConfig1, args); +} + +function performAmtNetConfig1(stack, name, response, status, args) { + if (status == 200) { + // Set wired and wireless interfaces + var amtwirelessif = -1; + var amtwiredif = -1; + 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 + } + + // Check if configuration change is required + if (args) { + 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(); } }); + } + 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(); } }); + } + } + + if (pendingAmtConfigActions == 0) { + 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]); + } + } + } + if (amtwirelessif != -1) { // Wireless + var z = response['AMT_EthernetPortSettings'].responses[amtwirelessif]; + console.log('--WIRELESS---'); + for (var i in z) { + if (['ElementName', 'InstanceID'].indexOf(i) == -1) { + var name = i; + while (name.length < 16) { name += ' '; } + console.log(name + ': ' + z[i]); + } + } + } + process.exit(0); + } + } else { + console.log('Error, status ' + status + '.'); + process.exit(1); + } +} + + // // Intel AMT feature configuration action // function performAmtFeatureConfig(args) { + if ((settings.hostname == '127.0.0.1') || (settings.hostname.toLowerCase() == 'localhost')) { + settings.noconsole = true; startLms(performAmtFeatureConfig0, false, args); + } else { + performAmtFeatureConfig0(1, args); + } +} + +function performAmtFeatureConfig0(state, args) { var transport = require('amt-wsman-duk'); var wsman = require('amt-wsman'); var amt = require('amt'); @@ -2101,7 +2228,6 @@ function performAmtFeatureConfig(args) { amtstack.BatchEnum(null, ['*IPS_OptInService', '*AMT_RedirectionService', '*CIM_KVMRedirectionSAP'], performAmtFeatureConfig1, args); } -var pendingAmtConfigActions = 0; function performAmtFeatureConfig1(stack, name, response, status, args) { if (status == 200) { // User consent @@ -2110,17 +2236,17 @@ function performAmtFeatureConfig1(stack, name, response, status, 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) { performAmtFeatureConfig(); } }); + 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) { performAmtFeatureConfig(); } }); + 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) { performAmtFeatureConfig(); } }); + amtstack.Put("IPS_OptInService", response['IPS_OptInService'].response, function (stack, name, response, status) { if (--pendingAmtConfigActions == 0) { performAmtFeatureConfig0(); } }); } } @@ -2138,8 +2264,8 @@ function performAmtFeatureConfig1(stack, name, response, status, args) { 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; } if ((ider == true) && ((args.ider == 'disabled') || (args.ider == 0))) { ider = false; redirchange = true; } - if (redirportchange) { pendingAmtConfigActions++; amtstack.Put("AMT_RedirectionService", response['AMT_RedirectionService'].response, function (stack, name, response, status) { if (--pendingAmtConfigActions == 0) { performAmtFeatureConfig(); } }); } - if (redirchange) { pendingAmtConfigActions++; amtstack.AMT_RedirectionService_RequestStateChange((32768 + ((ider ? 1 : 0) + (sol ? 2 : 0))), function (stack, name, response, status) { if (--pendingAmtConfigActions == 0) { performAmtFeatureConfig(); } }); } + if (redirportchange) { pendingAmtConfigActions++; amtstack.Put("AMT_RedirectionService", response['AMT_RedirectionService'].response, function (stack, name, response, status) { if (--pendingAmtConfigActions == 0) { performAmtFeatureConfig0(); } }); } + if (redirchange) { pendingAmtConfigActions++; amtstack.AMT_RedirectionService_RequestStateChange((32768 + ((ider ? 1 : 0) + (sol ? 2 : 0))), function (stack, name, response, status) { if (--pendingAmtConfigActions == 0) { performAmtFeatureConfig0(); } }); } } // KVM @@ -2150,19 +2276,19 @@ function performAmtFeatureConfig1(stack, name, response, status, args) { 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; } - if (kvmchange) { pendingAmtConfigActions++; amtstack.CIM_KVMRedirectionSAP_RequestStateChange(kvm ? 2 : 3, 0, function (stack, name, response, status) { if (--pendingAmtConfigActions == 0) { performAmtFeatureConfig(); } }); } + if (kvmchange) { pendingAmtConfigActions++; amtstack.CIM_KVMRedirectionSAP_RequestStateChange(kvm ? 2 : 3, 0, function (stack, name, response, status) { if (--pendingAmtConfigActions == 0) { performAmtFeatureConfig0(); } }); } } } 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 { diff --git a/package.json b/package.json index ba9d5210..168187f1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "meshcentral", - "version": "0.3.7-t", + "version": "0.3.7-u", "keywords": [ "Remote Management", "Intel AMT",