add tpm support (#5421)
* add tpm support Signed-off-by: Simon Smith <simonsmith5521@gmail.com> * fix tpm semicolon mistake Signed-off-by: Simon Smith <simonsmith5521@gmail.com> --------- Signed-off-by: Simon Smith <simonsmith5521@gmail.com>
Simon Smith committed
Nov 4, 2023 at 18:44 UTC
7b016eac586dd0628eee0608821b0224ecce302d
5 files changed
+50
agents/meshcore.js
+26
@@ -1844,6 +1844,22 @@ function getSystemInformation(func) {
1844
}
1845
} catch (ex) { results.hardware.identifiers['bios_mode'] = 'Legacy'; }
1846
}
1847
+ if (!results.hardware.tpm) {
1848
+ IntToStr = function (v) { return String.fromCharCode((v >> 24) & 0xFF, (v >> 16) & 0xFF, (v >> 8) & 0xFF, v & 0xFF); };
1849
+ try {
1850
+ var values = require('win-wmi').query('ROOT\\CIMV2\\Security\\MicrosoftTpm', "SELECT * FROM Win32_Tpm", ['IsActivated_InitialValue','IsEnabled_InitialValue','IsOwned_InitialValue','ManufacturerId','ManufacturerVersion','SpecVersion']);
1851
+ if(values[0]) {
1852
+ results.hardware.tpm = {
1853
+ SpecVersion: values[0].SpecVersion.split(",")[0],
1854
+ ManufacturerId: IntToStr(values[0].ManufacturerId).replace(/[^\x00-\x7F]/g, ""),
1855
+ ManufacturerVersion: values[0].ManufacturerVersion,
1856
+ IsActivated: values[0].IsActivated_InitialValue,
1857
+ IsEnabled: values[0].IsEnabled_InitialValue,
1858
+ IsOwned: values[0].IsOwned_InitialValue,
1859
+ }
1860
+ }
1861
+ } catch (ex) { }
1862
+ }
1863
}
1864
if(results.hardware && results.hardware.linux) {
1865
if (!results.hardware.identifiers['bios_serial']) {
@@ -1856,6 +1872,16 @@ function getSystemInformation(func) {
1872
results.hardware.identifiers['bios_mode'] = (require('fs').statSync('/sys/firmware/efi').isDirectory() ? 'UEFI': 'Legacy');
1873
} catch (ex) { results.hardware.identifiers['bios_mode'] = 'Legacy'; }
1874
}
1875
+ if (!results.hardware.tpm) {
1876
+ IntToStr = function (v) { return String.fromCharCode((v >> 24) & 0xFF, (v >> 16) & 0xFF, (v >> 8) & 0xFF, v & 0xFF); };
1877
+ try {
1878
+ if (require('fs').statSync('/sys/class/tpm/tpm0').isDirectory()){
1879
+ results.hardware.tpm = {
1880
+ SpecVersion: require('fs').readFileSync('/sys/class/tpm/tpm0/tpm_version_major').toString().trim()
1881
+ }
1882
+ }
1883
+ } catch (ex) { }
1884
+ }
1885
}
1886
results.hardware.agentvers = process.versions;
1887
replaceSpacesWithUnderscoresRec(results);
public/images/details/tpm32.png
Binary files /dev/null and b/public/images/details/tpm32.png differ
public/images/details/tpm64.png
Binary files /dev/null and b/public/images/details/tpm64.png differ
views/default-mobile.handlebars
+12
@@ -6016,6 +6016,18 @@
6016
if (x != '') { sections.push({ name: "Motherboard", html: x, img: 'motherboard' }); }
6017
}
6018
6019
+ // TPM
6020
+ if (hardware.tpm) {
6021
+ var x = '', tpm = hardware.tpm;
6022
+ if (tpm.SpecVersion) { x += addDetailItem("SpecVersion", parseFloat(EscapeHtml(tpm.SpecVersion)).toFixed(1), s); }
6023
+ if (tpm.ManufacturerId) { x += addDetailItem("ManufacturerId", EscapeHtml(tpm.ManufacturerId), s); }
6024
+ if (tpm.ManufacturerVersion) { x += addDetailItem("ManufacturerVersion", EscapeHtml(tpm.ManufacturerVersion), s); }
6025
+ if (tpm.IsActivated != null) { x += addDetailItem("IsActivated", EscapeHtml(tpm.IsActivated), s); }
6026
+ if (tpm.IsEnabled != null) { x += addDetailItem("IsEnabled", EscapeHtml(tpm.IsEnabled), s); }
6027
+ if (tpm.IsOwned != null) { x += addDetailItem("IsOwned", EscapeHtml(tpm.IsOwned), s); }
6028
+ if (x != '') { sections.push({ name: "TPM", html: x, img: 'tpm'}); }
6029
+ }
6030
+
6031
if (hardware.windows) {
6032
if (hardware.windows.memory && (hardware.windows.memory.length > 0)) {
6033
var x = '';
views/default.handlebars
+12
@@ -11759,6 +11759,18 @@
11759
if (x != '') { sections.push({ name: "Motherboard", html: x, img: 'motherboard64.png'}); }
11760
}
11761
11762
+ // TPM
11763
+ if (hardware.tpm) {
11764
+ var x = '', tpm = hardware.tpm;
11765
+ if (tpm.SpecVersion) { x += addDetailItem("SpecVersion", parseFloat(EscapeHtml(tpm.SpecVersion)).toFixed(1), s); }
11766
+ if (tpm.ManufacturerId) { x += addDetailItem("ManufacturerId", EscapeHtml(tpm.ManufacturerId), s); }
11767
+ if (tpm.ManufacturerVersion) { x += addDetailItem("ManufacturerVersion", EscapeHtml(tpm.ManufacturerVersion), s); }
11768
+ if (tpm.IsActivated != null) { x += addDetailItem("IsActivated", EscapeHtml(tpm.IsActivated), s); }
11769
+ if (tpm.IsEnabled != null) { x += addDetailItem("IsEnabled", EscapeHtml(tpm.IsEnabled), s); }
11770
+ if (tpm.IsOwned != null) { x += addDetailItem("IsOwned", EscapeHtml(tpm.IsOwned), s); }
11771
+ if (x != '') { sections.push({ name: "TPM", html: x, img: 'tpm64.png'}); }
11772
+ }
11773
+
11774
if (hardware.windows) {
11775
if (hardware.windows.memory && (hardware.windows.memory.length > 0)) {
11776
var x = '';