Added MeshCMD AmtInfoJSON --post [url] option.

This commit is contained in:
Ylian Saint-Hilaire 2021-07-19 15:42:29 -07:00
parent 3e46c671d5
commit af32310da7
5 changed files with 48 additions and 2 deletions

Binary file not shown.

Binary file not shown.

View File

@ -225,6 +225,10 @@ function run(argv) {
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');
console.log('\r\nPossible arguments:\r\n');
console.log(' --json Display all Intel AMT state in JSON format.');
} else if (action == 'amtinfojson') {
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');
console.log('\r\nPossible arguments:\r\n');
console.log(' --post [url] Perform an HTTP POST of the data to the given URL.');
} else if ((action == 'amtversion') || (action == 'amtversions')) {
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');
console.log('\r\nPossible arguments:\r\n');
@ -613,7 +617,23 @@ function run(argv) {
} catch (ex) { console.log("Unable to perform MEI operations, try running as " + ((process.platform == 'win32')?"administrator.":"root.")); exit(1); return; }
} else if (settings.action == 'amtinfojson') {
// Display Intel AMT version and activation state
getMeiState(15, function (state) { console.log(JSON.stringify(state, null, 2)); exit(0); }); // Flags: 1 = Versions, 2 = OsAdmin, 4 = Hashes, 8 = Network
getMeiState(15, function (state) { // Flags: 1 = Versions, 2 = OsAdmin, 4 = Hashes, 8 = Network
if (typeof args.post == 'string') {
console.log("Attempting to send to " + args.post);
var http = require('http');
var options = http.parseUri(args.post);
options.method = 'POST';
options.rejectUnauthorized = false;
options.checkServerIdentity = function (cert) { }
//console.log("options: " + JSON.stringify(options, null, 2));
var req = http.request(options);
req.on('error', function (e) { console.log("Error: " + e); exit(1); });
req.on('response', function (response) { console.log("Status code: " + response.statusCode); exit(1); });
req.end(JSON.stringify(state));
} else {
console.log(JSON.stringify(state, null, 2)); exit(0);
}
});
} else if (settings.action == 'amtsavestate') {
// Save the entire state of Intel AMT info a JSON file
if ((settings.password == null) || (typeof settings.password != 'string') || (settings.password == '')) { console.log('No or invalid \"password\" specified, use --password [password].'); exit(1); return; }

View File

@ -36,6 +36,8 @@
"sample-config-advanced.json"
],
"dependencies": {
"archiver": "^4.0.2",
"archiver-zip-encrypted": "^1.0.10",
"body-parser": "^1.19.0",
"cbor": "~5.2.0",
"compression": "^1.7.4",
@ -43,14 +45,24 @@
"express": "^4.17.0",
"express-handlebars": "^3.1.0",
"express-ws": "^4.0.0",
"image-size": "^1.0.0",
"ipcheck": "^0.1.0",
"loadavg-windows": "^1.1.1",
"minimist": "^1.2.0",
"mongodb": "^4.0.0",
"multiparty": "^4.2.1",
"nedb": "^1.8.0",
"node-forge": "^0.10.0",
"node-rdpjs-2": "^0.3.5",
"node-windows": "^1.0.0-beta.5",
"otplib": "^10.2.3",
"saslprep": "^1.0.3",
"ssh2": "^1.1.0",
"web-push": "^3.4.5",
"ws": "^5.2.3",
"xmldom": "^0.5.0",
"yauzl": "^2.10.0"
"yauzl": "^2.10.0",
"yubikeyotp": "^0.2.0"
},
"repository": {
"type": "git",

View File

@ -5721,6 +5721,20 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
if (obj.parent.config.firebase.relayserver) { parent.debug('email', 'Firebase-relay-handler'); obj.app.ws(url + 'firebaserelay.aspx', handleFirebaseRelayRequest); }
}
/*
// Testing code only, display a POST and return 200 OK
obj.app.post(url + 'post.aspx', function (req, res) {
var body = [];
req.on('data', function(chunk) {
body.push(chunk);
}).on('end', () => {
body = Buffer.concat(body).toString();
console.log(body);
res.sendStatus(200);
});
});
*/
// Setup auth strategies using passport if needed
if (typeof domain.authstrategies == 'object') {
const passport = domain.passport = require('passport');