mirror of
				https://github.com/Ylianst/MeshCentral.git
				synced 2025-03-09 15:40:18 +00:00 
			
		
		
		
	Added option to allow framing.
This commit is contained in:
		
							parent
							
								
									1aa0e80f53
								
							
						
					
					
						commit
						400f853732
					
				
					 9 changed files with 42 additions and 22 deletions
				
			
		
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							| 
						 | 
					@ -64,16 +64,16 @@ function createMeshCore(agent) {
 | 
				
			||||||
    // If we are running in Duktape, agent will be null
 | 
					    // If we are running in Duktape, agent will be null
 | 
				
			||||||
    if (agent == null) {
 | 
					    if (agent == null) {
 | 
				
			||||||
        // Running in native agent, Import libraries
 | 
					        // Running in native agent, Import libraries
 | 
				
			||||||
        var db = require('SimpleDataStore').Shared();
 | 
					        db = require('SimpleDataStore').Shared();
 | 
				
			||||||
        var sha = require('SHA256Stream');
 | 
					        sha = require('SHA256Stream');
 | 
				
			||||||
        var mesh = require('MeshAgent');
 | 
					        mesh = require('MeshAgent');
 | 
				
			||||||
        var processManager = require('ILibProcessPipe');
 | 
					        processManager = require('ILibProcessPipe');
 | 
				
			||||||
        if (mesh.hasKVM == 1) { obj.meshCoreCapabilities |= 1; }
 | 
					        if (mesh.hasKVM == 1) { obj.meshCoreCapabilities |= 1; }
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
        // Running in nodejs
 | 
					        // Running in nodejs
 | 
				
			||||||
        obj.meshCoreInfo += '-NodeJS';
 | 
					        obj.meshCoreInfo += '-NodeJS';
 | 
				
			||||||
        obj.meshCoreCapabilities = 8;
 | 
					        obj.meshCoreCapabilities = 8;
 | 
				
			||||||
        var mesh = agent.getMeshApi();
 | 
					        mesh = agent.getMeshApi();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Get our location (lat/long) using our public IP address
 | 
					    // Get our location (lat/long) using our public IP address
 | 
				
			||||||
| 
						 | 
					@ -464,7 +464,9 @@ function createMeshCore(agent) {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    function onTunnelSendOk() { sendConsoleText("Tunnel #" + this.index + " SendOK.", this.sessionid); }
 | 
					    function onTunnelSendOk() { sendConsoleText("Tunnel #" + this.index + " SendOK.", this.sessionid); }
 | 
				
			||||||
    function onTunnelData(data) {
 | 
					    function onTunnelData(data) {
 | 
				
			||||||
        console.log("OnTunnelData");
 | 
					        //console.log("OnTunnelData");
 | 
				
			||||||
 | 
					        //sendConsoleText('OnTunnelData, ' +  data.length + ', ' + typeof data + ', ' + data);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // If this is upload data, save it to file
 | 
					        // If this is upload data, save it to file
 | 
				
			||||||
        if (this.httprequest.uploadFile) {
 | 
					        if (this.httprequest.uploadFile) {
 | 
				
			||||||
            try { fs.writeSync(this.httprequest.uploadFile, data); } catch (e) { this.write(JSON.stringify({ action: 'uploaderror' })); return; } // Write to the file, if there is a problem, error out.
 | 
					            try { fs.writeSync(this.httprequest.uploadFile, data); } catch (e) { this.write(JSON.stringify({ action: 'uploaderror' })); return; } // Write to the file, if there is a problem, error out.
 | 
				
			||||||
| 
						 | 
					@ -530,8 +532,8 @@ function createMeshCore(agent) {
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
                        this.httprequest.process.tunnel = this;
 | 
					                        this.httprequest.process.tunnel = this;
 | 
				
			||||||
                        this.httprequest.process.error.data = function (chunk) { this.parent.tunnel.write(chunk); }
 | 
					                        this.httprequest.process.error.data = function (chunk) { this.parent.tunnel.write(chunk); }
 | 
				
			||||||
                        this.httprequest.process.pipe(this);
 | 
					                        this.httprequest.process.pipe(this, { dataTypeSkip: 1 }); // 0 = Binary, 1 = Text.
 | 
				
			||||||
                        this.pipe(this.httprequest.process);
 | 
					                        this.pipe(this.httprequest.process, { dataTypeSkip: 1 }); // 0 = Binary, 1 = Text.
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                if (this.httprequest.protocol == 2) {
 | 
					                if (this.httprequest.protocol == 2) {
 | 
				
			||||||
| 
						 | 
					@ -555,8 +557,11 @@ function createMeshCore(agent) {
 | 
				
			||||||
                            if (this.desktop.kvm.connectionCount == 0) { this.httprequest.desktop.kvm.end(); }
 | 
					                            if (this.desktop.kvm.connectionCount == 0) { this.httprequest.desktop.kvm.end(); }
 | 
				
			||||||
                        };
 | 
					                        };
 | 
				
			||||||
                        if (this.httprequest.desktop.kvm.hasOwnProperty("connectionCount")) { this.httprequest.desktop.kvm.connectionCount++; } else { this.httprequest.desktop.kvm.connectionCount = 1; }
 | 
					                        if (this.httprequest.desktop.kvm.hasOwnProperty("connectionCount")) { this.httprequest.desktop.kvm.connectionCount++; } else { this.httprequest.desktop.kvm.connectionCount = 1; }
 | 
				
			||||||
                        this.pipe(this.httprequest.desktop.kvm);
 | 
					                        //this.write('Hello!');
 | 
				
			||||||
                        this.httprequest.desktop.kvm.pipe(this);
 | 
					                        //sendConsoleText('KVM WriteHello');
 | 
				
			||||||
 | 
					                        this.pipe(this.httprequest.desktop.kvm, { dataTypeSkip: 1 }); // 0 = Binary, 1 = Text.
 | 
				
			||||||
 | 
					                        this.httprequest.desktop.kvm.pipe(this, { dataTypeSkip: 1 }); // 0 = Binary, 1 = Text.
 | 
				
			||||||
 | 
					                        //this.on('data', function (data) { sendConsoleText('KVM: ' + data); });
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                else if (this.httprequest.protocol == 5) {
 | 
					                else if (this.httprequest.protocol == 5) {
 | 
				
			||||||
| 
						 | 
					@ -704,6 +709,7 @@ function createMeshCore(agent) {
 | 
				
			||||||
                    response += '\r\nModules: ' + JSON.stringify(addedModules) + '';
 | 
					                    response += '\r\nModules: ' + JSON.stringify(addedModules) + '';
 | 
				
			||||||
                    var oldNodeId = db.Get('OldNodeId');
 | 
					                    var oldNodeId = db.Get('OldNodeId');
 | 
				
			||||||
                    if (oldNodeId != null) { response += '\r\nOldNodeID: ' + oldNodeId + '.'; }
 | 
					                    if (oldNodeId != null) { response += '\r\nOldNodeID: ' + oldNodeId + '.'; }
 | 
				
			||||||
 | 
					                    response += '\r\ServerState: ' + meshServerConnectionState + '.';
 | 
				
			||||||
                    break;
 | 
					                    break;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                case 'selfinfo': { // Return self information block
 | 
					                case 'selfinfo': { // Return self information block
 | 
				
			||||||
| 
						 | 
					@ -1002,7 +1008,7 @@ function createMeshCore(agent) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Called periodically to check if we need to send updates to the server
 | 
					    // Called periodically to check if we need to send updates to the server
 | 
				
			||||||
    function sendPeriodicServerUpdate(force) {
 | 
					    function sendPeriodicServerUpdate(force) {
 | 
				
			||||||
        if (amtMeiConnected != 1) { // If we are pending MEI connection, hold off on updating the server on self-info
 | 
					        if ((amtMeiConnected != 1) || (force == true)) { // If we are pending MEI connection, hold off on updating the server on self-info
 | 
				
			||||||
            // Update the self information data
 | 
					            // Update the self information data
 | 
				
			||||||
            var selfInfo = buildSelfInfo(), selfInfoStr = JSON.stringify(selfInfo);
 | 
					            var selfInfo = buildSelfInfo(), selfInfoStr = JSON.stringify(selfInfo);
 | 
				
			||||||
            if ((force == true) || (selfInfoStr != lastSelfInfo)) { mesh.SendCommand(selfInfo); lastSelfInfo = selfInfoStr; }
 | 
					            if ((force == true) || (selfInfoStr != lastSelfInfo)) { mesh.SendCommand(selfInfo); lastSelfInfo = selfInfoStr; }
 | 
				
			||||||
| 
						 | 
					@ -1071,7 +1077,7 @@ function createMeshCore(agent) {
 | 
				
			||||||
        mesh.AddCommandHandler(handleServerCommand);
 | 
					        mesh.AddCommandHandler(handleServerCommand);
 | 
				
			||||||
        mesh.AddConnectHandler(handleServerConnection);
 | 
					        mesh.AddConnectHandler(handleServerConnection);
 | 
				
			||||||
        //mesh.lmsNotification = handleAmtNotification; // TODO
 | 
					        //mesh.lmsNotification = handleAmtNotification; // TODO
 | 
				
			||||||
        sendPeriodicServerUpdate(); // TODO: Check if connected before sending
 | 
					        sendPeriodicServerUpdate(true); // TODO: Check if connected before sending
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // Parse input arguments
 | 
					        // Parse input arguments
 | 
				
			||||||
        //var args = parseArgs(process.argv);
 | 
					        //var args = parseArgs(process.argv);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -180,7 +180,7 @@ module.exports.CreateMeshRelay = function (parent, ws, req, domain) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // When data is received from the mesh relay web socket
 | 
					    // When data is received from the mesh relay web socket
 | 
				
			||||||
    ws.on('message', function (data) {
 | 
					    ws.on('message', function (data) {
 | 
				
			||||||
        //console.log(typeof data);
 | 
					        //console.log(typeof data, data.length);
 | 
				
			||||||
        //if (typeof data == 'string') console.log(data);
 | 
					        //if (typeof data == 'string') console.log(data);
 | 
				
			||||||
        if (this.peer != null) { try { this.pause(); this.peer.send(data, ws.flushSink); } catch (e) { } }
 | 
					        if (this.peer != null) { try { this.pause(); this.peer.send(data, ws.flushSink); } catch (e) { } }
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,6 +1,6 @@
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  "name": "meshcentral",
 | 
					  "name": "meshcentral",
 | 
				
			||||||
  "version": "0.1.1-f",
 | 
					  "version": "0.1.1-h",
 | 
				
			||||||
  "keywords": [
 | 
					  "keywords": [
 | 
				
			||||||
    "Remote Management",
 | 
					    "Remote Management",
 | 
				
			||||||
    "Intel AMT",
 | 
					    "Intel AMT",
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -47,6 +47,8 @@ var CreateAgentRedirect = function (meshserver, module, serverPublicNamePort) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Called to pass websocket control messages
 | 
					    // Called to pass websocket control messages
 | 
				
			||||||
    obj.xxOnControlCommand = function (msg) {
 | 
					    obj.xxOnControlCommand = function (msg) {
 | 
				
			||||||
 | 
					        //console.log(msg);
 | 
				
			||||||
 | 
					        //obj.socket.send('hellobob');
 | 
				
			||||||
        var controlMsg = JSON.parse(msg);
 | 
					        var controlMsg = JSON.parse(msg);
 | 
				
			||||||
        if ((controlMsg.type == 'answer') && (obj.webrtc != null)) {
 | 
					        if ((controlMsg.type == 'answer') && (obj.webrtc != null)) {
 | 
				
			||||||
            console.log('gotAnswer', JSON.stringify(controlMsg));
 | 
					            console.log('gotAnswer', JSON.stringify(controlMsg));
 | 
				
			||||||
| 
						 | 
					@ -106,8 +108,7 @@ var CreateAgentRedirect = function (meshserver, module, serverPublicNamePort) {
 | 
				
			||||||
        if (typeof e.data == 'string') {
 | 
					        if (typeof e.data == 'string') {
 | 
				
			||||||
            // Control messages, most likely WebRTC setup 
 | 
					            // Control messages, most likely WebRTC setup 
 | 
				
			||||||
            obj.xxOnControlCommand(e.data);
 | 
					            obj.xxOnControlCommand(e.data);
 | 
				
			||||||
        }
 | 
					        } else if (typeof e.data == 'object') {
 | 
				
			||||||
        if (typeof e.data == 'object') {
 | 
					 | 
				
			||||||
            var f = new FileReader();
 | 
					            var f = new FileReader();
 | 
				
			||||||
            if (f.readAsBinaryString) {
 | 
					            if (f.readAsBinaryString) {
 | 
				
			||||||
                // Chrome & Firefox (Draft)
 | 
					                // Chrome & Firefox (Draft)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -636,10 +636,12 @@
 | 
				
			||||||
        var clickOnce = detectClickOnce();
 | 
					        var clickOnce = detectClickOnce();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        function startup() {
 | 
					        function startup() {
 | 
				
			||||||
            // Guard against other site's top frames (web bugs).
 | 
					            if ((features & 32) == 0) {
 | 
				
			||||||
            var loc = null;
 | 
					                // Guard against other site's top frames (web bugs).
 | 
				
			||||||
            try { loc = top.location.toString().toLowerCase(); } catch (e) { }
 | 
					                var loc = null;
 | 
				
			||||||
            if (top != self && (loc == null || top.active == false)) { top.location = self.location; return; }
 | 
					                try { loc = top.location.toString().toLowerCase(); } catch (e) { }
 | 
				
			||||||
 | 
					                if (top != self && (loc == null || top.active == false)) { top.location = self.location; return; }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            // Check if we are in debug mode
 | 
					            // Check if we are in debug mode
 | 
				
			||||||
            args = parseUriArgs();
 | 
					            args = parseUriArgs();
 | 
				
			||||||
| 
						 | 
					@ -754,7 +756,7 @@
 | 
				
			||||||
                hideContextMenu(); // Hide the context menu if present
 | 
					                hideContextMenu(); // Hide the context menu if present
 | 
				
			||||||
                QV('verifyEmailId2', false);
 | 
					                QV('verifyEmailId2', false);
 | 
				
			||||||
                QV('logoutControl', false);
 | 
					                QV('logoutControl', false);
 | 
				
			||||||
                serverPoll();
 | 
					                setTimeout(serverPoll, 5000);
 | 
				
			||||||
            } else if (state == 2) {
 | 
					            } else if (state == 2) {
 | 
				
			||||||
                // Fetch list of meshes, nodes, files
 | 
					                // Fetch list of meshes, nodes, files
 | 
				
			||||||
                meshserver.Send({ action: 'meshes' });
 | 
					                meshserver.Send({ action: 'meshes' });
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -169,8 +169,16 @@
 | 
				
			||||||
        var passhint = "{{{passhint}}}";
 | 
					        var passhint = "{{{passhint}}}";
 | 
				
			||||||
        var newAccountPass = {{{newAccountPass}}};
 | 
					        var newAccountPass = {{{newAccountPass}}};
 | 
				
			||||||
        var emailCheck = {{{emailcheck}}};
 | 
					        var emailCheck = {{{emailcheck}}};
 | 
				
			||||||
 | 
					        var features = {{{features}}};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        function startup() {
 | 
					        function startup() {
 | 
				
			||||||
 | 
					            if ((features & 32) == 0) {
 | 
				
			||||||
 | 
					                // Guard against other site's top frames (web bugs).
 | 
				
			||||||
 | 
					                var loc = null;
 | 
				
			||||||
 | 
					                try { loc = top.location.toString().toLowerCase(); } catch (e) { }
 | 
				
			||||||
 | 
					                if (top != self && (loc == null || top.active == false)) { top.location = self.location; return; }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            window.onresize = center;
 | 
					            window.onresize = center;
 | 
				
			||||||
            center();
 | 
					            center();
 | 
				
			||||||
            validateLogin();
 | 
					            validateLogin();
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -613,13 +613,16 @@ module.exports.CreateWebServer = function (parent, db, args, secret, certificate
 | 
				
			||||||
            if (obj.args.nousers == true) { features += 4; } // Single user mode
 | 
					            if (obj.args.nousers == true) { features += 4; } // Single user mode
 | 
				
			||||||
            if (domain.userQuota == -1) { features += 8; } // No server files mode
 | 
					            if (domain.userQuota == -1) { features += 8; } // No server files mode
 | 
				
			||||||
            if (obj.args.tlsoffload == true) { features += 16; } // No mutual-auth CIRA
 | 
					            if (obj.args.tlsoffload == true) { features += 16; } // No mutual-auth CIRA
 | 
				
			||||||
 | 
					            if (parent.config.settings.allowFraming == true) { features += 32; } // Allow site within iframe
 | 
				
			||||||
            if ((!obj.args.user) && (obj.args.nousers != true)) { logoutcontrol += ' <a href=' + domain.url + 'logout?' + Math.random() + ' style=color:white>Logout</a>'; } // If a default user is in use or no user mode, don't display the logout button
 | 
					            if ((!obj.args.user) && (obj.args.nousers != true)) { logoutcontrol += ' <a href=' + domain.url + 'logout?' + Math.random() + ' style=color:white>Logout</a>'; } // If a default user is in use or no user mode, don't display the logout button
 | 
				
			||||||
            res.render(obj.path.join(__dirname, 'views/default'), { viewmode: viewmode, currentNode: currentNode, logoutControl: logoutcontrol, title: domain.title, title2: domain.title2, domainurl: domain.url, domain: domain.id, debuglevel: parent.debugLevel, serverDnsName: obj.certificates.CommonName, serverRedirPort: args.redirport, serverPublicPort: args.port, noServerBackup: (args.noserverbackup == 1 ? 1 : 0), features: features, mpspass: args.mpspass, webcerthash: obj.webCertificateHashBase64 });
 | 
					            res.render(obj.path.join(__dirname, 'views/default'), { viewmode: viewmode, currentNode: currentNode, logoutControl: logoutcontrol, title: domain.title, title2: domain.title2, domainurl: domain.url, domain: domain.id, debuglevel: parent.debugLevel, serverDnsName: obj.certificates.CommonName, serverRedirPort: args.redirport, serverPublicPort: args.port, noServerBackup: (args.noserverbackup == 1 ? 1 : 0), features: features, mpspass: args.mpspass, webcerthash: obj.webCertificateHashBase64 });
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            // Send back the login application
 | 
					            // Send back the login application
 | 
				
			||||||
            var loginmode = req.session.loginmode;
 | 
					            var loginmode = req.session.loginmode;
 | 
				
			||||||
            delete req.session.loginmode; // Clear this state, if the user hits refresh, we want to go back to the login page.
 | 
					            delete req.session.loginmode; // Clear this state, if the user hits refresh, we want to go back to the login page.
 | 
				
			||||||
            res.render(obj.path.join(__dirname, 'views/login'), { loginmode: loginmode, rootCertLink: getRootCertLink(), title: domain.title, title2: domain.title2, newAccount: domain.newaccounts, newAccountPass: (((domain.newaccountspass == null) || (domain.newaccountspass == '')) ? 0 : 1), serverDnsName: obj.certificates.CommonName, serverPublicPort: obj.args.port, emailcheck: obj.parent.mailserver != null });
 | 
					            var features = 0;
 | 
				
			||||||
 | 
					            if (parent.config.settings.allowFraming == true) { features += 32; } // Allow site within iframe
 | 
				
			||||||
 | 
					            res.render(obj.path.join(__dirname, 'views/login'), { loginmode: loginmode, rootCertLink: getRootCertLink(), title: domain.title, title2: domain.title2, newAccount: domain.newaccounts, newAccountPass: (((domain.newaccountspass == null) || (domain.newaccountspass == '')) ? 0 : 1), serverDnsName: obj.certificates.CommonName, serverPublicPort: obj.args.port, emailcheck: obj.parent.mailserver != null, features: features });
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue