mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2025-03-09 15:40:18 +00:00
Published as v0.3.9-w
This commit is contained in:
parent
616005883d
commit
ff97603fb4
5 changed files with 96 additions and 56 deletions
53
agents/meshcore.min.js
vendored
53
agents/meshcore.min.js
vendored
|
@ -1042,7 +1042,7 @@ function createMeshCore(agent)
|
|||
|
||||
if (this.httprequest.state == 0) {
|
||||
// Check if this is a relay connection
|
||||
if (data == 'c') { this.httprequest.state = 1; /*sendConsoleText("Tunnel #" + this.httprequest.index + " now active", this.httprequest.sessionid);*/ }
|
||||
if ((data == 'c') || (data == 'cr')) { this.httprequest.state = 1; /*sendConsoleText("Tunnel #" + this.httprequest.index + " now active", this.httprequest.sessionid);*/ }
|
||||
} else {
|
||||
// Handle tunnel data
|
||||
if (this.httprequest.protocol == 0) { // 1 = Terminal, 2 = Desktop, 5 = Files, 6 = PowerShell
|
||||
|
@ -1059,41 +1059,61 @@ function createMeshCore(agent)
|
|||
return;
|
||||
}
|
||||
|
||||
this.end = function () {
|
||||
if (process.platform == "win32") {
|
||||
this.end = function ()
|
||||
{
|
||||
if (process.platform == "win32")
|
||||
{
|
||||
// Unpipe the web socket
|
||||
this.unpipe(this.httprequest._term);
|
||||
this.httprequest._term.unpipe(this);
|
||||
if (this.httprequest._term) { this.httprequest._term.unpipe(this); }
|
||||
|
||||
// Unpipe the WebRTC channel if needed (This will also be done when the WebRTC channel ends).
|
||||
if (this.rtcchannel) {
|
||||
if (this.rtcchannel)
|
||||
{
|
||||
this.rtcchannel.unpipe(this.httprequest._term);
|
||||
this.httprequest._term.unpipe(this.rtcchannel);
|
||||
if (this.httprequest._term) { this.httprequest._term.unpipe(this.rtcchannel); }
|
||||
}
|
||||
|
||||
// Clean up
|
||||
this.httprequest._term.end();
|
||||
if (this.httprequest._term) { this.httprequest._term.end(); }
|
||||
this.httprequest._term = null;
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
// TODO!!
|
||||
}
|
||||
};
|
||||
|
||||
// Remote terminal using native pipes
|
||||
if (process.platform == "win32") {
|
||||
if ((this.httprequest.protocol == 6) && (require('win-terminal').PowerShellCapable() == true)) {
|
||||
this.httprequest._term = require('win-terminal').StartPowerShell(80, 25);
|
||||
} else {
|
||||
this.httprequest._term = require('win-terminal').Start(80, 25);
|
||||
if (process.platform == "win32")
|
||||
{
|
||||
try
|
||||
{
|
||||
if ((this.httprequest.protocol == 6) && (require('win-terminal').PowerShellCapable() == true))
|
||||
{
|
||||
this.httprequest._term = require('win-terminal').StartPowerShell(80, 25);
|
||||
} else
|
||||
{
|
||||
this.httprequest._term = require('win-terminal').Start(80, 25);
|
||||
}
|
||||
}
|
||||
catch(e)
|
||||
{
|
||||
MeshServerLog('Failed to start remote terminal session, ' + e.toString() + ' (' + this.httprequest.remoteaddr + ')', this.httprequest);
|
||||
this.write(JSON.stringify({ ctrlChannel: '102938', type: 'console', msg: e.toString() }));
|
||||
this.end();
|
||||
return;
|
||||
}
|
||||
this.httprequest._term.pipe(this, { dataTypeSkip: 1 });
|
||||
this.pipe(this.httprequest._term, { dataTypeSkip: 1, end: false });
|
||||
this.prependListener('end', function () { this.httprequest._term.end(function () { console.log('Terminal was closed'); }); });
|
||||
} else {
|
||||
if (fs.existsSync("/bin/bash")) {
|
||||
} else
|
||||
{
|
||||
if (fs.existsSync("/bin/bash"))
|
||||
{
|
||||
this.httprequest.process = childProcess.execFile("/bin/bash", ["bash", "-i"], { type: childProcess.SpawnTypes.TERM });
|
||||
if (process.platform == 'linux') { this.httprequest.process.stdin.write("alias ls='ls --color=auto'\nclear\n"); }
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
this.httprequest.process = childProcess.execFile("/bin/sh", ["sh"], { type: childProcess.SpawnTypes.TERM });
|
||||
if (process.platform == 'linux') { this.httprequest.process.stdin.write("stty erase ^H\nalias ls='ls --color=auto'\nPS1='\\u@\\h:\\w\\$ '\nclear\n"); }
|
||||
}
|
||||
|
@ -1296,7 +1316,6 @@ function createMeshCore(agent)
|
|||
} else if (this.httprequest.protocol == 1) {
|
||||
// Send data into terminal stdin
|
||||
//this.write(data); // Echo back the keys (Does not seem to be a good idea)
|
||||
this.httprequest.process.write(data);
|
||||
} else if (this.httprequest.protocol == 2) {
|
||||
// Send data into remote desktop
|
||||
if (this.httprequest.desktop.state == 0) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue