From 8550ca648bd1c496d818adffc9516a79e1584d05 Mon Sep 17 00:00:00 2001 From: Bryan Roe Date: Mon, 6 Apr 2020 17:21:19 -0700 Subject: [PATCH] Synced with Agent Repo 1. Capped smbios to 64k 2. Removed commented out code from win-console.js 3. Updated win-terminal to check for null before pushing --- agents/modules_meshcore/smbios.js | 6 ++++ agents/modules_meshcore/win-console.js | 1 - agents/modules_meshcore/win-terminal.js | 38 ++++++++++++++----------- 3 files changed, 28 insertions(+), 17 deletions(-) diff --git a/agents/modules_meshcore/smbios.js b/agents/modules_meshcore/smbios.js index b1f5393d..ad8fa8c4 100644 --- a/agents/modules_meshcore/smbios.js +++ b/agents/modules_meshcore/smbios.js @@ -191,6 +191,12 @@ function SMBiosTables() catch(e) { } + try + { + if (JSON.stringify(r).length > 65535) { r = {}; } + } + catch(ee) + {} return r; } this.processorInfo = function processorInfo(data) { diff --git a/agents/modules_meshcore/win-console.js b/agents/modules_meshcore/win-console.js index 82d57e86..32ae289f 100644 --- a/agents/modules_meshcore/win-console.js +++ b/agents/modules_meshcore/win-console.js @@ -145,7 +145,6 @@ function WindowsConsole() this.TrayIcon.remove(); handled = true; } - //if (!handled) { console.log(msg); } } }); retVal.remove = function remove() diff --git a/agents/modules_meshcore/win-terminal.js b/agents/modules_meshcore/win-terminal.js index 29234222..592e61bc 100644 --- a/agents/modules_meshcore/win-terminal.js +++ b/agents/modules_meshcore/win-terminal.js @@ -401,7 +401,8 @@ function windows_terminal() { } } } - this._WriteCharacter = function (key, bControlKey) { + this._WriteCharacter = function (key, bControlKey) + { var rec = GM.CreateVariable(20); rec.Deref(0, 2).toBuffer().writeUInt16LE(KEY_EVENT); // rec.EventType rec.Deref(4, 4).toBuffer().writeUInt16LE(1); // rec.Event.KeyEvent.bKeyDown @@ -410,10 +411,10 @@ function windows_terminal() { rec.Deref(8, 2).toBuffer().writeUInt16LE(1); // rec.Event.KeyEvent.wRepeatCount rec.Deref(10, 2).toBuffer().writeUInt16LE(this._user32.VkKeyScanA(key).Val); // rec.Event.KeyEvent.wVirtualKeyCode rec.Deref(12, 2).toBuffer().writeUInt16LE(this._user32.MapVirtualKeyA(this._user32.VkKeyScanA(key).Val, MAPVK_VK_TO_VSC).Val); - + var dwWritten = GM.CreateVariable(4); if (this._kernel32.WriteConsoleInputA(this._stdinput, rec, 1, dwWritten).Val == 0) { return (false); } - + rec.Deref(4, 4).toBuffer().writeUInt16LE(0); // rec.Event.KeyEvent.bKeyDown return (this._kernel32.WriteConsoleInputA(this._stdinput, rec, 1, dwWritten).Val != 0); } @@ -478,23 +479,28 @@ function windows_terminal() { return (retVal); } - this._SendDataBuffer = function (data) { + this._SendDataBuffer = function (data) + { // { data, attributes, width, height, x, y } - - var dy, line, attr; - for (dy = 0; dy < data.height; ++dy) { - line = data.data[dy]; - attr = data.attributes[dy]; - line.s = line.toString(); - - //line = data.data.slice(data.width * dy, (data.width * dy) + data.width); - //attr = data.attributes.slice(data.width * dy, (data.width * dy) + data.width); - this._stream.push(TranslateLine(data.x + 1, data.y + dy + 1, line, attr)); + if (this._stream != null) + { + var dy, line, attr; + for (dy = 0; dy < data.height; ++dy) + { + line = data.data[dy]; + attr = data.attributes[dy]; + line.s = line.toString(); + + //line = data.data.slice(data.width * dy, (data.width * dy) + data.width); + //attr = data.attributes.slice(data.width * dy, (data.width * dy) + data.width); + this._stream.push(TranslateLine(data.x + 1, data.y + dy + 1, line, attr)); + } } } - this._SendScroll = function _SendScroll(dx, dy) { - if (this._scrollTimer) { return; } + this._SendScroll = function _SendScroll(dx, dy) + { + if (this._scrollTimer || this._stream == null) { return; } var info = GM.CreateVariable(22); if (this._kernel32.GetConsoleScreenBufferInfo(this._stdoutput, info).Val == 0) { throw ('Error getting screen buffer info'); }