From e5e86fee19487cab6a5fe2dde54e8f81a17b35ac Mon Sep 17 00:00:00 2001 From: Ylian Saint-Hilaire Date: Sat, 17 Feb 2024 14:01:49 -0800 Subject: [PATCH] BitLocker fixes, added drive volumes to details tab. --- agents/meshcore.js | 8 +++--- meshagent.js | 16 ++++++++--- views/default.handlebars | 58 ++++++++++++++++++++++++++-------------- 3 files changed, 55 insertions(+), 27 deletions(-) diff --git a/agents/meshcore.js b/agents/meshcore.js index 1de8c1b1..1aaadb36 100644 --- a/agents/meshcore.js +++ b/agents/meshcore.js @@ -656,14 +656,14 @@ try { require('os').name().then(function (v) { meshCoreObj.osdesc = v; meshCoreO // Get Volumes and BitLocker if Windows try { - if (process.platform == 'win32'){ - if (require('computer-identifiers').volumes_promise != null){ + if (process.platform == 'win32') { + if (require('computer-identifiers').volumes_promise != null) { var p = require('computer-identifiers').volumes_promise(); - p.then(function (res){ + p.then(function (res) { meshCoreObj.volumes = res; meshCoreObjChanged(); }); - }else if (require('computer-identifiers').volumes != null){ + } else if (require('computer-identifiers').volumes != null) { meshCoreObj.volumes = require('computer-identifiers').volumes(); meshCoreObjChanged(); } diff --git a/meshagent.js b/meshagent.js index b3ce7654..e86cac07 100644 --- a/meshagent.js +++ b/meshagent.js @@ -1941,9 +1941,19 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) { } // Volumes and BitLocker - if(command.volumes != null){ - if(!device.volumes) { device.volumes = {}; } - if (JSON.stringify(device.volumes) != JSON.stringify(command.volumes)) { /*changes.push('Volumes status');*/ device.volumes = command.volumes; change = 1; log = 1; } + if (command.volumes != null) { + for (var i in command.volumes) { + // Fix the incoming data and cut down how much data we use + const v = command.volumes[i]; + if (typeof v.size == 'string') { v.size = parseInt(v.size); } + if (v.recoveryPassword == '') { delete v.recoveryPassword; } + if (v.identifier == '') { delete v.identifier; } + if (v.name == '') { delete v.name; } + if (v.removable != true) { delete v.removable; } + if (v.protectionStatus == 'On') { v.protectionStatus = true; } else { delete v.protectionStatus; } + if (v.volumeStatus == "FullyDecrypted") { delete v.volumeStatus; } + } + if (JSON.stringify(device.volumes) != JSON.stringify(command.volumes)) { device.volumes = command.volumes; change = 1; } } // If there are changes, event the new device diff --git a/views/default.handlebars b/views/default.handlebars index 82705e9e..a22ffaef 100644 --- a/views/default.handlebars +++ b/views/default.handlebars @@ -4785,8 +4785,6 @@ if (deviceViewSettings.devsCols.indexOf('ip') >= 0) { var ip = ''; if (node.mtype == 3) { ip = node.host; } else if (node.ip) { ip = node.ip; } r += '' + ip; } // IP address if (deviceViewSettings.devsCols.indexOf('conn') >= 0) { r += '' + states.join(' + '); } // Connectivity if (deviceViewSettings.devsCols.indexOf('lastseen') >= 0) { r += ''; if (node.conn > 0) { r += "Connected"; } else if (node.lastconnect != null) { r += printDateTime(new Date(node.lastconnect)); } } - - console.log(node.intelamt); if (deviceViewSettings.devsCols.indexOf('amthost') >= 0) { r += '' + (((node.intelamt == null) || (node.intelamt.host == null)) ? '' : EscapeHtml(node.intelamt.host)); } if (deviceViewSettings.devsCols.indexOf('amtstate') >= 0) { var amtstate = ''; @@ -7453,20 +7451,20 @@ x += addDeviceAttribute("Antivirus", y.join('
')); } + /* // Volumes and Bitlocker if (node.volumes){ var bitlocker = []; for (var i in node.volumes) { if (typeof node.volumes[i].protectionStatus !== 'undefined' && node.volumes[i].protectionStatus == 'On'){ - bitlocker.push('
' + addKeyLinkConditional(i + ' - ' + node.volumes[i].volumeStatus + '',"p10showBitlockerKey('"+i+"')", (userinfo.siteadmin == 0xFFFFFFFF)) + '
'); - }else if (typeof node.volumes[i].protectionStatus !== 'undefined'){ - bitlocker.push('
' + i + ' - ' + node.volumes[i].volumeStatus + '' + '
'); + bitlocker.push('
' + addKeyLinkConditional(i + ' - ' + EscapeHtml(node.volumes[i].volumeStatus) + '', 'p10showBitlockerKey(\'' + i + '\')', (userinfo.siteadmin == 0xFFFFFFFF)) + '
'); + } else if (typeof node.volumes[i].protectionStatus !== 'undefined') { + bitlocker.push('
' + i + ' - ' + EscapeHtml(node.volumes[i].volumeStatus) + '' + '
'); } } - if(bitlocker.length > 0){ - x += addDeviceAttribute("BitLocker", bitlocker.join(' ')); - } + if (bitlocker.length > 0) { x += addDeviceAttribute("BitLocker", bitlocker.join(' ')); } } + */ // Active Users if (node.users && node.conn && (node.users.length > 0) && (node.conn & 1)) { x += addDeviceAttribute(((node.users.length > 1)?"Active Users":"Active User"), EscapeHtml(node.users.join(', '))); } @@ -7922,14 +7920,9 @@ function p10showBitlockerKey(drive) { if (xxdialogMode) return false; - var x = '
'; - x += '

BitLocker Identifier For ' + drive + ':

'; - x += '

' + (currentNode.volumes[drive].identifier ? currentNode.volumes[drive].identifier : 'Unknown') + '

'; - - x += '

BitLocker Recovery Password For ' + drive + ':

'; - x += '

' + (currentNode.volumes[drive].recoveryPassword ? currentNode.volumes[drive].recoveryPassword : 'Unknown') + '

'; - x += '
' - setDialogMode(2, "BitLocker Information", 1, null, x, ''); + var x = '

' + "Identifier" + '

' + EscapeHtml(currentNode.volumes[drive].identifier ? currentNode.volumes[drive].identifier : "Unknown") + '

'; + x += '

' + "Recovery Password" + '

' + EscapeHtml(currentNode.volumes[drive].recoveryPassword ? currentNode.volumes[drive].recoveryPassword : "Unknown") + '

'; + setDialogMode(2, EscapeHtml(drive) + ': ' + "BitLocker Information", 1, null, x, ''); } function p20editDeviceNotify() { @@ -11062,15 +11055,15 @@ const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB']; const i = parseInt(Math.floor(Math.log(Math.abs(f.s)) / Math.log(1024)), 10); const option = Q('p13sizedropdown').options[Q('p13sizedropdown').selectedIndex]; - if(Q('p13sizedropdown').value==0){ + if (Q('p13sizedropdown').value == 0) { if (f.s === 0){ fsize = 'n/a'; - }else{ + } else { fsize = (i === 0 ? `${f.s} ${sizes[i]}` : `${(f.s / (1024 ** i)).toFixed(2)} ${sizes[i]}`); } - }else if(Q('p13sizedropdown').value==1){ + } else if (Q('p13sizedropdown').value==1) { fsize = getFileSizeStr(f.s); - }else{ + } else { fsize = `${(f.s / (2 ** option.value)).toFixed(2)} ${option.title}`; } } @@ -12129,6 +12122,31 @@ if (x != '') { sections.push({ name: "Storage", html: x, img: 'storage64.png'}); } } + // Volumes and Bitlocker + if (node.volumes) { + var x = ''; + for (var i in node.volumes) { + var m = node.volumes[i]; + x += '
'; + x += '
' + i + ':' + (((m.name == null) || (m.name == '')) ? '' : (' - ' + EscapeHtml(m.name))) + '
'; + if (m.size) { + var sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB']; + var i = parseInt(Math.floor(Math.log(Math.abs(m.size)) / Math.log(1024)), 10); + var fsize = (i === 0 ? `${m.size} ${sizes[i]}` : `${(m.size / (1024 ** i)).toFixed(2)} ${sizes[i]}`); + x += addDetailItem("Capacity", EscapeHtml(fsize), s); + } + if (m.type) { x += addDetailItem("File System", (m.removable == true ? ("Removable" + ' / ') : '') + EscapeHtml(m.type), s); } + if (m.protectionStatus || m.volumeStatus) { + var bitlockerState = []; + if (m.protectionStatus) bitlockerState.push("Enabled"); + if (m.volumeStatus) bitlockerState.push(EscapeHtml(m.volumeStatus)); + x += addDetailItem("BitLocker", bitlockerState.join(' - '), s); + } + x += '
'; + } + if (x != '') { sections.push({ name: "Storage Volumes", html: '' + x + '
', img: 'storage64.png'}); } + } + // Render the sections var x = ''; for (var i in sections) {