From b887457ec4947b19d44dfb19829cddf93544fd32 Mon Sep 17 00:00:00 2001 From: Simon Smith Date: Wed, 31 Jan 2024 15:40:58 +0000 Subject: [PATCH] add bitlocker key to gui for admins (#5747) Signed-off-by: si458 --- .../modules_meshcore/computer-identifiers.js | 21 +++++++++++------- public/images/key16.png | Bin 0 -> 331 bytes views/default.handlebars | 21 +++++++++++++++--- 3 files changed, 31 insertions(+), 11 deletions(-) create mode 100644 public/images/key16.png diff --git a/agents/modules_meshcore/computer-identifiers.js b/agents/modules_meshcore/computer-identifiers.js index 0eedb33a..f55cc2b0 100644 --- a/agents/modules_meshcore/computer-identifiers.js +++ b/agents/modules_meshcore/computer-identifiers.js @@ -438,25 +438,30 @@ function windows_volumes() ret[key].volumeStatus = tokens[1].split('"')[1]; ret[key].protectionStatus = tokens[2].split('"')[1]; try { - var foundMarkedLine = false; - var password = ''; + var foundIDMarkedLine = false, foundMarkedLine = false, identifier = '', password = ''; var keychild = require('child_process').execFile(process.env['windir'] + '\\system32\\cmd.exe', ['/c', 'manage-bde -protectors -get ', tokens[0].split('"')[1], ' -Type recoverypassword'], {}); keychild.stdout.str = ''; keychild.stdout.on('data', function (c) { this.str += c.toString(); }); keychild.waitExit(); var lines = keychild.stdout.str.trim().split('\r\n'); - for (var x = 0; x < lines.length; x++) { + for (var x = 0; x < lines.length; x++) { // Loop each line var abc = lines[x].trim(); + var englishidpass = (abc !== '' && abc.includes('Numerical Password:')); // English ID + var germanidpass = (abc !== '' && abc.includes('Numerisches Kennwort:')); // German ID var englishpass = (abc !== '' && abc.includes('Password:') && !abc.includes('Numerical Password:')); // English Password var germanpass = (abc !== '' && abc.includes('Kennwort:') && !abc.includes('Numerisches Kennwort:')); // German Password - if (englishpass || germanpass) { // Numeric Password - if (x + 1 < lines.length && lines[x + 1].trim() !== '') { - password = lines[x + 1].trim(); + if (englishidpass || germanidpass || englishpass || germanpass) { + var nextline = lines[x + 1].trim(); + if (x + 1 < lines.length && (nextline !== '' && nextline.startsWith('ID:'))) { + identifier = nextline.replace('ID:','').trim(); + foundIDMarkedLine = true; + }else if (x + 1 < lines.length && nextline !== '') { + password = nextline; foundMarkedLine = true; } - if (foundMarkedLine) break; } } - ret[key].recoveryPassword = (foundMarkedLine ? password : ''); + ret[key].identifier = (foundIDMarkedLine ? identifier : ''); // Set Bitlocker Identifier + ret[key].recoveryPassword = (foundMarkedLine ? password : ''); // Set Bitlocker Password } catch(ex) { } } } diff --git a/public/images/key16.png b/public/images/key16.png new file mode 100644 index 0000000000000000000000000000000000000000..a184527f92c98b569efae9b8413c2ccfc7456afb GIT binary patch literal 331 zcmV-R0kr;!P)MTS|X69}1)Fd*%80RsbLJy3%HlBN$pgB%%Vn_a+V z5X69t;|dJ_SkD7l9~c<^F9aH-4`c^GH9cUMWul1R0Eq4VKs' + node.volumes[i].volumeStatus + ''); + 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('
' + i + ' - ' + node.volumes[i].volumeStatus + '' + '
'); } } if(bitlocker.length > 0){ - x += addDeviceAttribute("BitLocker", bitlocker.join(', ')); + x += addDeviceAttribute("BitLocker", bitlocker.join(' ')); } } @@ -7900,6 +7901,18 @@ } } + 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, ''); + } + function p20editDeviceNotify() { if (xxdialogMode) return false; var devNotify = 0, fx = ((features2 & 0x00004000) && (userinfo.emailVerified))?1:0; @@ -18683,6 +18696,8 @@ function getstore(name, val) { try { if (typeof (localStorage) === 'undefined') return val; var v = localStorage.getItem(name); if ((v == null) || (v == null)) return val; return v; } catch (e) { return val; } } function addLink(x, f) { return '' + x + ' '; } function addLinkConditional(x, f, c) { if (c) return addLink(x, f); return x; } + function addKeyLink(x, f) { return '' + x + ' '; } + function addKeyLinkConditional(x, f, c) { if (c) return addKeyLink(x, f); return x; } function haltEvent(e) { if (e.preventDefault) e.preventDefault(); if (e.stopPropagation) e.stopPropagation(); return false; } function addOption(q, t, i) { var option = document.createElement('option'); option.text = t; option.value = i; Q(q).add(option); } function passwordcheck(p) { return (p.length > 7) && (/\d/.test(p)) && (/[a-z]/.test(p)) && (/[A-Z]/.test(p)) && (/\W/.test(p)); }