add bitlocker key to gui for admins (#5747)

Signed-off-by: si458 <simonsmith5521@gmail.com>
This commit is contained in:
Simon Smith 2024-01-31 15:40:58 +00:00 committed by GitHub
parent 4648dbeb26
commit b887457ec4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 31 additions and 11 deletions

View File

@ -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) { }
}
}

BIN
public/images/key16.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 331 B

View File

@ -3425,6 +3425,7 @@
}
if (message.event.node.av != null) { node.av = message.event.node.av; }
if (message.event.node.wsc != null) { node.wsc = message.event.node.wsc; }
if (message.event.node.volumes != null) { node.volumes = message.event.node.volumes; }
node.namel = node.name.toLowerCase();
if (node.rname) { node.rnamel = node.rname.toLowerCase(); } else { node.rnamel = node.namel; }
if (message.event.node.icon) { node.icon = message.event.node.icon; }
@ -7438,13 +7439,13 @@
var bitlocker = [];
for (var i in node.volumes) {
if (typeof node.volumes[i].protectionStatus !== 'undefined' && node.volumes[i].protectionStatus == 'On'){
bitlocker.push(i + ' - <span style=color:green>' + node.volumes[i].volumeStatus + '</span>');
bitlocker.push('<div style=margin-bottom:2px>' + addKeyLinkConditional(i + ' - <span style=color:green>' + node.volumes[i].volumeStatus + '</span>',"p10showBitlockerKey('"+i+"')", (userinfo.siteadmin == 0xFFFFFFFF)) + '</div>');
}else if (typeof node.volumes[i].protectionStatus !== 'undefined'){
bitlocker.push(i + ' - <span style=color:red>' + node.volumes[i].volumeStatus + '</span>');
bitlocker.push('<div style=margin-bottom:2px>' + i + ' - <span style=color:red>' + node.volumes[i].volumeStatus + '</span>' + '</div>');
}
}
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 = '<div>';
x += '<p>BitLocker Identifier For <b>' + drive + ':</b></p>';
x += '<p style=user-select:text;font-weight:bold>' + (currentNode.volumes[drive].identifier ? currentNode.volumes[drive].identifier : 'Unknown') + '</p>';
x += '<p>BitLocker Recovery Password For <b>' + drive + ':</b></p>';
x += '<p style=user-select:text;font-weight:bold>' + (currentNode.volumes[drive].recoveryPassword ? currentNode.volumes[drive].recoveryPassword : 'Unknown') + '</p>';
x += '</div>'
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 '<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>'; }
function addLinkConditional(x, f, c) { if (c) return addLink(x, f); return x; }
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>'; }
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)); }