Added MeshCMD AmtInfoJSON --post [url] option.

Ylian Saint-Hilaire committed Jul 19, 2021 at 15:42 UTC af32310da71b02614553e00a31267155fc4a1dd4
5 files changed +48 -2
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
+21 -1
@@ -225,6 +225,10 @@ function run(argv) {
225 console.log('AmtInfo action will get the version and activation state of Intel AMT on this computer. The command must be run on a computer with Intel AMT, must run as administrator and the Intel management driver must be installed. Example usage:\r\n\r\n meshcmd amtinfo');
226 console.log('\r\nPossible arguments:\r\n');
227 console.log(' --json Display all Intel AMT state in JSON format.');
228 + } else if (action == 'amtinfojson') {
229 + console.log('AmtInfoJson action get Intel AMT information about the computer and display it or send it to a server using HTTP. Example usage:\r\n\r\n meshcmd amtinfojson --post https://example.com/capture');
230 + console.log('\r\nPossible arguments:\r\n');
231 + console.log(' --post [url] Perform an HTTP POST of the data to the given URL.');
232 } else if ((action == 'amtversion') || (action == 'amtversions')) {
233 console.log('AmtVersions will display all version information about Intel AMT on this computer. The command must be run on a computer with Intel AMT, must run as administrator and the Intel management driver must be installed. Example usage:\r\n\r\n meshcmd amtversions');
234 console.log('\r\nPossible arguments:\r\n');
@@ -613,7 +617,23 @@ function run(argv) {
617 } catch (ex) { console.log("Unable to perform MEI operations, try running as " + ((process.platform == 'win32')?"administrator.":"root.")); exit(1); return; }
618 } else if (settings.action == 'amtinfojson') {
619 // Display Intel AMT version and activation state
616 - getMeiState(15, function (state) { console.log(JSON.stringify(state, null, 2)); exit(0); }); // Flags: 1 = Versions, 2 = OsAdmin, 4 = Hashes, 8 = Network
620 + getMeiState(15, function (state) { // Flags: 1 = Versions, 2 = OsAdmin, 4 = Hashes, 8 = Network
621 + if (typeof args.post == 'string') {
622 + console.log("Attempting to send to " + args.post);
623 + var http = require('http');
624 + var options = http.parseUri(args.post);
625 + options.method = 'POST';
626 + options.rejectUnauthorized = false;
627 + options.checkServerIdentity = function (cert) { }
628 + //console.log("options: " + JSON.stringify(options, null, 2));
629 + var req = http.request(options);
630 + req.on('error', function (e) { console.log("Error: " + e); exit(1); });
631 + req.on('response', function (response) { console.log("Status code: " + response.statusCode); exit(1); });
632 + req.end(JSON.stringify(state));
633 + } else {
634 + console.log(JSON.stringify(state, null, 2)); exit(0);
635 + }
636 + });
637 } else if (settings.action == 'amtsavestate') {
638 // Save the entire state of Intel AMT info a JSON file
639 if ((settings.password == null) || (typeof settings.password != 'string') || (settings.password == '')) { console.log('No or invalid \"password\" specified, use --password [password].'); exit(1); return; }
package.json
+13 -1
@@ -36,6 +36,8 @@
36 "sample-config-advanced.json"
37 ],
38 "dependencies": {
39 + "archiver": "^4.0.2",
40 + "archiver-zip-encrypted": "^1.0.10",
41 "body-parser": "^1.19.0",
42 "cbor": "~5.2.0",
43 "compression": "^1.7.4",
@@ -43,14 +45,24 @@
45 "express": "^4.17.0",
46 "express-handlebars": "^3.1.0",
47 "express-ws": "^4.0.0",
48 + "image-size": "^1.0.0",
49 "ipcheck": "^0.1.0",
50 + "loadavg-windows": "^1.1.1",
51 "minimist": "^1.2.0",
52 + "mongodb": "^4.0.0",
53 "multiparty": "^4.2.1",
54 "nedb": "^1.8.0",
55 "node-forge": "^0.10.0",
56 + "node-rdpjs-2": "^0.3.5",
57 + "node-windows": "^1.0.0-beta.5",
58 + "otplib": "^10.2.3",
59 + "saslprep": "^1.0.3",
60 + "ssh2": "^1.1.0",
61 + "web-push": "^3.4.5",
62 "ws": "^5.2.3",
63 "xmldom": "^0.5.0",
53 - "yauzl": "^2.10.0"
64 + "yauzl": "^2.10.0",
65 + "yubikeyotp": "^0.2.0"
66 },
67 "repository": {
68 "type": "git",
webserver.js
+14
@@ -5721,6 +5721,20 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
5721 if (obj.parent.config.firebase.relayserver) { parent.debug('email', 'Firebase-relay-handler'); obj.app.ws(url + 'firebaserelay.aspx', handleFirebaseRelayRequest); }
5722 }
5723
5724 + /*
5725 + // Testing code only, display a POST and return 200 OK
5726 + obj.app.post(url + 'post.aspx', function (req, res) {
5727 + var body = [];
5728 + req.on('data', function(chunk) {
5729 + body.push(chunk);
5730 + }).on('end', () => {
5731 + body = Buffer.concat(body).toString();
5732 + console.log(body);
5733 + res.sendStatus(200);
5734 + });
5735 + });
5736 + */
5737 +
5738 // Setup auth strategies using passport if needed
5739 if (typeof domain.authstrategies == 'object') {
5740 const passport = domain.passport = require('passport');