diff --git a/agents/modules_meshcore/computer-identifiers.js b/agents/modules_meshcore/computer-identifiers.js index 68b2ef19..7a27c2c5 100644 --- a/agents/modules_meshcore/computer-identifiers.js +++ b/agents/modules_meshcore/computer-identifiers.js @@ -364,7 +364,18 @@ function linux_identifiers() child.stdout.str = ''; child.stdout.on('data', function (c) { this.str += c.toString(); }); child.stderr.on('data', function () { }); child.waitExit(); - values.linux.LastBootUpTime = child.stdout.str.trim(); + var regex = /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/; + if (regex.test(child.stdout.str.trim())) { + values.linux.LastBootUpTime = child.stdout.str.trim(); + } else { + child = require('child_process').execFile('/bin/sh', ['sh']); + child.stdout.str = ''; child.stdout.on('data', function (c) { this.str += c.toString(); }); + child.stdin.write('date -d "@$(( $(date +%s) - $(awk \'{print int($1)}\' /proc/uptime) ))" "+%Y-%m-%d %H:%M:%S"\nexit\n'); + child.waitExit(); + if (regex.test(child.stdout.str.trim())) { + values.linux.LastBootUpTime = child.stdout.str.trim(); + } + } child = null; } catch (ex) { } diff --git a/views/default-mobile.handlebars b/views/default-mobile.handlebars index e323a934..cf437ca8 100644 --- a/views/default-mobile.handlebars +++ b/views/default-mobile.handlebars @@ -6152,91 +6152,89 @@ var sections = [], s = {}; // Operating System - if ((hardware.windows && hardware.windows.osinfo) || node.osdesc) { - var x = ''; - if (node.rname) { x += addDetailItem("Name", EscapeHtml(node.rname), s); } - if (node.osdesc) { x += addDetailItem("Version", EscapeHtml(node.osdesc), s); } - if (hardware.windows && hardware.windows.osinfo) { - var m = hardware.windows.osinfo; - if (m.OSArchitecture) { - if (m.OSArchitecture.startsWith('32')) { x += addDetailItem("Architecture", "32-bit", s); } - else if (m.OSArchitecture.startsWith('64')) { x += addDetailItem("Architecture", "64-bit", s); } - else { x += addDetailItem("Architecture", EscapeHtml(m.OSArchitecture), s); } - } - if(m.LastBootUpTime){ - var thedate = { - year: parseInt(m.LastBootUpTime.substring(0, 4)), - month: parseInt(m.LastBootUpTime.substring(4, 6)) - 1, // Months are 0-based in JavaScript (0 - January, 11 - December) - day: parseInt(m.LastBootUpTime.substring(6, 8)), - hours: parseInt(m.LastBootUpTime.substring(8, 10)), - minutes: parseInt(m.LastBootUpTime.substring(10, 12)), - seconds: parseInt(m.LastBootUpTime.substring(12, 14)), - }; - const date = printDateTime(new Date(thedate.year, thedate.month, thedate.day, thedate.hours, thedate.minutes, thedate.seconds)); - x += addDetailItem("Last Boot Up Time", date); - } + var x = ''; + if (node.rname) { x += addDetailItem("Name", EscapeHtml(node.rname), s); } + if (node.osdesc) { x += addDetailItem("Version", EscapeHtml(node.osdesc), s); } + if (hardware.windows && hardware.windows.osinfo) { + var m = hardware.windows.osinfo; + if (m.OSArchitecture) { + if (m.OSArchitecture.startsWith('32')) { x += addDetailItem("Architecture", "32-bit", s); } + else if (m.OSArchitecture.startsWith('64')) { x += addDetailItem("Architecture", "64-bit", s); } + else { x += addDetailItem("Architecture", EscapeHtml(m.OSArchitecture), s); } } - if(hardware.linux && hardware.linux.LastBootUpTime){ - var lastBootUpTime = new Date(hardware.linux.LastBootUpTime); + if(m.LastBootUpTime){ var thedate = { - year: lastBootUpTime.getFullYear(), - month: lastBootUpTime.getMonth(), - day: lastBootUpTime.getDate(), - hours: lastBootUpTime.getHours(), - minutes: lastBootUpTime.getMinutes(), - seconds: lastBootUpTime.getSeconds() + year: parseInt(m.LastBootUpTime.substring(0, 4)), + month: parseInt(m.LastBootUpTime.substring(4, 6)) - 1, // Months are 0-based in JavaScript (0 - January, 11 - December) + day: parseInt(m.LastBootUpTime.substring(6, 8)), + hours: parseInt(m.LastBootUpTime.substring(8, 10)), + minutes: parseInt(m.LastBootUpTime.substring(10, 12)), + seconds: parseInt(m.LastBootUpTime.substring(12, 14)), }; const date = printDateTime(new Date(thedate.year, thedate.month, thedate.day, thedate.hours, thedate.minutes, thedate.seconds)); x += addDetailItem("Last Boot Up Time", date); } - if(hardware.darwin && hardware.darwin.LastBootUpTime){ - var lastBootUpTime = new Date(hardware.darwin.LastBootUpTime * 1000); // must times by 1000 even tho timestamp is correct? - var thedate = { - year: lastBootUpTime.getFullYear(), - month: lastBootUpTime.getMonth(), - day: lastBootUpTime.getDate(), - hours: lastBootUpTime.getHours(), - minutes: lastBootUpTime.getMinutes(), - seconds: lastBootUpTime.getSeconds() - }; - const date = printDateTime(new Date(thedate.year, thedate.month, thedate.day, thedate.hours, thedate.minutes, thedate.seconds)); - x += addDetailItem("Last Boot Up Time", date); - } - - // Windows Security Central - if (node.wsc) { - var y = []; - if (node.wsc.antiVirus != null) { if (node.wsc.antiVirus == 'OK') { y.push("AV" + ' - ' + "OK" + ''); } else { y.push("AV" + ' - ' + "BAD" + ''); } } - if (node.wsc.autoUpdate != null) { if (node.wsc.autoUpdate == 'OK') { y.push("Update" + ' - ' + "OK" + ''); } else { y.push("Update" + ' - ' + "BAD" + ''); } } - if (node.wsc.firewall != null) { if (node.wsc.firewall == 'OK') { y.push("Firewall" + ' - ' + "OK" + ''); } else { y.push("Firewall" + ' - ' + "BAD" + ''); } } - x += addDetailItem("Windows Security", y.join(', ')); - } - - // Defender for Windows Server - if(node.defender && !node.wsc) { - var y = []; - if (node.defender.RealTimeProtection != null) { if (node.defender.RealTimeProtection == true) { y.push("RealTimeProtection" + ' - ' + "On" + ''); } else { y.push("RealTimeProtection" + ' - ' + "Off" + ''); } } - if (node.defender.TamperProtected != null) { if (node.defender.TamperProtected == true) { y.push("TamperProtection" + ' - ' + "On" + ''); } else { y.push("TamperProtection" + ' - ' + "Off" + ''); } } - x += addDetailItem("Windows Defender", y.join(', ')); - } - - // Antivirus - if (node.av && node.av.length > 0) { - var y = []; - for (var i in node.av) { - if (node.av[i].product) { - var avx = EscapeHtml(node.av[i].product); - if (node.av[i].enabled !== true) { avx += ' - ' + "Disabled" + ''; } - if (node.av[i].updated !== true) { avx += ' - ' + "Out of date" + ''; } - if ((node.av[i].enabled == true) && (node.av[i].updated == true)) { avx += ' - ' + "OK" + ''; } - y.push(avx); - } - } - x += addDetailItem("Antivirus", y.join('
')); - } - - if (x != '') { sections.push({ name: "Operating System", html: x, img: 'software' }); } } + if(hardware.linux && hardware.linux.LastBootUpTime){ + var lastBootUpTime = new Date(hardware.linux.LastBootUpTime); + var thedate = { + year: lastBootUpTime.getFullYear(), + month: lastBootUpTime.getMonth(), + day: lastBootUpTime.getDate(), + hours: lastBootUpTime.getHours(), + minutes: lastBootUpTime.getMinutes(), + seconds: lastBootUpTime.getSeconds() + }; + const date = printDateTime(new Date(thedate.year, thedate.month, thedate.day, thedate.hours, thedate.minutes, thedate.seconds)); + x += addDetailItem("Last Boot Up Time", date); + } + if(hardware.darwin && hardware.darwin.LastBootUpTime){ + var lastBootUpTime = new Date(hardware.darwin.LastBootUpTime * 1000); // must times by 1000 even tho timestamp is correct? + var thedate = { + year: lastBootUpTime.getFullYear(), + month: lastBootUpTime.getMonth(), + day: lastBootUpTime.getDate(), + hours: lastBootUpTime.getHours(), + minutes: lastBootUpTime.getMinutes(), + seconds: lastBootUpTime.getSeconds() + }; + const date = printDateTime(new Date(thedate.year, thedate.month, thedate.day, thedate.hours, thedate.minutes, thedate.seconds)); + x += addDetailItem("Last Boot Up Time", date); + } + + // Windows Security Central + if (node.wsc) { + var y = []; + if (node.wsc.antiVirus != null) { if (node.wsc.antiVirus == 'OK') { y.push("AV" + ' - ' + "OK" + ''); } else { y.push("AV" + ' - ' + "BAD" + ''); } } + if (node.wsc.autoUpdate != null) { if (node.wsc.autoUpdate == 'OK') { y.push("Update" + ' - ' + "OK" + ''); } else { y.push("Update" + ' - ' + "BAD" + ''); } } + if (node.wsc.firewall != null) { if (node.wsc.firewall == 'OK') { y.push("Firewall" + ' - ' + "OK" + ''); } else { y.push("Firewall" + ' - ' + "BAD" + ''); } } + x += addDetailItem("Windows Security", y.join(', ')); + } + + // Defender for Windows Server + if(node.defender && !node.wsc) { + var y = []; + if (node.defender.RealTimeProtection != null) { if (node.defender.RealTimeProtection == true) { y.push("RealTimeProtection" + ' - ' + "On" + ''); } else { y.push("RealTimeProtection" + ' - ' + "Off" + ''); } } + if (node.defender.TamperProtected != null) { if (node.defender.TamperProtected == true) { y.push("TamperProtection" + ' - ' + "On" + ''); } else { y.push("TamperProtection" + ' - ' + "Off" + ''); } } + x += addDetailItem("Windows Defender", y.join(', ')); + } + + // Antivirus + if (node.av && node.av.length > 0) { + var y = []; + for (var i in node.av) { + if (node.av[i].product) { + var avx = EscapeHtml(node.av[i].product); + if (node.av[i].enabled !== true) { avx += ' - ' + "Disabled" + ''; } + if (node.av[i].updated !== true) { avx += ' - ' + "Out of date" + ''; } + if ((node.av[i].enabled == true) && (node.av[i].updated == true)) { avx += ' - ' + "OK" + ''; } + y.push(avx); + } + } + x += addDetailItem("Antivirus", y.join('
')); + } + + if (x != '') { sections.push({ name: "Operating System", html: x, img: 'software' }); } // MeshAgent if (node.agent) { diff --git a/views/default.handlebars b/views/default.handlebars index 7bb7dcca..d7db1ceb 100644 --- a/views/default.handlebars +++ b/views/default.handlebars @@ -12018,42 +12018,40 @@ var sections = [], s = {}; // Operating System - if ((hardware.windows && hardware.windows.osinfo) || node.osdesc) { - var x = ''; - if (node.rname) { x += addDetailItem("Name", EscapeHtml(node.rname), s); } - if (node.osdesc) { x += addDetailItem("Version", EscapeHtml(node.osdesc), s); } - if (hardware.windows && hardware.windows.osinfo) { - var m = hardware.windows.osinfo; - if (m.OSArchitecture) { - if (m.OSArchitecture.startsWith('32')) { x += addDetailItem("Architecture", "32-bit", s); } - else if (m.OSArchitecture.startsWith('64')) { x += addDetailItem("Architecture", "64-bit", s); } - else { x += addDetailItem("Architecture", EscapeHtml(m.OSArchitecture), s); } - } - if(m.LastBootUpTime){ - var thedate = { - year: parseInt(m.LastBootUpTime.substring(0, 4)), - month: parseInt(m.LastBootUpTime.substring(4, 6)) - 1, // Months are 0-based in JavaScript (0 - January, 11 - December) - day: parseInt(m.LastBootUpTime.substring(6, 8)), - hours: parseInt(m.LastBootUpTime.substring(8, 10)), - minutes: parseInt(m.LastBootUpTime.substring(10, 12)), - seconds: parseInt(m.LastBootUpTime.substring(12, 14)), - }; - const date = printDateTime(new Date(thedate.year, thedate.month, thedate.day, thedate.hours, thedate.minutes, thedate.seconds)); - x += addDetailItem("Last Boot Up Time", date); - } + var x = ''; + if (node.rname) { x += addDetailItem("Name", EscapeHtml(node.rname), s); } + if (node.osdesc) { x += addDetailItem("Version", EscapeHtml(node.osdesc), s); } + if (hardware.windows && hardware.windows.osinfo) { + var m = hardware.windows.osinfo; + if (m.OSArchitecture) { + if (m.OSArchitecture.startsWith('32')) { x += addDetailItem("Architecture", "32-bit", s); } + else if (m.OSArchitecture.startsWith('64')) { x += addDetailItem("Architecture", "64-bit", s); } + else { x += addDetailItem("Architecture", EscapeHtml(m.OSArchitecture), s); } } - if(hardware.linux && hardware.linux.LastBootUpTime){ - var lastBootUpTime = new Date(hardware.linux.LastBootUpTime); - const date = printDateTime(lastBootUpTime); + if(m.LastBootUpTime){ + var thedate = { + year: parseInt(m.LastBootUpTime.substring(0, 4)), + month: parseInt(m.LastBootUpTime.substring(4, 6)) - 1, // Months are 0-based in JavaScript (0 - January, 11 - December) + day: parseInt(m.LastBootUpTime.substring(6, 8)), + hours: parseInt(m.LastBootUpTime.substring(8, 10)), + minutes: parseInt(m.LastBootUpTime.substring(10, 12)), + seconds: parseInt(m.LastBootUpTime.substring(12, 14)), + }; + const date = printDateTime(new Date(thedate.year, thedate.month, thedate.day, thedate.hours, thedate.minutes, thedate.seconds)); x += addDetailItem("Last Boot Up Time", date); } - if(hardware.darwin && hardware.darwin.LastBootUpTime){ - var lastBootUpTime = new Date(hardware.darwin.LastBootUpTime * 1000); // must times by 1000 even tho timestamp is correct? - const date = printDateTime(lastBootUpTime); - x += addDetailItem("Last Boot Up Time", date); - } - if (x != '') { sections.push({ name: "Operating System", html: x, img: 'software64.png'}); } } + if(hardware.linux && hardware.linux.LastBootUpTime){ + var lastBootUpTime = new Date(hardware.linux.LastBootUpTime); + const date = printDateTime(lastBootUpTime); + x += addDetailItem("Last Boot Up Time", date); + } + if(hardware.darwin && hardware.darwin.LastBootUpTime){ + var lastBootUpTime = new Date(hardware.darwin.LastBootUpTime * 1000); // must times by 1000 even tho timestamp is correct? + const date = printDateTime(lastBootUpTime); + x += addDetailItem("Last Boot Up Time", date); + } + if (x != '') { sections.push({ name: "Operating System", html: x, img: 'software64.png'}); } // MeshAgent if (node.agent) {