From 3d549dc18706e040ed8d66b62e649e9044b7e8c6 Mon Sep 17 00:00:00 2001 From: Ylian Saint-Hilaire Date: Tue, 3 May 2022 13:31:58 -0700 Subject: [PATCH] More work on RDP integration to Desktop tab. --- agents/meshcmd.js | 5 +++-- public/scripts/agent-rdp-0.0.1.js | 7 +++++-- rdp/core/type.js | 2 +- views/default.handlebars | 33 ++++++++++++++++++------------- 4 files changed, 28 insertions(+), 19 deletions(-) diff --git a/agents/meshcmd.js b/agents/meshcmd.js index 992ab63d..67fbbd11 100644 --- a/agents/meshcmd.js +++ b/agents/meshcmd.js @@ -244,6 +244,7 @@ function run(argv) { console.log('Starts MicroLMS on this computer, allowing local access to Intel AMT on TCP ports 16992 and 16993 when applicable. The command must be run on a computer with Intel AMT, must run as administrator and the Intel management driver must be installed. These certificates hashes are used by Intel AMT when performing activation into ACM mode. Example usage:\r\n\r\n meshcmd microlms'); console.log('\r\nPossible arguments:\r\n'); console.log(' --noconsole MeshCommander for LMS will no be available on port 16994.'); + console.log(' --bindany Bind to all network interfaces.'); console.log('\r\nRun as a background service:\r\n'); console.log(' microlms install/uninstall/start/stop.'); } else if (action == 'amtccm') { @@ -1586,7 +1587,7 @@ function startLms(func, lmscommander, tag) { amtMei.on('error', function (e) { console.log('startLms() error: ' + e); exit(1); return; }); //console.log("PTHI Connected."); - try { amtLms = new lme_heci({ debug: settings.lmsdebug }); } catch (ex) { if (func != null) { func(0, tag); } return; } + try { amtLms = new lme_heci({ debug: settings.lmsdebug, bindany: settings.bindany }); } catch (ex) { if (func != null) { func(0, tag); } return; } amtLms.promise = ret; amtLms.on('error', function (e) { //console.log('LME connection failed', e); @@ -1631,7 +1632,7 @@ function startLms(func, lmscommander, tag) { } }); - return (ret); + return ret; } function startMeshCommanderLms() { diff --git a/public/scripts/agent-rdp-0.0.1.js b/public/scripts/agent-rdp-0.0.1.js index cda3a53c..7558f816 100644 --- a/public/scripts/agent-rdp-0.0.1.js +++ b/public/scripts/agent-rdp-0.0.1.js @@ -118,6 +118,7 @@ var CreateRDPDesktop = function (canvasid) { obj.m.mousemove = function (e) { if (!obj.socket || (obj.State != 3)) return; var m = getMousePosition(e); + if ((m.x < 0) || (m.y < 0) || (m.x > obj.ScreenWidth) || (m.y > obj.ScreenHeight)) return; obj.mouseNagleData = ['mouse', m.x, m.y, 0, false]; if (obj.mouseNagleTimer == null) { obj.mouseNagleTimer = setTimeout(function () { obj.socket.send(JSON.stringify(obj.mouseNagleData)); obj.mouseNagleTimer = null; }, 50); } e.preventDefault(); @@ -125,16 +126,18 @@ var CreateRDPDesktop = function (canvasid) { } obj.m.mouseup = function (e) { if (!obj.socket || (obj.State != 3)) return; - if (obj.mouseNagleTimer != null) { clearTimeout(obj.mouseNagleTimer); obj.mouseNagleTimer = null; } var m = getMousePosition(e); + if ((m.x < 0) || (m.y < 0) || (m.x > obj.ScreenWidth) || (m.y > obj.ScreenHeight)) return; + if (obj.mouseNagleTimer != null) { clearTimeout(obj.mouseNagleTimer); obj.mouseNagleTimer = null; } obj.socket.send(JSON.stringify(['mouse', m.x, m.y, mouseButtonMap(e.button), false])); e.preventDefault(); return false; } obj.m.mousedown = function (e) { if (!obj.socket || (obj.State != 3)) return; - if (obj.mouseNagleTimer != null) { clearTimeout(obj.mouseNagleTimer); obj.mouseNagleTimer = null; } var m = getMousePosition(e); + if ((m.x < 0) || (m.y < 0) || (m.x > obj.ScreenWidth) || (m.y > obj.ScreenHeight)) return; + if (obj.mouseNagleTimer != null) { clearTimeout(obj.mouseNagleTimer); obj.mouseNagleTimer = null; } obj.socket.send(JSON.stringify(['mouse', m.x, m.y, mouseButtonMap(e.button), true])); e.preventDefault(); return false; diff --git a/rdp/core/type.js b/rdp/core/type.js index 5da2268e..3897ec14 100644 --- a/rdp/core/type.js +++ b/rdp/core/type.js @@ -145,7 +145,7 @@ Type.prototype.read = function(s) { if(oldValue !== this.value) { log.error('constant value mismatch ' + oldValue + ' != ' + this.value); - throw new error.ProtocolError("NODE_RDP_CORE_TYPE_CONSTANT_VALUE_MISMATCH", oldValue, this.value); + throw new error.ProtocolError("NODE_RDP_CORE_TYPE_CONSTANT_VALUE_MISMATCH, OLD:" + oldValue + ", NEW:" + this.value); } } else { diff --git a/views/default.handlebars b/views/default.handlebars index 7404d02d..ee41455a 100644 --- a/views/default.handlebars +++ b/views/default.handlebars @@ -88,10 +88,9 @@
Login Shell
- Disconnected + + + + + + Disconnected +
@@ -5778,10 +5783,6 @@ // Desktop connect button context menu if ((currentNode == null) || (currentNode.agent == null)) return true; contextelement = elem; - QV('deskConnectContextMenu1', currentNode.mtype == 2); // Ask Consent + Bar - QV('deskConnectContextMenu2', currentNode.mtype == 2); // Ask Consent - QV('deskConnectContextMenu3', currentNode.mtype == 2); // Privacy Bar - QV('deskConnectContextMenu4', (currentNode.agent.id == 3) || (currentNode.agent.id == 4)); // RDP showContextMenuDiv(document.getElementById('deskConnectContextMenu'), event.pageX, event.pageY); break; } @@ -7157,7 +7158,7 @@ // mesh.mtype: 1 = Intel AMT only, 2 = Mesh Agent, 3 = Local Device // node.agent.caps (bitmask): 1 = Desktop, 2 = Terminal, 4 = Files, 8 = Console QV('MainDevDesktop', desktopAccess && ((((node.agent == null) && (node.intelamt != null) && ((typeof node.intelamt.sku !== 'number') || ((node.intelamt.sku & 8) != 0))) - || ((node.agent != null) && ((node.agent.caps == null) || ((node.agent.caps & 1) != 0) || (node.intelamt && (node.intelamt.state == 2))))) + || ((node.agent != null) && ((node.agent.caps == null) || ((node.agent.caps & 1) != 0) || (node.intelamt && (node.intelamt.state == 2)))) || ((node.mtype == 3) && ((node.agent.id == 3) || (node.agent.id == 4)))) && ((meshrights & 8) || (meshrights & 256))) ); QV('MainDevTerminal', (((node.agent == null) && (node.intelamt != null)) || ((node.agent) && (node.agent.caps == null)) || ((node.agent) && ((node.agent.caps & 2) != 0)) || (node.intelamt && (node.intelamt.state == 2))) && (meshrights & 8) && terminalAccess); @@ -8251,6 +8252,7 @@ // Show the right buttons QV('disconnectbutton1span', (deskState != 0)); QV('connectbutton1span', (deskState == 0) && ((rights & 8) || (rights & 256)) && (currentNode.agent != null) && (currentNode.agent.caps & 1)); + QV('connectbutton1rspan', ((features & 0x40000000) == 0) && (deskState == 0) && (rights & 8) && (currentNode.agent != null) && ((currentNode.agent.id == 4) || (currentNode.agent.id == 5))); if (mtype == 1) { QV('connectbutton1hspan', (deskState == 0) && @@ -8282,6 +8284,7 @@ var inputAllowed = ((features2 & 0x2000) == 0) && ((currentNode.agent == null) || (currentNode.agent.id != 14)) && ((rights == 0xFFFFFFFF) || (((rights & 8) != 0) && ((rights & 256) == 0) && ((rights & 4096) == 0))); var online = ((currentNode.conn & 1) != 0); // If Agent (1) connected, enable remote desktop QE('connectbutton1', online); + QE('connectbutton1r', online || (currentNode.mtype == 3)); var hwonline = ((currentNode.conn & 6) != 0); // If CIRA (2) or AMT (4) connected, enable hardware terminal QE('connectbutton1h', hwonline); QV('deskFocusBtn', (desktop != null) && (desktop.contype == 2) && (deskState != 0) && (desktopsettings.showfocus)); @@ -8298,9 +8301,9 @@ QV('DeskTimer', deskState == 3); // Enable browser clipboard read if supported - QV('DeskClipboardOutButton', online && inputAllowed && ((features2 & 0x1000) == 0) && (navigator.clipboard != null) && (navigator.clipboard.readText != null) && ((desktopsettings.autoclipboard != true) || (navigator.clipboard == null) || (navigator.clipboard.readText == null))); + QV('DeskClipboardOutButton', online && inputAllowed && ((desktop == null) || (desktop.contype != 4)) && ((features2 & 0x1000) == 0) && (navigator.clipboard != null) && (navigator.clipboard.readText != null) && ((desktopsettings.autoclipboard != true) || (navigator.clipboard == null) || (navigator.clipboard.readText == null))); QV('d7deskAutoClipboardLabel', (navigator.clipboard.readText != null) && ((features2 & 0x1000) == 0)); - QV('DeskClipboardInButton', online && inputAllowed && ((features2 & 0x0800) == 0) && (navigator.clipboard != null) && (navigator.clipboard.writeText != null) && ((desktopsettings.autoclipboard != true) || (navigator.clipboard == null) || (navigator.clipboard.readText == null))); + QV('DeskClipboardInButton', online && inputAllowed && ((desktop == null) || (desktop.contype != 4)) && ((features2 & 0x0800) == 0) && (navigator.clipboard != null) && (navigator.clipboard.writeText != null) && ((desktopsettings.autoclipboard != true) || (navigator.clipboard == null) || (navigator.clipboard.readText == null))); if (deskState != 3) { QV('DeskInputLockedButton', false); @@ -8510,7 +8513,7 @@ x += addHtmlValue("Domain", ''); x += addHtmlValue("Username", ''); x += addHtmlValue("Password", ''); - x += addHtmlValue("", ''); + if ((features2 & 0x00400000) == 0) { x += addHtmlValue("", ''); } x + '
'; setDialogMode(2, "RDP Credentials", 3, askRdpCredentialsEx, x); } @@ -8525,7 +8528,9 @@ if ((currentNode.rdp == 1) && (Q('d2mode').value == 1)) { connectDesktop(null, 4, { servercred: true }); } else { - connectDesktop(null, 4, { domain: Q('d2domain').value, username: Q('d2user').value, password: Q('d2pass').value, savecred: Q('d2savecred').checked }); + savecred = false; + if ((features2 & 0x00400000) == 0) { savecred = Q('d2savecred').checked; } + connectDesktop(null, 4, { domain: Q('d2domain').value, username: Q('d2user').value, password: Q('d2pass').value, savecred: savecred }); } }