add bitlocker recoverykey to sysinfo (#5671)
Signed-off-by: si458 <simonsmith5521@gmail.com>
Simon Smith committed
Jan 8, 2024 at 06:22 UTC
36741c767f549b4297889c76cd1b74e15ccefb3a
1 file changed
+20
agents/modules_meshcore/computer-identifiers.js
+20
@@ -430,6 +430,26 @@ function windows_volumes()
430
{
431
ret[key].volumeStatus = tokens[1].split('"')[1];
432
ret[key].protectionStatus = tokens[2].split('"')[1];
433
+ try {
434
+ var str = '';
435
+ var foundMarkedLine = false;
436
+ var password = '';
437
+ var child = require('child_process').execFile(process.env['windir'] + '\\system32\\cmd.exe', ['/c', 'manage-bde -protectors -get ', tokens[0].split('"')[1], ' -Type recoverypassword'], {});
438
+ child.stdout.on('data', function (chunk) { str += chunk.toString(); });
439
+ child.stderr.on('data', function (chunk) { str += chunk.toString(); });
440
+ child.waitExit();
441
+ var lines = str.split(/\r?\n/);
442
+ for (var i = 0; i < lines.length; i++) {
443
+ if (lines[i].trim() !== '' && lines[i].includes('Password:') && !lines[i].includes('Numerical Password:')) {
444
+ if (i + 1 < lines.length && lines[i + 1].trim() !== '') {
445
+ password = lines[i + 1].trim();
446
+ foundMarkedLine = true;
447
+ }
448
+ if (foundMarkedLine) break;
449
+ }
450
+ }
451
+ ret[key].recoveryPassword = (foundMarkedLine ? password : '');
452
+ } catch(ex) { }
453
}
454
}
455
this.promise._res(ret);