Added agent filename customization.

This commit is contained in:
Ylian Saint-Hilaire 2020-12-19 17:21:42 -08:00
parent 35ab3397c5
commit 8910be58a3
4 changed files with 25 additions and 5 deletions

View File

@ -263,7 +263,8 @@
"displayName": { "type": "string", "default": "MeshCentral Agent", "description": "The name of the agent as displayed to the user." },
"description": { "type": "string", "default": "Mesh Agent background service", "description": "The description of the agent as displayed to the user." },
"companyName": { "type": "string", "default": "Mesh Agent", "description": "This will be used as the path to install the agent, by default this is 'Mesh Agent' in Windows and 'meshagent' in other OS's." },
"serviceName": { "type": "string", "default": "Mesh Agent", "description": "The name of the background service, by default this is 'Mesh Agent' in Windows and 'meshagent' in other OS's but should be set to an all lower case, no space string." }
"serviceName": { "type": "string", "default": "Mesh Agent", "description": "The name of the background service, by default this is 'Mesh Agent' in Windows and 'meshagent' in other OS's but should be set to an all lower case, no space string." },
"fileName": { "type": "string", "default": "meshagent", "description": "The agent filename." }
}
},
"userAllowedIP": { "type": "string" },

View File

@ -399,6 +399,7 @@ var CreateAgentRemoteDesktop = function (canvasid, scrolldiv) {
if (i != -1) { obj.pressedKeys.splice(i, 1); } // Remove the key press from the pressed array
}
if (obj.debugmode > 0) { console.log('Sending Key ' + kc + ', action ' + action); }
obj.send(String.fromCharCode(0x00, obj.InputType.KEY, 0x00, 0x06, (action - 1), kc));
}
}

View File

@ -184,7 +184,8 @@
"displayName": "Compagny® Product™",
"description": "Compagny® Product™ agent for remote monitoring, management and assistance.",
"companyName": "Compagny",
"serviceName": "compagnyagent"
"serviceName": "compagnyagent",
"fileName": "compagnyagent"
},
"_userAllowedIP": "127.0.0.1,192.168.1.0/24",
"_userBlockedIP": "127.0.0.1,::1,192.168.0.100",

View File

@ -4253,7 +4253,11 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
for (var i in meshsettingslines) { tokens = meshsettingslines[i].split('='); if (tokens.length == 2) { msh[tokens[0]] = tokens[1]; } }
var js = scriptInfo.data.replace('var msh = {};', 'var msh = ' + JSON.stringify(msh) + ';');
setContentDispositionHeader(res, 'application/octet-stream', 'meshagent', null, 'meshagent');
// Get the agent filename
var meshagentFilename = 'meshagent';
if ((domain.agentcustomization != null) && (typeof domain.agentcustomization.filename == 'string')) { meshagentFilename = domain.agentcustomization.filename; }
setContentDispositionHeader(res, 'application/octet-stream', meshagentFilename, null, 'meshagent');
res.statusCode = 200;
obj.parent.exeHandler.streamExeWithJavaScript({ platform: argentInfo.platform, sourceFileName: argentInfo.path, destinationStream: res, js: Buffer.from(js, 'utf8'), peinfo: argentInfo.pe });
} else if (req.query.id != null) {
@ -4274,7 +4278,10 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
}
if ((req.query.meshid == null) || (argentInfo.platform != 'win32')) {
setContentDispositionHeader(res, 'application/octet-stream', argentInfo.rname, null, 'meshagent');
// Get the agent filename
var meshagentFilename = argentInfo.rname;
if ((domain.agentcustomization != null) && (typeof domain.agentcustomization.filename == 'string')) { meshagentFilename = domain.agentcustomization.filename; }
setContentDispositionHeader(res, 'application/octet-stream', meshagentFilename, null, 'meshagent');
if (argentInfo.data == null) { res.sendFile(argentInfo.path); } else { res.end(argentInfo.data); }
} else {
// Check if the meshid is a time limited, encrypted cookie
@ -4302,6 +4309,12 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
meshfilename = meshfilename.split('\\').join('').split('/').join('').split(':').join('').split('*').join('').split('?').join('').split('"').join('').split('<').join('').split('>').join('').split('|').join('').split(' ').join('').split('\'').join('');
if (argentInfo.rname.endsWith('.exe')) { meshfilename = argentInfo.rname.substring(0, argentInfo.rname.length - 4) + '-' + meshfilename + '.exe'; } else { meshfilename = argentInfo.rname + '-' + meshfilename; }
// Customize the mesh agent file name
if ((domain.agentcustomization != null) && (typeof domain.agentcustomization.filename == 'string')) {
meshfilename = meshfilename.split('meshagent').join(domain.agentcustomization.filename);
meshfilename = meshfilename.split('MeshAgent').join(domain.agentcustomization.filename);
}
// Get the agent connection server name
var serverName = obj.getWebServerName(domain);
if (typeof obj.args.agentaliasdns == 'string') { serverName = obj.args.agentaliasdns; }
@ -4744,7 +4757,11 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
var meshsettings = getMshFromRequest(req, res, domain);
if (meshsettings == null) { res.sendStatus(401); return; }
setContentDispositionHeader(res, 'application/octet-stream', 'meshagent.msh', null, 'meshagent.msh');
// Get the agent filename
var meshagentFilename = 'meshagent';
if ((domain.agentcustomization != null) && (typeof domain.agentcustomization.filename == 'string')) { meshagentFilename = domain.agentcustomization.filename; }
setContentDispositionHeader(res, 'application/octet-stream', meshagentFilename + '.msh', null, 'meshagent.msh');
res.send(meshsettings);
};