Fix for broken MeshCMD link.
Ylian Saint-Hilaire committed
May 20, 2021 at 15:18 UTC
066b15f80c93a528612dd51f82b3d2e88b691170
4 files changed
+6
-3
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
exeHandler.js
+2
-2
@@ -49,7 +49,7 @@ module.exports.streamExeWithJavaScript = function (options) {
49
if ((options.platform == 'win32') && (!options.peinfo)) { options.peinfo = module.exports.parseWindowsExecutable(options.sourceFileName); }
50
51
// If unsigned Windows or Linux, we merge at the end with the GUID and no padding.
52
- if ((options.platform == 'win32' && options.peinfo.CertificateTableAddress == 0) || options.platform != 'win32') {
52
+ if (((options.platform == 'win32') && (options.peinfo.CertificateTableAddress == 0)) || (options.platform != 'win32')) {
53
// This is not a signed binary, so we can just send over the EXE then the MSH
54
options.destinationStream.sourceStream = require('fs').createReadStream(options.sourceFileName, { flags: 'r' });
55
options.destinationStream.sourceStream.options = options;
@@ -64,7 +64,7 @@ module.exports.streamExeWithJavaScript = function (options) {
64
// Pipe the entire source binary without ending the stream.
65
options.destinationStream.sourceStream.pipe(options.destinationStream, { end: false });
66
} else {
67
- throw ('js content not specified');
67
+ throw ('streamExeWithJavaScript(): Cannot stream JavaScript with signed executable.');
68
}
69
};
70
webserver.js
+4
-1
@@ -4684,12 +4684,14 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
4684
res.sendFile(meshCmd64Path); return;
4685
}
4686
}
4687
+
4688
// No signed agents, we are going to merge a new MeshCmd.
4688
- if ((agentid < 10000) && (obj.parent.meshAgentBinaries[agentid + 10000] != null)) { agentid += 10000; } // Avoid merging javascript to a signed mesh agent.
4689
+ if (((agentid == 3) || (agentid == 4)) && (obj.parent.meshAgentBinaries[agentid + 10000] != null)) { agentid += 10000; } // Avoid merging javascript to a signed mesh agent.
4690
var argentInfo = obj.parent.meshAgentBinaries[agentid];
4691
if ((argentInfo == null) || (obj.parent.defaultMeshCmd == null)) { try { res.sendStatus(404); } catch (ex) { } return; }
4692
setContentDispositionHeader(res, 'application/octet-stream', 'meshcmd' + ((req.query.meshcmd <= 4) ? '.exe' : ''), null, 'meshcmd');
4693
res.statusCode = 200;
4694
+
4695
if (argentInfo.signedMeshCmdPath != null) {
4696
// If we have a pre-signed MeshCmd, send that.
4697
res.sendFile(argentInfo.signedMeshCmdPath);
@@ -4697,6 +4699,7 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
4699
// Merge JavaScript to a unsigned agent and send that.
4700
obj.parent.exeHandler.streamExeWithJavaScript({ platform: argentInfo.platform, sourceFileName: argentInfo.path, destinationStream: res, js: Buffer.from(obj.parent.defaultMeshCmd, 'utf8'), peinfo: argentInfo.pe });
4701
}
4702
+ return;
4703
} else if (req.query.meshaction != null) {
4704
if ((domain.loginkey != null) && (domain.loginkey.indexOf(req.query.key) == -1)) { try { res.sendStatus(404); } catch (ex) { } return; } // Check 3FA URL key
4705
var user = obj.users[req.session.userid];