From 40ae7f5bdd253f9bb22712913280a7a1366ed163 Mon Sep 17 00:00:00 2001 From: Bryan Roe Date: Mon, 23 Sep 2019 13:07:13 -0700 Subject: [PATCH] Updated 'openuserdesktopurl' so that on Windows, it uses the task scheduler to spawn the target into the user desktop, as opposed to just impersonating the user. --- agents/meshcore.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/agents/meshcore.js b/agents/meshcore.js index 59474080..020a8223 100644 --- a/agents/meshcore.js +++ b/agents/meshcore.js @@ -1645,8 +1645,15 @@ function createMeshCore(agent) try { switch (process.platform) { case 'win32': - //child = require('child_process').execFile(process.env['windir'] + '\\system32\\cmd.exe', ["/c", "start", url], { type: childProcess.SpawnTypes.USER, uid: require('user-sessions').Current().Active[0].SessionId }); - child = require('child_process').execFile(process.env['windir'] + '\\system32\\cmd.exe', ["/c", "start", url], { type: childProcess.SpawnTypes.USER }); + var user = require('user-sessions').getUsername(require('user-sessions').consoleUid()); + child = require('child_process').execFile(process.env['windir'] + '\\system32\\cmd.exe', ['cmd']); + child.stderr.on('data', function () { }); + child.stdout.on('data', function () { }); + child.stdin.write('SCHTASKS /CREATE /F /TN MeshChatTask /SC ONCE /ST 00:00 /RU ' + user + ' /TR "' + process.env['windir'] + '\\system32\\cmd.exe /C START ' + url + '"\r\n'); + child.stdin.write('SCHTASKS /RUN /TN MeshChatTask\r\n'); + child.stdin.write('SCHTASKS /DELETE /F /TN MeshChatTask\r\n'); + child.stdin.write('exit\r\n'); + child.waitExit(); break; case 'linux': child = require('child_process').execFile('/usr/bin/xdg-open', ['xdg-open', url], { uid: require('user-sessions').consoleUid() });