add bitlocker key to gui for admins (#5747)
Signed-off-by: si458 <simonsmith5521@gmail.com>
Simon Smith committed
Jan 31, 2024 at 15:40 UTC
b887457ec4947b19d44dfb19829cddf93544fd32
3 files changed
+31
-11
agents/modules_meshcore/computer-identifiers.js
+13
-8
@@ -438,25 +438,30 @@ function windows_volumes()
438
ret[key].volumeStatus = tokens[1].split('"')[1];
439
ret[key].protectionStatus = tokens[2].split('"')[1];
440
try {
441
- var foundMarkedLine = false;
442
- var password = '';
441
+ var foundIDMarkedLine = false, foundMarkedLine = false, identifier = '', password = '';
442
var keychild = require('child_process').execFile(process.env['windir'] + '\\system32\\cmd.exe', ['/c', 'manage-bde -protectors -get ', tokens[0].split('"')[1], ' -Type recoverypassword'], {});
443
keychild.stdout.str = ''; keychild.stdout.on('data', function (c) { this.str += c.toString(); });
444
keychild.waitExit();
445
var lines = keychild.stdout.str.trim().split('\r\n');
447
- for (var x = 0; x < lines.length; x++) {
446
+ for (var x = 0; x < lines.length; x++) { // Loop each line
447
var abc = lines[x].trim();
448
+ var englishidpass = (abc !== '' && abc.includes('Numerical Password:')); // English ID
449
+ var germanidpass = (abc !== '' && abc.includes('Numerisches Kennwort:')); // German ID
450
var englishpass = (abc !== '' && abc.includes('Password:') && !abc.includes('Numerical Password:')); // English Password
451
var germanpass = (abc !== '' && abc.includes('Kennwort:') && !abc.includes('Numerisches Kennwort:')); // German Password
451
- if (englishpass || germanpass) { // Numeric Password
452
- if (x + 1 < lines.length && lines[x + 1].trim() !== '') {
453
- password = lines[x + 1].trim();
452
+ if (englishidpass || germanidpass || englishpass || germanpass) {
453
+ var nextline = lines[x + 1].trim();
454
+ if (x + 1 < lines.length && (nextline !== '' && nextline.startsWith('ID:'))) {
455
+ identifier = nextline.replace('ID:','').trim();
456
+ foundIDMarkedLine = true;
457
+ }else if (x + 1 < lines.length && nextline !== '') {
458
+ password = nextline;
459
foundMarkedLine = true;
460
}
456
- if (foundMarkedLine) break;
461
}
462
}
459
- ret[key].recoveryPassword = (foundMarkedLine ? password : '');
463
+ ret[key].identifier = (foundIDMarkedLine ? identifier : ''); // Set Bitlocker Identifier
464
+ ret[key].recoveryPassword = (foundMarkedLine ? password : ''); // Set Bitlocker Password
465
} catch(ex) { }
466
}
467
}
public/images/key16.png
Binary files /dev/null and b/public/images/key16.png differ
views/default.handlebars
+18
-3
@@ -3425,6 +3425,7 @@
3425
}
3426
if (message.event.node.av != null) { node.av = message.event.node.av; }
3427
if (message.event.node.wsc != null) { node.wsc = message.event.node.wsc; }
3428
+ if (message.event.node.volumes != null) { node.volumes = message.event.node.volumes; }
3429
node.namel = node.name.toLowerCase();
3430
if (node.rname) { node.rnamel = node.rname.toLowerCase(); } else { node.rnamel = node.namel; }
3431
if (message.event.node.icon) { node.icon = message.event.node.icon; }
@@ -7438,13 +7439,13 @@
7439
var bitlocker = [];
7440
for (var i in node.volumes) {
7441
if (typeof node.volumes[i].protectionStatus !== 'undefined' && node.volumes[i].protectionStatus == 'On'){
7441
- bitlocker.push(i + ' - <span style=color:green>' + node.volumes[i].volumeStatus + '</span>');
7442
+ bitlocker.push('<div style=margin-bottom:2px>' + addKeyLinkConditional(i + ' - <span style=color:green>' + node.volumes[i].volumeStatus + '</span>',"p10showBitlockerKey('"+i+"')", (userinfo.siteadmin == 0xFFFFFFFF)) + '</div>');
7443
}else if (typeof node.volumes[i].protectionStatus !== 'undefined'){
7443
- bitlocker.push(i + ' - <span style=color:red>' + node.volumes[i].volumeStatus + '</span>');
7444
+ bitlocker.push('<div style=margin-bottom:2px>' + i + ' - <span style=color:red>' + node.volumes[i].volumeStatus + '</span>' + '</div>');
7445
}
7446
}
7447
if(bitlocker.length > 0){
7447
- x += addDeviceAttribute("BitLocker", bitlocker.join(', '));
7448
+ x += addDeviceAttribute("BitLocker", bitlocker.join(' '));
7449
}
7450
}
7451
@@ -7900,6 +7901,18 @@
7901
}
7902
}
7903
7904
+ function p10showBitlockerKey(drive) {
7905
+ if (xxdialogMode) return false;
7906
+ var x = '<div>';
7907
+ x += '<p>BitLocker Identifier For <b>' + drive + ':</b></p>';
7908
+ x += '<p style=user-select:text;font-weight:bold>' + (currentNode.volumes[drive].identifier ? currentNode.volumes[drive].identifier : 'Unknown') + '</p>';
7909
+
7910
+ x += '<p>BitLocker Recovery Password For <b>' + drive + ':</b></p>';
7911
+ x += '<p style=user-select:text;font-weight:bold>' + (currentNode.volumes[drive].recoveryPassword ? currentNode.volumes[drive].recoveryPassword : 'Unknown') + '</p>';
7912
+ x += '</div>'
7913
+ setDialogMode(2, "BitLocker Information", 1, null, x, '');
7914
+ }
7915
+
7916
function p20editDeviceNotify() {
7917
if (xxdialogMode) return false;
7918
var devNotify = 0, fx = ((features2 & 0x00004000) && (userinfo.emailVerified))?1:0;
@@ -18683,6 +18696,8 @@
18696
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; } }
18697
function addLink(x, f) { return '<span tabindex=0 style=cursor:pointer;text-decoration:none onclick=\'' + f + '\' onkeypress="if (event.key==\'Enter\') {' + f + '} ">' + x + ' <img class=hoverButton src=images/link5.png></span>'; }
18698
function addLinkConditional(x, f, c) { if (c) return addLink(x, f); return x; }
18699
+ function addKeyLink(x, f) { return '<span tabindex=0 style=cursor:pointer;text-decoration:none onclick=' + f + ' onkeypress="if (event.key==\'Enter\') { ' + f + ' } ">' + x + ' <img class=hoverButton src=images/key16.png></span>'; }
18700
+ function addKeyLinkConditional(x, f, c) { if (c) return addKeyLink(x, f); return x; }
18701
function haltEvent(e) { if (e.preventDefault) e.preventDefault(); if (e.stopPropagation) e.stopPropagation(); return false; }
18702
function addOption(q, t, i) { var option = document.createElement('option'); option.text = t; option.value = i; Q(q).add(option); }
18703
function passwordcheck(p) { return (p.length > 7) && (/\d/.test(p)) && (/[a-z]/.test(p)) && (/[A-Z]/.test(p)) && (/\W/.test(p)); }