From 7b016eac586dd0628eee0608821b0224ecce302d Mon Sep 17 00:00:00 2001 From: Simon Smith Date: Sat, 4 Nov 2023 18:44:34 +0000 Subject: [PATCH] add tpm support (#5421) * add tpm support Signed-off-by: Simon Smith * fix tpm semicolon mistake Signed-off-by: Simon Smith --------- Signed-off-by: Simon Smith --- agents/meshcore.js | 26 ++++++++++++++++++++++++++ public/images/details/tpm32.png | Bin 0 -> 1296 bytes public/images/details/tpm64.png | Bin 0 -> 3160 bytes views/default-mobile.handlebars | 12 ++++++++++++ views/default.handlebars | 12 ++++++++++++ 5 files changed, 50 insertions(+) create mode 100644 public/images/details/tpm32.png create mode 100644 public/images/details/tpm64.png diff --git a/agents/meshcore.js b/agents/meshcore.js index d8e62c6c..ff83392d 100644 --- a/agents/meshcore.js +++ b/agents/meshcore.js @@ -1844,6 +1844,22 @@ function getSystemInformation(func) { } } catch (ex) { results.hardware.identifiers['bios_mode'] = 'Legacy'; } } + if (!results.hardware.tpm) { + IntToStr = function (v) { return String.fromCharCode((v >> 24) & 0xFF, (v >> 16) & 0xFF, (v >> 8) & 0xFF, v & 0xFF); }; + try { + var values = require('win-wmi').query('ROOT\\CIMV2\\Security\\MicrosoftTpm', "SELECT * FROM Win32_Tpm", ['IsActivated_InitialValue','IsEnabled_InitialValue','IsOwned_InitialValue','ManufacturerId','ManufacturerVersion','SpecVersion']); + if(values[0]) { + results.hardware.tpm = { + SpecVersion: values[0].SpecVersion.split(",")[0], + ManufacturerId: IntToStr(values[0].ManufacturerId).replace(/[^\x00-\x7F]/g, ""), + ManufacturerVersion: values[0].ManufacturerVersion, + IsActivated: values[0].IsActivated_InitialValue, + IsEnabled: values[0].IsEnabled_InitialValue, + IsOwned: values[0].IsOwned_InitialValue, + } + } + } catch (ex) { } + } } if(results.hardware && results.hardware.linux) { if (!results.hardware.identifiers['bios_serial']) { @@ -1856,6 +1872,16 @@ function getSystemInformation(func) { results.hardware.identifiers['bios_mode'] = (require('fs').statSync('/sys/firmware/efi').isDirectory() ? 'UEFI': 'Legacy'); } catch (ex) { results.hardware.identifiers['bios_mode'] = 'Legacy'; } } + if (!results.hardware.tpm) { + IntToStr = function (v) { return String.fromCharCode((v >> 24) & 0xFF, (v >> 16) & 0xFF, (v >> 8) & 0xFF, v & 0xFF); }; + try { + if (require('fs').statSync('/sys/class/tpm/tpm0').isDirectory()){ + results.hardware.tpm = { + SpecVersion: require('fs').readFileSync('/sys/class/tpm/tpm0/tpm_version_major').toString().trim() + } + } + } catch (ex) { } + } } results.hardware.agentvers = process.versions; replaceSpacesWithUnderscoresRec(results); diff --git a/public/images/details/tpm32.png b/public/images/details/tpm32.png new file mode 100644 index 0000000000000000000000000000000000000000..aeefe0036066acaeb91a21a44863d594aa5db652 GIT binary patch literal 1296 zcmV+r1@HQaP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D1f@wtK~z{r?Urjy zlUE$Z*%m*{Efe@iqVck?gm=>*GF)&_L=dQ=mHQnOp)HgZ3dOGAtV0-eLq#Z;ARrc^ z1(}h{!bM9d;0-|$aaQ(W$+8ca`C*1)p8d~jMG?0#G-g?Nk|*c%yl>C*JLmj!^4cwF zNlRMN|3(oJ5nNbUm@qUn)ZR8^ce``nYIDmz!$?;q#*Mic=@g^i5NBZHwpU(HF)=Y* zbab>fGBVOa03ZMm0QT(JW5|((rVV$7T4J%7OHEDH?%%)PLI5BD5C9emaL;rE*2!W_PbguX$b)rUg_)bl zeE5?g0yOx~2aw5RTv}S1Rw|WR2mk~C0>EMb#<~s=z)@JozJzsDjG5uY+3+X*K^WD4 zF&99sR(BHs2ml0t#Q+2c2SXqbKqLyok98?{e7_XdThe*qk9)SFPv_Qci+-y7{CsFM z8n8AqGm{Tr2mo8HkB<)@Dv`*rVZ$bvOjj^6)Pb&Q5gw0bQ+Uj5_#a(9FqeM{vu-_S zi+-xy+*~M?O626^K&4WFb_Chk*)*wy4}K9KJUkq}zJAzEp;-zg+}t*y=9C^|<3C~T zx^>vGGYsXGXArV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jL0ME>-dRyuy_nXoQ!w+xYXSeg0kyQFyy390aFu{W z%Qw}*hS2W@3te5^DfAfYOD)sRcAAwp>*>jp^~~bPkTkP^Hz?d2-IbGnn9qIuBD+cs zRq%OGa9n#q;b9(tI4VVX=x{loOJdWNO*u9MKpXd~7UGjsZ4SV}@b}oD{Qdr9+1k3g zhCkB!*%T>`V!yuHLCasNT0wv1AqB7oKXjp=>^usDX7eyv3J`oD$~4=8IC^(<#YaI}|K=wDh==Cqy@&)@)brV)UQR|8<6hJ+EZ zFG+c%LctqkJzb+{;B(f~4UH%GJRvblSzS}t4`6Iqc)WRYORE;Gc{RsRu5A-PssIL{ zHO1hS0~o09!0_?iS6)?fls6a@EXk`sdYsR_y~Fd4pJ?Lqy#ZqHqYX-PTC)j0s5k&o zj{tNLfb#Hp48Vx|lh|v!cZUbo)gR*xdUytjl*do;`L10dqLZguWVB|pW=PWm#Q?NN zs{u%7;&{9s1MvO7_;?la_m2@aHJ@P*SgbNe@7xtEI(6za1Hkn(#js2d6a#QRhHir# z0Bu|t0W)Ao1q4Wh%`ImdXvtb)tfl3qxsUhsvx)(@AbAAfdb&1FjN}UN@CX&OoIV>s z%V*x{p~L}*r6)l(fRQ`{UWyoii?KQ!fEyXJa5l|w2P7NS)7A|HP{rCV} zPIv_1=8qJBSP`g&FDvwMGfM|26BjT5BlCZSyeyRor@Nj`(ZS{YGx1@_+~@oI-~YQ# y#!q#S2Tehd&&+A+LmFwMkwzM6q|s0sHR?Z+h`VnEFj|-Z0000 0)) { var x = ''; diff --git a/views/default.handlebars b/views/default.handlebars index 8609e87f..5bb9ae2c 100644 --- a/views/default.handlebars +++ b/views/default.handlebars @@ -11759,6 +11759,18 @@ if (x != '') { sections.push({ name: "Motherboard", html: x, img: 'motherboard64.png'}); } } + // TPM + if (hardware.tpm) { + var x = '', tpm = hardware.tpm; + if (tpm.SpecVersion) { x += addDetailItem("SpecVersion", parseFloat(EscapeHtml(tpm.SpecVersion)).toFixed(1), s); } + if (tpm.ManufacturerId) { x += addDetailItem("ManufacturerId", EscapeHtml(tpm.ManufacturerId), s); } + if (tpm.ManufacturerVersion) { x += addDetailItem("ManufacturerVersion", EscapeHtml(tpm.ManufacturerVersion), s); } + if (tpm.IsActivated != null) { x += addDetailItem("IsActivated", EscapeHtml(tpm.IsActivated), s); } + if (tpm.IsEnabled != null) { x += addDetailItem("IsEnabled", EscapeHtml(tpm.IsEnabled), s); } + if (tpm.IsOwned != null) { x += addDetailItem("IsOwned", EscapeHtml(tpm.IsOwned), s); } + if (x != '') { sections.push({ name: "TPM", html: x, img: 'tpm64.png'}); } + } + if (hardware.windows) { if (hardware.windows.memory && (hardware.windows.memory.length > 0)) { var x = '';