1
0
Fork 0
mirror of https://github.com/Ylianst/MeshCentral.git synced 2025-03-09 15:40:18 +00:00

Added chat to device support, more fixes.

This commit is contained in:
Ylian Saint-Hilaire 2018-12-07 16:36:27 -08:00
parent 443ed0cfcb
commit c7d71eb660
16 changed files with 157 additions and 68 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -436,14 +436,23 @@ function createMeshCore(agent) {
break;
}
case 'ps': {
// Return the list of running processes
if (data.sessionid) {
processManager.getProcesses(function (plist) { mesh.SendCommand({ "action": "msg", "type": "ps", "value": JSON.stringify(plist), "sessionid": data.sessionid }); });
}
break;
}
case 'pskill': {
//sendConsoleText(JSON.stringify(data));
try { process.kill(data.value); } catch (e) { sendConsoleText(JSON.stringify(e)); }
// Kill a process
if (data.value) {
try { process.kill(data.value); } catch (e) { sendConsoleText(JSON.stringify(e)); }
}
break;
}
case 'openUrl': {
// Open a local web browser and return success/fail
sendConsoleText('OpenURL: ' + data.url);
if (data.url) { mesh.SendCommand({ "action": "msg", "type":"openUrl", "url": data.url, "sessionid": data.sessionid, "success": (openUserDesktopUrl(data.url) != null) }); }
break;
}
}
@ -477,6 +486,12 @@ function createMeshCore(agent) {
if (data.title && data.msg) { require('toaster').Toast(data.title, data.msg); }
break;
}
case 'openUrl': {
// Open a local web browser and return success/fail
sendConsoleText('OpenURL: ' + data.url);
if (data.url) { mesh.SendCommand({ "action": "openUrl", "url": data.url, "sessionid": data.sessionid, "success": (openUserDesktopUrl(data.url) != null) }); }
break;
}
}
}
}
@ -964,13 +979,32 @@ function createMeshCore(agent) {
response.close = function () { sendConsoleText('httprequest.response.close', this.sessionid); consoleHttpRequest = null; }
};
// Open a web browser to a specified URL on current user's desktop
function openUserDesktopUrl(url) {
var child = null;
try {
switch (process.platform) {
case 'win32':
child = require('child_process').execFile(process.env['windir'] + '\\system32\\cmd.exe', ["/c", "start", url], { type: childProcess.SpawnTypes.USER });
break;
case 'linux':
child = require('child_process').execFile('/usr/bin/xdg-open', ['xdg-open', url], { type: require('child_process').SpawnTypes.DETACHED, uid: require('user-sessions').consoleUid() });
break;
case 'darwin':
child = require('child_process').execFile('/usr/bin/open', ['open', url], { uid: require('user-sessions').consoleUid() });
break;
}
} catch (ex) { }
return child;
}
// Process a mesh agent console command
function processConsoleCommand(cmd, args, rights, sessionid) {
try {
var response = null;
switch (cmd) {
case 'help': { // Displays available commands
response = 'Available commands: help, info, osinfo, args, print, type, dbget, dbset, dbcompact, eval, parseuri, httpget,\r\nwslist, wsconnect, wssend, wsclose, notify, ls, ps, kill, amt, netinfo, location, power, wakeonlan, scanwifi,\r\nscanamt, setdebug, smbios, rawsmbios, toast, lock, users, sendcaps.';
response = 'Available commands: help, info, osinfo,args, print, type, dbget, dbset, dbcompact, eval, parseuri, httpget,\r\nwslist, wsconnect, wssend, wsclose, notify, ls, ps, kill, amt, netinfo, location, power, wakeonlan, scanwifi,\r\nscanamt, setdebug, smbios, rawsmbios, toast, lock, users, sendcaps, openurl.';
break;
}
/*
@ -992,6 +1026,11 @@ function createMeshCore(agent) {
}
break;
*/
case 'openurl': {
if (args['_'].length != 1) { response = 'Proper usage: openurl (url)'; } // Display usage
else { if (openUserDesktopUrl(args['_'][0]) == null) { response = 'Failed.'; } else { response = 'Success.'; } }
break;
}
case 'users': {
if (meshCoreObj.users == null) { response = 'Active users are unknown.'; } else { response = 'Active Users: ' + meshCoreObj.users.join(', ') + '.'; }
break;
@ -1520,7 +1559,7 @@ function createMeshCore(agent) {
//amtLms.on('bind', function (map) { });
amtLms.on('notify', function (data, options, str, code) {
if (code == 'iAMT0052-3') {
kvmGetData();
obj.kvmGetData();
} else {
//if (str != null) { sendConsoleText('Intel AMT LMS: ' + str); }
handleAmtNotification(data);
@ -1597,7 +1636,7 @@ function createMeshCore(agent) {
});
}
obj.kvmGetData = function(tag) {
obj.kvmGetData = function (tag) {
obj.osamtstack.IPS_KVMRedirectionSettingData_DataChannelRead(obj.kvmDataGetResponse, tag);
}

View file

@ -88,8 +88,10 @@ function CreateWsmanComm(/*host, port, user, pass, tls, extra*/)
obj.digest.http = require('http');
}
var request = { protocol: (obj.tls == 1 ? 'https:' : 'http:'), method: 'POST', host: obj.host, path: '/wsman', port: obj.port, rejectUnauthorized: false, checkServerIdentity: function (cert) { console.log('checkServerIdentity', JSON.stringify(cert)); } };
var req = obj.digest.request(request);
//console.log('Request ' + (obj.RequestCount++));
req.on('error', function (e) { obj.gotNextMessagesError({ status: 600 }, 'error', null, [postdata, callback, tag]); });
req.on('response', function (response) {
//console.log('Response: ' + response.statusCode);
@ -105,6 +107,7 @@ function CreateWsmanComm(/*host, port, user, pass, tls, extra*/)
// Send POST body, this work with binary.
req.end(postdata);
obj.ActiveAjaxCount++;
return req;
}