diff --git a/agents/MeshCmd-signed.exe b/agents/MeshCmd-signed.exe index 2d70e89b..2251ec64 100644 Binary files a/agents/MeshCmd-signed.exe and b/agents/MeshCmd-signed.exe differ diff --git a/agents/MeshCmd64-signed.exe b/agents/MeshCmd64-signed.exe index f153a326..f098fc64 100644 Binary files a/agents/MeshCmd64-signed.exe and b/agents/MeshCmd64-signed.exe differ diff --git a/agents/MeshService-signed.exe b/agents/MeshService-signed.exe index 85e09fb8..b26af5a2 100644 Binary files a/agents/MeshService-signed.exe and b/agents/MeshService-signed.exe differ diff --git a/agents/MeshService.exe b/agents/MeshService.exe index 88ce82ed..a1146063 100644 Binary files a/agents/MeshService.exe and b/agents/MeshService.exe differ diff --git a/agents/MeshService64-signed.exe b/agents/MeshService64-signed.exe index 0f65b678..bfd7d1cd 100644 Binary files a/agents/MeshService64-signed.exe and b/agents/MeshService64-signed.exe differ diff --git a/agents/MeshService64.exe b/agents/MeshService64.exe index fd6ccb06..f286659b 100644 Binary files a/agents/MeshService64.exe and b/agents/MeshService64.exe differ diff --git a/agents/meshcore.js b/agents/meshcore.js index 7bde4a3f..8f3a8b34 100644 --- a/agents/meshcore.js +++ b/agents/meshcore.js @@ -438,9 +438,7 @@ function createMeshCore(agent) { } else { // List all the files and folders in this path if (reqpath == '') { reqpath = '/'; } - var xpath = obj.path.join(reqpath, '*'); - var results = null; - + var results = null, xpath = obj.path.join(reqpath, '*'); try { results = fs.readdirSync(xpath); } catch (e) { } if (results != null) { for (var i = 0; i < results.length; ++i) { @@ -530,7 +528,7 @@ function createMeshCore(agent) { function onTunnelSendOk() { sendConsoleText("Tunnel #" + this.index + " SendOK.", this.sessionid); } function onTunnelData(data) { //console.log("OnTunnelData"); - //sendConsoleText('OnTunnelData, ' + data.length + ', ' + typeof data + ', ' + data); + //sendConsoleText('OnTunnelData, ' + data.length + ', ' + typeof data + ', ' + data); // If this is upload data, save it to file if (this.httprequest.uploadFile) { diff --git a/meshagent.js b/meshagent.js index 4221ec19..86aae5e7 100644 --- a/meshagent.js +++ b/meshagent.js @@ -411,7 +411,7 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) { function processAgentData(msg) { var str = msg.toString('utf8'); if (str[0] == '{') { - try { command = JSON.parse(str) } catch (e) { console.log('Unable to parse JSON (' + obj.remoteaddr + ').'); return; } // If the command can't be parsed, ignore it. + try { command = JSON.parse(str) } catch (e) { console.log('Unable to parse agent JSON (' + obj.remoteaddr + '): ' + str); return; } // If the command can't be parsed, ignore it. switch (command.action) { case 'msg': { diff --git a/meshrelay.js b/meshrelay.js index 4550faeb..3ddcb9b6 100644 --- a/meshrelay.js +++ b/meshrelay.js @@ -182,7 +182,7 @@ module.exports.CreateMeshRelay = function (parent, ws, req, domain) { ws.on('message', function (data) { //console.log(typeof data, data.length); if (this.peer != null) { - //if (typeof data == 'string') { console.log('Relay: ' + data); } + //if (typeof data == 'string') { console.log('Relay: ' + data); } else { console.log('Relay:' + data.length + ' byte(s)'); } try { this.pause(); this.peer.send(data, ws.flushSink); } catch (e) { } } }); diff --git a/multiserver.js b/multiserver.js index f701a8c5..f3279ce8 100644 --- a/multiserver.js +++ b/multiserver.js @@ -173,7 +173,7 @@ module.exports.CreateMultiServer = function (parent, args) { function processServerData(msg) { var str = msg.toString('utf8'); if (str[0] == '{') { - try { command = JSON.parse(str) } catch (e) { obj.parent.parent.debug(1, 'Unable to parse JSON (' + obj.remoteaddr + ').'); return; } // If the command can't be parsed, ignore it. + try { command = JSON.parse(str) } catch (e) { obj.parent.parent.debug(1, 'Unable to parse server JSON (' + obj.remoteaddr + ').'); return; } // If the command can't be parsed, ignore it. if (command.action == 'info') { if (obj.authenticated != 3) { // We get the peer's serverid and database identifier. @@ -337,7 +337,7 @@ module.exports.CreateMultiServer = function (parent, args) { function processServerData(msg) { var str = msg.toString('utf8'); if (str[0] == '{') { - try { command = JSON.parse(str) } catch (e) { obj.parent.parent.debug(1, 'Unable to parse JSON (' + obj.remoteaddr + ').'); return; } // If the command can't be parsed, ignore it. + try { command = JSON.parse(str) } catch (e) { obj.parent.parent.debug(1, 'Unable to parse server JSON (' + obj.remoteaddr + ').'); return; } // If the command can't be parsed, ignore it. if (command.action == 'info') { if (obj.authenticated != 3) { // We get the peer's serverid and database identifier. diff --git a/package.json b/package.json index b1b2b913..a10341ad 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "meshcentral", - "version": "0.1.8-k", + "version": "0.1.8-l", "keywords": [ "Remote Management", "Intel AMT", diff --git a/public/scripts/agent-redir-ws-0.1.0.js b/public/scripts/agent-redir-ws-0.1.0.js index 05e1050a..ef66aa11 100644 --- a/public/scripts/agent-redir-ws-0.1.0.js +++ b/public/scripts/agent-redir-ws-0.1.0.js @@ -166,7 +166,12 @@ var CreateAgentRedirect = function (meshserver, module, serverPublicNamePort) { //console.log("xxOnSocketData", rstr2hex(data)); return obj.m.ProcessData(data); } - + + obj.sendText = function (x) { + if (typeof x != 'string') { x = JSON.stringify(x); } // Turn into a string if needed + obj.send(encode_utf8(x)); // Encode UTF8 correctly + } + obj.send = function (x) { //obj.debug("Agent Redir Send(" + obj.webRtcActive + ", " + x.length + "): " + rstr2hex(x)); //console.log("Agent Redir Send(" + obj.webRtcActive + ", " + x.length + "): " + ((typeof x == 'string')?x:rstr2hex(x))); diff --git a/public/scripts/amt-terminal-0.0.2.js b/public/scripts/amt-terminal-0.0.2.js index 797227c3..ce975fb1 100644 --- a/public/scripts/amt-terminal-0.0.2.js +++ b/public/scripts/amt-terminal-0.0.2.js @@ -35,14 +35,6 @@ var CreateAmtRemoteTerminal = function (divid) { var _tscreen = []; var _VTUNDERLINE = 1; var _VTREVERSE = 2; - // ###BEGIN###{Terminal-Enumation-All} - var _utf8accumulator = 0; - var _utf8accumulatorCount = 0; - // ###END###{Terminal-Enumation-All} - // ###BEGIN###{Terminal-Enumation-UTF8} - var _utf8accumulator = 0; - var _utf8accumulatorCount = 0; - // ###END###{Terminal-Enumation-UTF8} obj.Start = function () { } @@ -60,7 +52,15 @@ var CreateAmtRemoteTerminal = function (divid) { obj.xxStateChange = function(newstate) { } - obj.ProcessData = function (str) { if (obj.capture != null) obj.capture += str; _ProcessVt100EscString(str); obj.TermDraw(); } + obj.ProcessData = function (str) { + // ###BEGIN###{Terminal-Enumation-UTF8} + //str = decode_utf8(str); + // ###END###{Terminal-Enumation-UTF8} + // ###BEGIN###{Terminal-Enumation-All} + if (obj.terminalEmulation == 0) { str = decode_utf8(str); } + // ###END###{Terminal-Enumation-All} + if (obj.capture != null) obj.capture += str; _ProcessVt100EscString(str); obj.TermDraw(); + } function _ProcessVt100EscString(str) { for (var i = 0; i < str.length; i++) _ProcessVt100EscChar(String.fromCharCode(str.charCodeAt(i)), str.charCodeAt(i)); } @@ -363,48 +363,11 @@ var CreateAmtRemoteTerminal = function (divid) { function _ProcessVt100Char(c) { if (c == '\0' || c.charCodeAt() == 7) return; // Ignore null & bell - var ch = c.charCodeAt(); // ###BEGIN###{Terminal-Enumation-All} // UTF8 Terminal - if (obj.terminalEmulation == 0) { - // VT100 - UTF-8 emulation - var fallout = true; - if ((ch & 0x80) == 0) { - // Sub 127 char. - _utf8accumulator = ch; - _utf8accumulatorCount = 0; - fallout = false; - } - else if ((ch & 0xE0) == 0xC0) { - // 2 byte char - _utf8accumulator = (ch & 0x1F); - _utf8accumulatorCount = 1; - fallout = true; - } - else if ((ch & 0xF0) == 0xE0) { - // 3 byte char - _utf8accumulator = (ch & 0x0F); - _utf8accumulatorCount = 2; - fallout = true; - } - else if ((ch & 0xC0) == 0x80) { - if (_utf8accumulatorCount > 0) { - _utf8accumulator = (_utf8accumulator << 6); - _utf8accumulator += (ch & 0x3F); - _utf8accumulatorCount--; - fallout = (_utf8accumulatorCount != 0); - } - else { - _utf8accumulator = 0; - _utf8accumulatorCount = 0; - fallout = true; - } - } - if (fallout == true) return; - c = String.fromCharCode(_utf8accumulator); - } else if (obj.terminalEmulation == 1) { + if (obj.terminalEmulation == 1) { // ANSI - Extended ASCII emulation. if ((ch & 0x80) != 0) { c = String.fromCharCode(AsciiToUnicode[ch & 0x7F]); } } else if (obj.terminalEmulation == 2) { @@ -413,52 +376,14 @@ var CreateAmtRemoteTerminal = function (divid) { } // ###END###{Terminal-Enumation-All} - // ###BEGIN###{Terminal-Enumation-UTF8} - // VT100 - UTF-8 emulation - var fallout = true; - if ((ch & 0x80) == 0) { - // Sub 127 char. - _utf8accumulator = ch; - _utf8accumulatorCount = 0; - fallout = false; - } - else if ((ch & 0xE0) == 0xC0) { - // 2 byte char - _utf8accumulator = (ch & 0x1F); - _utf8accumulatorCount = 1; - fallout = true; - } - else if ((ch & 0xF0) == 0xE0) { - // 3 byte char - _utf8accumulator = (ch & 0x0F); - _utf8accumulatorCount = 2; - fallout = true; - } - else if ((ch & 0xC0) == 0x80) { - if (_utf8accumulatorCount > 0) { - _utf8accumulator = (_utf8accumulator << 6); - _utf8accumulator += (ch & 0x3F); - _utf8accumulatorCount--; - fallout = (_utf8accumulatorCount != 0); - } - else { - _utf8accumulator = 0; - _utf8accumulatorCount = 0; - fallout = true; - } - } - if (fallout == true) return; - c = String.fromCharCode(_utf8accumulator); - // ###END###{Terminal-Enumation-UTF8} - // ###BEGIN###{Terminal-Enumation-ASCII} // ANSI - Extended ASCII emulation. - if ((ch & 0x80) != 0) { c = String.fromCharCode(AsciiToUnicode[ch & 0x7F]); } + //if ((ch & 0x80) != 0) { c = String.fromCharCode(AsciiToUnicode[ch & 0x7F]); } // ###END###{Terminal-Enumation-ASCII} // ###BEGIN###{Terminal-Enumation-Intel} // ANSI - Intel Extended ASCII emulation. - if ((ch & 0x80) != 0) { c = String.fromCharCode(AsciiToUnicodeIntel[ch & 0x7F]); } + //if ((ch & 0x80) != 0) { c = String.fromCharCode(AsciiToUnicodeIntel[ch & 0x7F]); } // ###END###{Terminal-Enumation-Intel} //if (ch < 32 && ch != 10 && ch != 13) alert(ch); diff --git a/views/default.handlebars b/views/default.handlebars index 024d5122..23466909 100644 --- a/views/default.handlebars +++ b/views/default.handlebars @@ -2,7 +2,7 @@
- + @@ -3767,6 +3767,7 @@ terminal.onStateChanged = onTerminalStateChange; terminal.Start(terminalNode._id, 16994, '*', '*', 0); terminal.contype = 2; + Q('id_ttypebutton').value = terminalEmulations[terminal.m.terminalEmulation]; } else { // Setup a mesh agent terminal terminal = CreateAgentRedirect(meshserver, CreateAmtRemoteTerminal('Term'), serverPublicNamePort); @@ -3777,6 +3778,8 @@ terminal.onStateChanged = onTerminalStateChange; terminal.Start(terminalNode._id); terminal.contype = 1; + terminal.m.terminalEmulation = 0; + Q('id_ttypebutton').value = terminalEmulations[0]; } } else { //QH('Term', ''); @@ -3860,7 +3863,7 @@ break; case 3: p13targetpath = ''; - files.send(JSON.stringify({ action: 'ls', reqid: 1, path: '' })); + files.sendText({ action: 'ls', reqid: 1, path: '' }); break; } } @@ -3901,10 +3904,9 @@ var p13filetreelocation = []; function p13gotFiles(data) { - //console.log('p13gotFiles', data); if ((data.length > 0) && (data.charCodeAt(0) != 123)) { p13gotDownloadBinaryData(data); return; } //console.log('p13gotFiles', data); - data = JSON.parse(data); + data = JSON.parse(decode_utf8(data)); if (data.action == 'download') { p13gotDownloadCommand(data); return; } data.path = data.path.replace(/\//g, "\\"); if ((p13filetree != null) && (data.path == p13filetree.path)) { @@ -3990,13 +3992,13 @@ function p13folderset(x) { p13targetpath = joinPaths(p13filetree.path, p13filetree.dir[x].n).split('\\').join('/'); - files.send(JSON.stringify({ action: 'ls', reqid: 1, path: p13targetpath })); + files.sendText({ action: 'ls', reqid: 1, path: p13targetpath }); } function p13folderup(x) { if (x == null) { p13filetreelocation.pop(); } else { while (p13filetreelocation.length > x) { p13filetreelocation.pop(); } } p13targetpath = p13filetreelocation.join('/'); - files.send(JSON.stringify({ action: 'ls', reqid: 1, path: p13targetpath })); + files.sendText({ action: 'ls', reqid: 1, path: p13targetpath }); } var p13sortorder; @@ -4047,11 +4049,11 @@ function p13getFileCount() { var cc = 0; var checkboxes = document.getElementsByName('fd'); return checkboxes.length; } function p13selectallfile() { var nv = (p13getFileSelCount() == 0), checkboxes = document.getElementsByName('fd'); for (var i = 0; i < checkboxes.length; i++) { checkboxes[i].checked = nv; } p13setActions(); } function p13createfolder() { setDialogMode(2, "New Folder", 3, p13createfolderEx, ''); focusTextBox('p13renameinput'); p13fileNameCheck(); } - function p13createfolderEx() { files.send(JSON.stringify({ action: 'mkdir', reqid: 1, path: p13filetreelocation.join('/') + '/' + Q('p13renameinput').value })); p13folderup(999); } + function p13createfolderEx() { files.sendText({ action: 'mkdir', reqid: 1, path: p13filetreelocation.join('/') + '/' + Q('p13renameinput').value }); p13folderup(999); } function p13deletefile() { var cc = getFileSelCount(); setDialogMode(2, "Delete", 3, p13deletefileEx, (cc > 1)?('Delete ' + cc + ' selected items?'):('Delete selected item?')); } - function p13deletefileEx() { var delfiles = [], checkboxes = document.getElementsByName('fd'); for (var i = 0; i < checkboxes.length; i++) { if (checkboxes[i].checked) { delfiles.push(p13filetree.dir[checkboxes[i].value].n); } } files.send(JSON.stringify({ action: 'rm', reqid: 1, path: p13filetreelocation.join('/'), delfiles: delfiles })); p13folderup(999); } + function p13deletefileEx() { var delfiles = [], checkboxes = document.getElementsByName('fd'); for (var i = 0; i < checkboxes.length; i++) { if (checkboxes[i].checked) { delfiles.push(p13filetree.dir[checkboxes[i].value].n); } } files.sendText({ action: 'rm', reqid: 1, path: p13filetreelocation.join('/'), delfiles: delfiles }); p13folderup(999); } function p13renamefile() { var renamefile, checkboxes = document.getElementsByName('fd'); for (var i = 0; i < checkboxes.length; i++) { if (checkboxes[i].checked) { renamefile = p13filetree.dir[checkboxes[i].value].n; } } setDialogMode(2, "Rename", 3, p13renamefileEx, '', { action: 'rename', path: p13filetreelocation.join('/'), oldname: renamefile}); focusTextBox('p13renameinput'); p13fileNameCheck(); } - function p13renamefileEx(b, t) { t.newname = Q('p13renameinput').value; files.send(JSON.stringify(t)); p13folderup(999); } + function p13renamefileEx(b, t) { t.newname = Q('p13renameinput').value; files.sendText(t); p13folderup(999); } function p13fileNameCheck(e) { var x = isFilenameValid(Q('p13renameinput').value); QE('idx_dlgOkButton', x); if ((x == true) && (e != null) && (e.keyCode == 13)) { dialogclose(1); } } function p13uploadFile() { setDialogMode(2, "Upload File", 3, p13uploadFileEx, ''); updateUploadDialogOk('p13uploadinput'); } function p13uploadFileEx() { p13doUploadFiles(Q('p13uploadinput').files); } @@ -4059,7 +4061,7 @@ var p13clipboard = null, p13clipboardFolder = null, p13clipboardCut = 0; function p13copyFile(cut) { var checkboxes = document.getElementsByName('fd'); p13clipboard = []; p13clipboardCut = cut, p13clipboardFolder = p13targetpath; for (var i = 0; i < checkboxes.length; i++) { if ((checkboxes[i].checked) && (checkboxes[i].attributes.file.value == "3")) { p13clipboard.push(p13filetree.dir[checkboxes[i].value].n); } } p13updateClipview(); } function p13pasteFile() { var x = ''; if ((p13clipboard != null) && (p13clipboard.length > 0)) { x = 'Confim ' + (p13clipboardCut == 0?'copy':'move') + ' of ' + p13clipboard.length + ' entrie' + ((p13clipboard.length > 1)?'s':'') + ' to this location?' } setDialogMode(2, "Paste", 3, p13pasteFileEx, x); } - function p13pasteFileEx() { files.send(JSON.stringify({ action: (p13clipboardCut == 0?'copy':'move'), reqid: 1, scpath: p13clipboardFolder, dspath: p13targetpath, names: p13clipboard })); p13folderup(999); if (p13clipboardCut == 1) { p13clipboard = null, p13clipboardFolder = null, p13clipboardCut = 0; p13updateClipview(); } } + function p13pasteFileEx() { files.sendText({ action: (p13clipboardCut == 0?'copy':'move'), reqid: 1, scpath: p13clipboardFolder, dspath: p13targetpath, names: p13clipboard }); p13folderup(999); if (p13clipboardCut == 1) { p13clipboard = null, p13clipboardFolder = null, p13clipboardCut = 0; p13updateClipview(); } } function p13updateClipview() { var x = ''; if ((p13clipboard != null) && (p13clipboard.length > 0)) { x = 'Holding ' + p13clipboard.length + ' entrie' + ((p13clipboard.length > 1)?'s':'') + ' for ' + (p13clipboardCut == 0?'copy':'move') + ', Clear.' } QH('p13bottomstatus', x); p13setActions(); } function p13clearClip() { p13clipboard = null; p13clipboardFolder = null; p13clipboardCut = 0; p13updateClipview(); } @@ -4101,18 +4103,18 @@ if (xxdialogMode || downloadFile || !files) return; downloadFile = { path: decodeURIComponent(x), file: decodeURIComponent(y), size: z, tsize: 0, data: '', state: 0, id: Math.random() } //console.log('p13downloadFileCancel', downloadFile); - files.send(JSON.stringify({ action: 'download', sub: 'start', id: downloadFile.id, path: downloadFile.path })); + files.sendText({ action: 'download', sub: 'start', id: downloadFile.id, path: downloadFile.path }); setDialogMode(2, "Download File", 10, p13downloadFileCancel, '