From 1c47f13090460072a27af3e7df39e04703499693 Mon Sep 17 00:00:00 2001 From: Ylian Saint-Hilaire Date: Mon, 22 Mar 2021 19:00:50 -0700 Subject: [PATCH] More work on Intel AMT Click Once Recovery. --- meshuser.js | 26 ++++++++++++++++++++++++-- webserver.js | 5 ++++- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/meshuser.js b/meshuser.js index 5d5a2f1e..bbb1e83c 100644 --- a/meshuser.js +++ b/meshuser.js @@ -5492,8 +5492,30 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use } break; } - case 'clickoncerecovery': { - console.log(command); // TODO + case 'clickoncerecovery': { // Intel(R) AMT Click once recovery + if (common.validateStrArray(command.nodeids, 1) == false) break; // Check nodeids + if (common.validateString(command.path, 1, 2048) == false) break; // Check file path + if (command.type != 'diskimage') break; // Make sure type is correct + + var file = parent.getServerFilePath(user, domain, command.path); + if (file == null) return; + + // For each nodeid, change the group + for (var i = 0; i < command.nodeids.length; i++) { + var xnodeid = command.nodeids[i]; + if (xnodeid.indexOf('/') == -1) { xnodeid = 'node/' + domain.id + '/' + xnodeid; } + + // Get the node and the rights for this node + parent.GetNodeWithRights(domain, user, xnodeid, function (node, rights, visible) { + // Check if we found this device and if we have full rights + if ((node == null) || (rights != 0xFFFFFFFF)) return; + + // Perform Intel AMT Click Once Recovery + console.log('ClickOnceRecovery', node._id, file.fullpath); + }); + } + + //console.log(command, file); break; } default: { diff --git a/webserver.js b/webserver.js index 3e507381..df288eb1 100644 --- a/webserver.js +++ b/webserver.js @@ -3438,7 +3438,10 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) { if ((node == null) || (rights != 0xFFFFFFFF) || (visible == false)) { res.sendStatus(404); return; } // We don't have remote control rights to this device for (var i in files.files) { var file = files.files[i]; - console.log('ClickOnceRecovery', file); // TODO + + // Perform Intel AMT Click Once Recovery + console.log('ClickOnceRecovery', node._id, file.path); + try { obj.fs.unlinkSync(file.path); } catch (e) { } } res.send('');