Added server side agent msh config option.

This commit is contained in:
Ylian Saint-Hilaire 2019-02-18 18:08:36 -08:00
parent eae67b9985
commit d081396d4b
5 changed files with 38 additions and 20 deletions

View File

@ -132,7 +132,9 @@ function windows_terminal() {
this._kernel32.SetConsoleWindowInfo(this._stdoutput, 1, rect); this._kernel32.SetConsoleWindowInfo(this._stdoutput, 1, rect);
} }
this.Start = function Start(CONSOLE_SCREEN_WIDTH, CONSOLE_SCREEN_HEIGHT) { this.Start = function Start(CONSOLE_SCREEN_WIDTH, CONSOLE_SCREEN_HEIGHT)
{
this.stopping = null;
if (this._kernel32.GetConsoleWindow().Val == 0) { if (this._kernel32.GetConsoleWindow().Val == 0) {
if (this._kernel32.AllocConsole().Val == 0) { if (this._kernel32.AllocConsole().Val == 0) {
throw ('AllocConsole failed with: ' + this._kernel32.GetLastError().Val); throw ('AllocConsole failed with: ' + this._kernel32.GetLastError().Val);
@ -209,10 +211,12 @@ function windows_terminal() {
this._stop = function () { this._stop = function () {
if (this.stopping) { return (this.stopping); } if (this.stopping) { return (this.stopping); }
//console.log('Stopping Terminal...'); //console.log('Stopping Terminal...');
this._ConsoleWinEventProc.removeAllListeners('GlobalCallback');
this.stopping = new promise(function (res, rej) { this._res = res; this._rej = rej; }); this.stopping = new promise(function (res, rej) { this._res = res; this._rej = rej; });
var threadID = this._kernel32.GetThreadId(this._user32.SetWinEventHook.async.thread()).Val; var threadID = this._kernel32.GetThreadId(this._user32.SetWinEventHook.async.thread()).Val;
this._user32.PostThreadMessageA(threadID, WM_QUIT, 0, 0); this._user32.PostThreadMessageA(threadID, WM_QUIT, 0, 0);
this._stream.emit('end');
return (this.stopping); return (this.stopping);
} }
@ -272,8 +276,10 @@ function windows_terminal() {
//SendConsoleEvent(dwEvent, idObject, idChild); //SendConsoleEvent(dwEvent, idObject, idChild);
break; break;
case EVENT_CONSOLE_END_APPLICATION: case EVENT_CONSOLE_END_APPLICATION:
if (idObject.Val == this.terminal._hProcessID) { if (idObject.Val == this.terminal._hProcessID)
{
//console.log('END APPLICATION: [PID: ' + idObject.Val + ' CID: ' + idChild.Val + ']'); //console.log('END APPLICATION: [PID: ' + idObject.Val + ' CID: ' + idChild.Val + ']');
this.terminal._hProcess = null;
this.terminal._stop().then(function () { console.log('STOPPED'); }); this.terminal._stop().then(function () { console.log('STOPPED'); });
} }
break; break;
@ -306,16 +312,21 @@ function windows_terminal() {
}, console.log); }, console.log);
}, console.log); }, console.log);
} }
} else { } else
{
this.nativeProxy.UnhookWinEvent.async(this.nativeProxy.terminal._user32.SetWinEventHook.async, this.nativeProxy.terminal.hwinEventHook) this.nativeProxy.UnhookWinEvent.async(this.nativeProxy.terminal._user32.SetWinEventHook.async, this.nativeProxy.terminal.hwinEventHook)
.then(function () { .then(function ()
{
if (this.nativeProxy.terminal._hProcess == null) { return; }
this.nativeProxy.terminal.stopping._res(); this.nativeProxy.terminal.stopping._res();
if (this.nativeProxy.terminal._kernel32.TerminateProcess(this.nativeProxy.terminal._hProcess, 1067).Val == 0) { if (this.nativeProxy.terminal._kernel32.TerminateProcess(this.nativeProxy.terminal._hProcess, 1067).Val == 0) {
var e = this.nativeProxy.terminal._kernel32.GetLastError().Val; var e = this.nativeProxy.terminal._kernel32.GetLastError().Val;
console.log('Unable to kill Terminal Process, error: ' + e); console.log('Unable to kill Terminal Process, error: ' + e);
} }
this.nativeProxy.terminal.stopping = null; this.nativeProxy.terminal.stopping = null;
}, function (err) { }, function (err)
{
console.log('REJECTED_UnhookWinEvent: ' + err); console.log('REJECTED_UnhookWinEvent: ' + err);
}); });
} }

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,6 @@
{ {
"name": "meshcentral", "name": "meshcentral",
"version": "0.2.8-r", "version": "0.2.8-s",
"keywords": [ "keywords": [
"Remote Management", "Remote Management",
"Intel AMT", "Intel AMT",

View File

@ -42,11 +42,14 @@
"_AgentAllowedIP": "192.168.0.100/24", "_AgentAllowedIP": "192.168.0.100/24",
"_AgentBlockedIP": "127.0.0.1,::1", "_AgentBlockedIP": "127.0.0.1,::1",
"_Limits": { "_Limits": {
"MaxUserAccounts": 100, "_MaxUserAccounts": 100,
"MaxUserSessions": 100, "_MaxUserSessions": 100,
"MaxAgentSessions": 100 "_MaxAgentSessions": 100,
"MaxSingleUserSessions": 10
}, },
"_yubikey": { "id": "0000", "secret": "xxxxxxxxxxxxxxxxxxxxx", "_proxy": "http://myproxy.domain.com:80" } "_yubikey": { "id": "0000", "secret": "xxxxxxxxxxxxxxxxxxxxx", "_proxy": "http://myproxy.domain.com:80" },
"_httpheaders": { "Strict-Transport-Security": "max-age=360000" },
"_agentConfig": [ "webSocketMaskOverride=1" ]
}, },
"customer1": { "customer1": {
"DNS": "customer1.myserver.com", "DNS": "customer1.myserver.com",
@ -62,7 +65,7 @@
} }
}, },
"_letsencrypt": { "_letsencrypt": {
"__comment__": "If your are having problems with Let's Encrypt, use https://letsdebug.net/ first to debug it.", "__comment__": "Go to https://letsdebug.net/ first before trying Let's Encrypt.",
"email": "myemail@myserver.com ", "email": "myemail@myserver.com ",
"names": "myserver.com,customer1.myserver.com", "names": "myserver.com,customer1.myserver.com",
"rsaKeySize": 3072, "rsaKeySize": 3072,

View File

@ -1927,6 +1927,8 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
if (req.query.tag != null) { meshsettings += "Tag=" + req.query.tag + "\r\n"; } if (req.query.tag != null) { meshsettings += "Tag=" + req.query.tag + "\r\n"; }
if ((req.query.installflags != null) && (req.query.installflags != 0)) { meshsettings += "InstallFlags=" + req.query.installflags + "\r\n"; } if ((req.query.installflags != null) && (req.query.installflags != 0)) { meshsettings += "InstallFlags=" + req.query.installflags + "\r\n"; }
if (domain.agentnoproxy === true) { meshsettings += "ignoreProxyFile=1\r\n"; } if (domain.agentnoproxy === true) { meshsettings += "ignoreProxyFile=1\r\n"; }
if (obj.args.agentconfig) { for (var i in obj.args.agentconfig) { meshsettings += obj.args.agentconfig[i] + "\r\n"; } }
if (domain.agentconfig) { for (var i in domain.agentconfig) { meshsettings += domain.agentconfig[i] + "\r\n"; } }
res.set({ 'Cache-Control': 'no-cache, no-store, must-revalidate', 'Pragma': 'no-cache', 'Expires': '0', 'Content-Type': 'application/octet-stream', 'Content-Disposition': 'attachment; filename=' + argentInfo.rname }); res.set({ 'Cache-Control': 'no-cache, no-store, must-revalidate', 'Pragma': 'no-cache', 'Expires': '0', 'Content-Type': 'application/octet-stream', 'Content-Disposition': 'attachment; filename=' + argentInfo.rname });
obj.parent.exeHandler.streamExeWithMeshPolicy({ platform: 'win32', sourceFileName: obj.parent.meshAgentBinaries[req.query.id].path, destinationStream: res, msh: meshsettings, peinfo: obj.parent.meshAgentBinaries[req.query.id].pe }); obj.parent.exeHandler.streamExeWithMeshPolicy({ platform: 'win32', sourceFileName: obj.parent.meshAgentBinaries[req.query.id].path, destinationStream: res, msh: meshsettings, peinfo: obj.parent.meshAgentBinaries[req.query.id].pe });
@ -2147,6 +2149,8 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
if (req.query.tag != null) { meshsettings += "Tag=" + req.query.tag + "\r\n"; } if (req.query.tag != null) { meshsettings += "Tag=" + req.query.tag + "\r\n"; }
if ((req.query.installflags != null) && (req.query.installflags != 0)) { meshsettings += "InstallFlags=" + req.query.installflags + "\r\n"; } if ((req.query.installflags != null) && (req.query.installflags != 0)) { meshsettings += "InstallFlags=" + req.query.installflags + "\r\n"; }
if (domain.agentnoproxy === true) { meshsettings += "ignoreProxyFile=1\r\n"; } if (domain.agentnoproxy === true) { meshsettings += "ignoreProxyFile=1\r\n"; }
if (obj.args.agentconfig) { for (var i in obj.args.agentconfig) { meshsettings += obj.args.agentconfig[i] + "\r\n"; } }
if (domain.agentconfig) { for (var i in domain.agentconfig) { meshsettings += domain.agentconfig[i] + "\r\n"; } }
res.set({ 'Cache-Control': 'no-cache, no-store, must-revalidate', 'Pragma': 'no-cache', 'Expires': '0', 'Content-Type': 'application/octet-stream', 'Content-Disposition': 'attachment; filename=meshagent.msh' }); res.set({ 'Cache-Control': 'no-cache, no-store, must-revalidate', 'Pragma': 'no-cache', 'Expires': '0', 'Content-Type': 'application/octet-stream', 'Content-Disposition': 'attachment; filename=meshagent.msh' });
res.send(meshsettings); res.send(meshsettings);