mirror of
				https://github.com/Ylianst/MeshCentral.git
				synced 2025-03-09 15:40:18 +00:00 
			
		
		
		
	Merge branch 'master' of https://github.com/Ylianst/MeshCentral
This commit is contained in:
		
						commit
						4d55780ec3
					
				
					 5 changed files with 11 additions and 13 deletions
				
			
		
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							| 
						 | 
					@ -25,7 +25,6 @@ limitations under the License.
 | 
				
			||||||
//console.displayStreamPipeMessages = 1; // Display stream pipe and un-pipes
 | 
					//console.displayStreamPipeMessages = 1; // Display stream pipe and un-pipes
 | 
				
			||||||
//var __gc = setInterval(function () { console.log('GC'); _debugGC() }, 2000); //
 | 
					//var __gc = setInterval(function () { console.log('GC'); _debugGC() }, 2000); //
 | 
				
			||||||
 | 
					
 | 
				
			||||||
setModulePath('modules_meshcmd');
 | 
					 | 
				
			||||||
var fs = require('fs');
 | 
					var fs = require('fs');
 | 
				
			||||||
var os = require('os');
 | 
					var os = require('os');
 | 
				
			||||||
var net = require('net');
 | 
					var net = require('net');
 | 
				
			||||||
| 
						 | 
					@ -213,7 +212,7 @@ function run(argv) {
 | 
				
			||||||
        console.log('  AmtWake           - Intel AMT Wake Alarms.');
 | 
					        console.log('  AmtWake           - Intel AMT Wake Alarms.');
 | 
				
			||||||
        console.log('  AmtRPE            - Intel AMT Remote Platform Erase.');
 | 
					        console.log('  AmtRPE            - Intel AMT Remote Platform Erase.');
 | 
				
			||||||
        console.log('  AmtDDNS           - Intel AMT DDNS settings.');
 | 
					        console.log('  AmtDDNS           - Intel AMT DDNS settings.');
 | 
				
			||||||
        console.log('  AmtTerm           - Intel AMT Serial-over-LAN terminal.');
 | 
					        if (console.canonical != null) { console.log('  AmtTerm           - Intel AMT Serial-over-LAN terminal.'); }
 | 
				
			||||||
        console.log('\r\nHelp on a specific action using:\r\n');
 | 
					        console.log('\r\nHelp on a specific action using:\r\n');
 | 
				
			||||||
        console.log('  meshcmd help [action]');
 | 
					        console.log('  meshcmd help [action]');
 | 
				
			||||||
        exit(0); return;
 | 
					        exit(0); return;
 | 
				
			||||||
| 
						 | 
					@ -442,7 +441,7 @@ function run(argv) {
 | 
				
			||||||
            console.log('  --set [disabled/dhcp/enabled]    Set the dynamic DNS mode.');
 | 
					            console.log('  --set [disabled/dhcp/enabled]    Set the dynamic DNS mode.');
 | 
				
			||||||
            console.log('  --interval [minutes]             Set update interval in minutes, default is 1440, minimum is 20.');
 | 
					            console.log('  --interval [minutes]             Set update interval in minutes, default is 1440, minimum is 20.');
 | 
				
			||||||
            console.log('  --ttl [seconds]                  Set time to live, default is 900.');
 | 
					            console.log('  --ttl [seconds]                  Set time to live, default is 900.');
 | 
				
			||||||
        } else if (action == 'amtterm') {
 | 
					        } else if ((action == 'amtterm') && (console.canonical != null)) {
 | 
				
			||||||
            console.log('AmtTerm is used to connect to the Serial-over-LAN port. Example usage:\r\n\r\n  meshcmd amtterm --host 1.2.3.4 --user admin --pass mypassword');
 | 
					            console.log('AmtTerm is used to connect to the Serial-over-LAN port. Example usage:\r\n\r\n  meshcmd amtterm --host 1.2.3.4 --user admin --pass mypassword');
 | 
				
			||||||
            console.log('\r\nRequired arguments:\r\n');
 | 
					            console.log('\r\nRequired arguments:\r\n');
 | 
				
			||||||
            console.log('  --host [hostname]                The IP address or DNS name of Intel AMT, 127.0.0.1 is default.');
 | 
					            console.log('  --host [hostname]                The IP address or DNS name of Intel AMT, 127.0.0.1 is default.');
 | 
				
			||||||
| 
						 | 
					@ -837,7 +836,7 @@ function run(argv) {
 | 
				
			||||||
        if ((settings.password == null) || (typeof settings.password != 'string') || (settings.password == '')) { console.log('No or invalid \"password\" specified, use --password [password].'); exit(1); return; }
 | 
					        if ((settings.password == null) || (typeof settings.password != 'string') || (settings.password == '')) { console.log('No or invalid \"password\" specified, use --password [password].'); exit(1); return; }
 | 
				
			||||||
        if ((settings.username == null) || (typeof settings.username != 'string') || (settings.username == '')) { settings.username = 'admin'; }
 | 
					        if ((settings.username == null) || (typeof settings.username != 'string') || (settings.username == '')) { settings.username = 'admin'; }
 | 
				
			||||||
        performAmtFeatureConfig(args);
 | 
					        performAmtFeatureConfig(args);
 | 
				
			||||||
    } else if (settings.action == 'amtterm') {
 | 
					    } else if ((settings.action == 'amtterm') && (console.canonical != null)) {
 | 
				
			||||||
        if (settings.hostname == null) { settings.hostname = '127.0.0.1'; }
 | 
					        if (settings.hostname == null) { settings.hostname = '127.0.0.1'; }
 | 
				
			||||||
        if ((settings.password == null) || (typeof settings.password != 'string') || (settings.password == '')) { console.log('No or invalid \"password\" specified, use --password [password].'); exit(1); return; }
 | 
					        if ((settings.password == null) || (typeof settings.password != 'string') || (settings.password == '')) { console.log('No or invalid \"password\" specified, use --password [password].'); exit(1); return; }
 | 
				
			||||||
        if ((settings.username == null) || (typeof settings.username != 'string') || (settings.username == '')) { settings.username = 'admin'; }
 | 
					        if ((settings.username == null) || (typeof settings.username != 'string') || (settings.username == '')) { settings.username = 'admin'; }
 | 
				
			||||||
| 
						 | 
					@ -3000,7 +2999,6 @@ function ShortToStrX(v) { return String.fromCharCode(v & 0xFF, (v >> 8) & 0xFF);
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
 | 
					
 | 
				
			||||||
var sol = null;
 | 
					var sol = null;
 | 
				
			||||||
var solTimer = null;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Called to start serial-over-lan terminal
 | 
					// Called to start serial-over-lan terminal
 | 
				
			||||||
function performAmtTerm(args) {
 | 
					function performAmtTerm(args) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -836,7 +836,7 @@ module.exports.CreateMstscRelay = function (parent, db, ws, req, args, domain) {
 | 
				
			||||||
            rdpClient = require('./rdp').createClient(args).on('connect', function () {
 | 
					            rdpClient = require('./rdp').createClient(args).on('connect', function () {
 | 
				
			||||||
                send(['rdp-connect']);
 | 
					                send(['rdp-connect']);
 | 
				
			||||||
                if ((typeof obj.infos.options == 'object') && (obj.infos.options.savepass == true)) { saveRdpCredentials(); } // Save the credentials if needed
 | 
					                if ((typeof obj.infos.options == 'object') && (obj.infos.options.savepass == true)) { saveRdpCredentials(); } // Save the credentials if needed
 | 
				
			||||||
                obj.sessionid = Buffer.from(parent.crypto.randomBytes(9), 'binary').toString('base64');
 | 
					                obj.sessionid = Buffer.from(parent.crypto.randomBytes(9), 'binary').toString('base64').replace(/\+/g, '@').replace(/\//g, '$');
 | 
				
			||||||
                obj.startTime = Date.now();
 | 
					                obj.startTime = Date.now();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                // Event session start
 | 
					                // Event session start
 | 
				
			||||||
| 
						 | 
					@ -1173,7 +1173,7 @@ module.exports.CreateSshRelay = function (parent, db, ws, req, args, domain) {
 | 
				
			||||||
                        obj.sshClient.on('ready', function () { // Authentication was successful.
 | 
					                        obj.sshClient.on('ready', function () { // Authentication was successful.
 | 
				
			||||||
                            // If requested, save the credentials
 | 
					                            // If requested, save the credentials
 | 
				
			||||||
                            saveSshCredentials(obj.keep);
 | 
					                            saveSshCredentials(obj.keep);
 | 
				
			||||||
                            obj.sessionid = Buffer.from(parent.crypto.randomBytes(9), 'binary').toString('base64');
 | 
					                            obj.sessionid = Buffer.from(parent.crypto.randomBytes(9), 'binary').toString('base64').replace(/\+/g, '@').replace(/\//g, '$');
 | 
				
			||||||
                            obj.startTime = Date.now();
 | 
					                            obj.startTime = Date.now();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                            // Event start of session
 | 
					                            // Event start of session
 | 
				
			||||||
| 
						 | 
					@ -1512,7 +1512,7 @@ module.exports.CreateSshTerminalRelay = function (parent, db, ws, req, domain, u
 | 
				
			||||||
                        obj.sshClient.on('ready', function () { // Authentication was successful.
 | 
					                        obj.sshClient.on('ready', function () { // Authentication was successful.
 | 
				
			||||||
                            // If requested, save the credentials
 | 
					                            // If requested, save the credentials
 | 
				
			||||||
                            saveSshCredentials(obj.keep);
 | 
					                            saveSshCredentials(obj.keep);
 | 
				
			||||||
                            obj.sessionid = Buffer.from(parent.crypto.randomBytes(9), 'binary').toString('base64');
 | 
					                            obj.sessionid = Buffer.from(parent.crypto.randomBytes(9), 'binary').toString('base64').replace(/\+/g, '@').replace(/\//g, '$');
 | 
				
			||||||
                            obj.startTime = Date.now();
 | 
					                            obj.startTime = Date.now();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                            try {
 | 
					                            try {
 | 
				
			||||||
| 
						 | 
					@ -1866,7 +1866,7 @@ module.exports.CreateSshFilesRelay = function (parent, db, ws, req, domain, user
 | 
				
			||||||
                        obj.sshClient.on('ready', function () { // Authentication was successful.
 | 
					                        obj.sshClient.on('ready', function () { // Authentication was successful.
 | 
				
			||||||
                            // If requested, save the credentials
 | 
					                            // If requested, save the credentials
 | 
				
			||||||
                            saveSshCredentials(obj.keep);
 | 
					                            saveSshCredentials(obj.keep);
 | 
				
			||||||
                            obj.sessionid = Buffer.from(parent.crypto.randomBytes(9), 'binary').toString('base64');
 | 
					                            obj.sessionid = Buffer.from(parent.crypto.randomBytes(9), 'binary').toString('base64').replace(/\+/g, '@').replace(/\//g, '$');
 | 
				
			||||||
                            obj.startTime = Date.now();
 | 
					                            obj.startTime = Date.now();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                            // Event start of session
 | 
					                            // Event start of session
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -879,7 +879,7 @@ function CreateMeshRelayEx(parent, ws, req, domain, user, cookie) {
 | 
				
			||||||
                const rcookieData = {};
 | 
					                const rcookieData = {};
 | 
				
			||||||
                if (user != null) { rcookieData.ruserid = user._id; } else if (obj.nouser === true) { rcookieData.nouser = 1; }
 | 
					                if (user != null) { rcookieData.ruserid = user._id; } else if (obj.nouser === true) { rcookieData.nouser = 1; }
 | 
				
			||||||
                const rcookie = parent.parent.encodeCookie(rcookieData, parent.parent.loginCookieEncryptionKey);
 | 
					                const rcookie = parent.parent.encodeCookie(rcookieData, parent.parent.loginCookieEncryptionKey);
 | 
				
			||||||
                if (obj.id == null) { obj.id = parent.crypto.randomBytes(9).toString('base64'); } // If there is no connection id, generate one.
 | 
					                if (obj.id == null) { obj.id = parent.crypto.randomBytes(9).toString('base64').replace(/\+/g, '@').replace(/\//g, '$'); } // If there is no connection id, generate one.
 | 
				
			||||||
                const command = { nodeid: cookie.nodeid, action: 'msg', type: 'tunnel', value: '*/' + xdomain + 'meshrelay.ashx?id=' + obj.id + '&rauth=' + rcookie, tcpport: cookie.tcpport, tcpaddr: cookie.tcpaddr, soptions: {} };
 | 
					                const command = { nodeid: cookie.nodeid, action: 'msg', type: 'tunnel', value: '*/' + xdomain + 'meshrelay.ashx?id=' + obj.id + '&rauth=' + rcookie, tcpport: cookie.tcpport, tcpaddr: cookie.tcpaddr, soptions: {} };
 | 
				
			||||||
                if (user) { command.userid = user._id; }
 | 
					                if (user) { command.userid = user._id; }
 | 
				
			||||||
                if (typeof domain.consentmessages == 'object') {
 | 
					                if (typeof domain.consentmessages == 'object') {
 | 
				
			||||||
| 
						 | 
					@ -915,7 +915,7 @@ function CreateMeshRelayEx(parent, ws, req, domain, user, cookie) {
 | 
				
			||||||
                obj.meshid = node.meshid;
 | 
					                obj.meshid = node.meshid;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                // Send connection request to agent
 | 
					                // Send connection request to agent
 | 
				
			||||||
                if (obj.id == null) { obj.id = parent.crypto.randomBytes(9).toString('base64'); } // If there is no connection id, generate one.
 | 
					                if (obj.id == null) { obj.id = parent.crypto.randomBytes(9).toString('base64').replace(/\+/g, '@').replace(/\//g, '$'); } // If there is no connection id, generate one.
 | 
				
			||||||
                const rcookie = parent.parent.encodeCookie({ ruserid: user._id }, parent.parent.loginCookieEncryptionKey);
 | 
					                const rcookie = parent.parent.encodeCookie({ ruserid: user._id }, parent.parent.loginCookieEncryptionKey);
 | 
				
			||||||
                if (obj.req.query.tcpport != null) {
 | 
					                if (obj.req.query.tcpport != null) {
 | 
				
			||||||
                    const command = { nodeid: obj.req.query.nodeid, action: 'msg', type: 'tunnel', userid: user._id, value: '*/' + xdomain + 'meshrelay.ashx?id=' + obj.id + '&rauth=' + rcookie, tcpport: obj.req.query.tcpport, tcpaddr: ((obj.req.query.tcpaddr == null) ? '127.0.0.1' : obj.req.query.tcpaddr), soptions: {} };
 | 
					                    const command = { nodeid: obj.req.query.nodeid, action: 'msg', type: 'tunnel', userid: user._id, value: '*/' + xdomain + 'meshrelay.ashx?id=' + obj.id + '&rauth=' + rcookie, tcpport: obj.req.query.tcpport, tcpaddr: ((obj.req.query.tcpaddr == null) ? '127.0.0.1' : obj.req.query.tcpaddr), soptions: {} };
 | 
				
			||||||
| 
						 | 
					@ -971,7 +971,7 @@ function CreateMeshRelayEx(parent, ws, req, domain, user, cookie) {
 | 
				
			||||||
                obj.meshid = node.meshid;
 | 
					                obj.meshid = node.meshid;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                // Send connection request to agent
 | 
					                // Send connection request to agent
 | 
				
			||||||
                if (obj.id == null) { obj.id = parent.crypto.randomBytes(9).toString('base64'); } // If there is no connection id, generate one.
 | 
					                if (obj.id == null) { obj.id = parent.crypto.randomBytes(9).toString('base64').replace(/\+/g, '@').replace(/\//g, '$'); } // If there is no connection id, generate one.
 | 
				
			||||||
                const rcookieData = { nodeid: node._id };
 | 
					                const rcookieData = { nodeid: node._id };
 | 
				
			||||||
                if (user != null) { rcookieData.ruserid = user._id; } else if (obj.nouser === true) { rcookieData.nouser = 1; }
 | 
					                if (user != null) { rcookieData.ruserid = user._id; } else if (obj.nouser === true) { rcookieData.nouser = 1; }
 | 
				
			||||||
                const rcookie = parent.parent.encodeCookie(rcookieData, parent.parent.loginCookieEncryptionKey);
 | 
					                const rcookie = parent.parent.encodeCookie(rcookieData, parent.parent.loginCookieEncryptionKey);
 | 
				
			||||||
| 
						 | 
					@ -1117,7 +1117,7 @@ module.exports.CreateLocalRelay = function (parent, ws, req, domain, user, cooki
 | 
				
			||||||
function CreateLocalRelayEx(parent, ws, req, domain, user, cookie) {
 | 
					function CreateLocalRelayEx(parent, ws, req, domain, user, cookie) {
 | 
				
			||||||
    const net = require('net');
 | 
					    const net = require('net');
 | 
				
			||||||
    var obj = {};
 | 
					    var obj = {};
 | 
				
			||||||
    obj.id = parent.crypto.randomBytes(9).toString('base64');
 | 
					    obj.id = parent.crypto.randomBytes(9).toString('base64').replace(/\+/g, '@').replace(/\//g, '$');
 | 
				
			||||||
    obj.req = req;
 | 
					    obj.req = req;
 | 
				
			||||||
    obj.ws = ws;
 | 
					    obj.ws = ws;
 | 
				
			||||||
    obj.user = user;
 | 
					    obj.user = user;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue