From cc4f836c643fd55f051326bb8f7605efcf91515a Mon Sep 17 00:00:00 2001 From: Simon Smith Date: Sun, 8 Oct 2023 12:29:02 +0000 Subject: [PATCH 1/5] add more identifiers to client Signed-off-by: Simon Smith --- modules/identifiers.js | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/modules/identifiers.js b/modules/identifiers.js index b9219345..03c43f1b 100644 --- a/modules/identifiers.js +++ b/modules/identifiers.js @@ -91,12 +91,17 @@ function linux_identifiers() identifiers['bios_date'] = ret['bios_date']; identifiers['bios_vendor'] = ret['bios_vendor']; identifiers['bios_version'] = ret['bios_version']; + identifiers['bios_serial'] = ret['product_serial']; identifiers['board_name'] = ret['board_name']; identifiers['board_serial'] = ret['board_serial']; identifiers['board_vendor'] = ret['board_vendor']; identifiers['board_version'] = ret['board_version']; identifiers['product_uuid'] = ret['product_uuid']; + try { + identifiers['bios_mode'] = (require('fs').statSync('/sys/firmware/efi').isDirectory() ? 'UEFI': 'Legacy'); + } catch (ex) { identifiers['bios_mode'] = 'Legacy'; } + var child = require('child_process').execFile('/bin/sh', ['sh']); child.stdout.str = ''; child.stdout.on('data', dataHandler); child.stdin.write('cat /proc/cpuinfo | grep "model name" | ' + "tr '\\n' ':' | awk -F: '{ print $2 }'\nexit\n"); @@ -424,11 +429,13 @@ function windows_identifiers() var ret = { windows: {} }; var items, item, i; - var values = require('win-wmi').query('ROOT\\CIMV2', "SELECT * FROM Win32_Bios", ['ReleaseDate', 'Manufacturer', 'SMBIOSBIOSVersion']); + var values = require('win-wmi').query('ROOT\\CIMV2', "SELECT * FROM Win32_Bios", ['ReleaseDate', 'Manufacturer', 'SMBIOSBIOSVersion', 'SerialNumber']); ret['identifiers'] = {}; ret['identifiers']['bios_date'] = values[0]['ReleaseDate']; ret['identifiers']['bios_vendor'] = values[0]['Manufacturer']; ret['identifiers']['bios_version'] = values[0]['SMBIOSBIOSVersion']; + ret['identifiers']['bios_serial'] = values[0]['SerialNumber']; + ret['identifiers']['bios_mode'] = 'Legacy'; values = require('win-wmi').query('ROOT\\CIMV2', "SELECT * FROM Win32_BaseBoard", ['Product', 'SerialNumber', 'Manufacturer', 'Version']); ret['identifiers']['board_name'] = values[0]['Product']; @@ -451,7 +458,12 @@ function windows_identifiers() values = require('win-wmi').query('ROOT\\CIMV2', "SELECT * FROM Win32_DiskPartition"); trimResults(values); ret.windows.partitions = values; - + for (var i in values) { + if (values[i].Description=='GPT: System') { + ret['identifiers']['bios_mode'] = 'UEFI'; + } + } + values = require('win-wmi').query('ROOT\\CIMV2', "SELECT * FROM Win32_Processor", ['Caption', 'DeviceID', 'Manufacturer', 'MaxClockSpeed', 'Name', 'SocketDesignation']); ret.windows.cpu = values; @@ -461,6 +473,11 @@ function windows_identifiers() values = require('win-wmi').query('ROOT\\CIMV2', "SELECT * FROM Win32_DiskDrive", ['Caption', 'DeviceID', 'Model', 'Partitions', 'Size']); ret.windows.drives = values; + values = require('win-wmi').query('ROOT\\CIMV2\\Security\\MicrosoftTpm', "SELECT * FROM Win32_Tpm", ['IsActivated_InitialValue','IsEnabled_InitialValue','IsOwned_InitialValue','ManufacturerIdTxt','ManufacturerVersion','ManufacturerVersionInfo','PhysicalPresenceVersionInfo','SpecVersion']); + if(values[0]) { + ret.tpm = values; + } + // Insert GPU names ret.identifiers.gpu_name = []; for (var gpuinfo in ret.windows.gpu) From 8c6cd1401d9fca0926103a28f9ccd95a0a921bbd Mon Sep 17 00:00:00 2001 From: Simon Smith Date: Sun, 8 Oct 2023 12:33:35 +0000 Subject: [PATCH 2/5] fix virrtual machine detect Signed-off-by: Simon Smith --- modules/identifiers.js | 66 +++++++++++++++++++++++++++--------------- 1 file changed, 42 insertions(+), 24 deletions(-) diff --git a/modules/identifiers.js b/modules/identifiers.js index 03c43f1b..5b95e70b 100644 --- a/modules/identifiers.js +++ b/modules/identifiers.js @@ -430,48 +430,66 @@ function windows_identifiers() var items, item, i; var values = require('win-wmi').query('ROOT\\CIMV2', "SELECT * FROM Win32_Bios", ['ReleaseDate', 'Manufacturer', 'SMBIOSBIOSVersion', 'SerialNumber']); - ret['identifiers'] = {}; - ret['identifiers']['bios_date'] = values[0]['ReleaseDate']; - ret['identifiers']['bios_vendor'] = values[0]['Manufacturer']; - ret['identifiers']['bios_version'] = values[0]['SMBIOSBIOSVersion']; - ret['identifiers']['bios_serial'] = values[0]['SerialNumber']; - ret['identifiers']['bios_mode'] = 'Legacy'; + if(values[0]){ + ret['identifiers'] = {}; + ret['identifiers']['bios_date'] = values[0]['ReleaseDate']; + ret['identifiers']['bios_vendor'] = values[0]['Manufacturer']; + ret['identifiers']['bios_version'] = values[0]['SMBIOSBIOSVersion']; + ret['identifiers']['bios_serial'] = values[0]['SerialNumber']; + ret['identifiers']['bios_mode'] = 'Legacy'; + } values = require('win-wmi').query('ROOT\\CIMV2', "SELECT * FROM Win32_BaseBoard", ['Product', 'SerialNumber', 'Manufacturer', 'Version']); - ret['identifiers']['board_name'] = values[0]['Product']; - ret['identifiers']['board_serial'] = values[0]['SerialNumber']; - ret['identifiers']['board_vendor'] = values[0]['Manufacturer']; - ret['identifiers']['board_version'] = values[0]['Version']; + if(values[0]){ + ret['identifiers']['board_name'] = values[0]['Product']; + ret['identifiers']['board_serial'] = values[0]['SerialNumber']; + ret['identifiers']['board_vendor'] = values[0]['Manufacturer']; + ret['identifiers']['board_version'] = values[0]['Version']; + } values = require('win-wmi').query('ROOT\\CIMV2', "SELECT * FROM Win32_ComputerSystemProduct", ['UUID']); - ret['identifiers']['product_uuid'] = values[0]['UUID']; - trimIdentifiers(ret.identifiers); + if(values[0]){ + ret['identifiers']['product_uuid'] = values[0]['UUID']; + trimIdentifiers(ret.identifiers); + } values = require('win-wmi').query('ROOT\\CIMV2', "SELECT * FROM Win32_PhysicalMemory"); - trimResults(values); - ret.windows.memory = values; + if(values[0]){ + trimResults(values); + ret.windows.memory = values; + } values = require('win-wmi').query('ROOT\\CIMV2', "SELECT * FROM Win32_OperatingSystem"); - trimResults(values); - ret.windows.osinfo = values[0]; + if(values[0]){ + trimResults(values); + ret.windows.osinfo = values[0]; + } values = require('win-wmi').query('ROOT\\CIMV2', "SELECT * FROM Win32_DiskPartition"); - trimResults(values); - ret.windows.partitions = values; - for (var i in values) { - if (values[i].Description=='GPT: System') { - ret['identifiers']['bios_mode'] = 'UEFI'; + if(values[0]){ + trimResults(values); + ret.windows.partitions = values; + for (var i in values) { + if (values[i].Description=='GPT: System') { + ret['identifiers']['bios_mode'] = 'UEFI'; + } } } values = require('win-wmi').query('ROOT\\CIMV2', "SELECT * FROM Win32_Processor", ['Caption', 'DeviceID', 'Manufacturer', 'MaxClockSpeed', 'Name', 'SocketDesignation']); - ret.windows.cpu = values; + if(values[0]){ + ret.windows.cpu = values; + } values = require('win-wmi').query('ROOT\\CIMV2', "SELECT * FROM Win32_VideoController", ['Name', 'CurrentHorizontalResolution', 'CurrentVerticalResolution']); - ret.windows.gpu = values; + if(values[0]){ + ret.windows.gpu = values; + } values = require('win-wmi').query('ROOT\\CIMV2', "SELECT * FROM Win32_DiskDrive", ['Caption', 'DeviceID', 'Model', 'Partitions', 'Size']); - ret.windows.drives = values; + if(values[0]){ + ret.windows.drives = values; + } values = require('win-wmi').query('ROOT\\CIMV2\\Security\\MicrosoftTpm', "SELECT * FROM Win32_Tpm", ['IsActivated_InitialValue','IsEnabled_InitialValue','IsOwned_InitialValue','ManufacturerIdTxt','ManufacturerVersion','ManufacturerVersionInfo','PhysicalPresenceVersionInfo','SpecVersion']); if(values[0]) { From 98a7f15788df1c76d0d1d2adfb4412b1c0c505c6 Mon Sep 17 00:00:00 2001 From: Simon Smith Date: Sun, 8 Oct 2023 12:45:39 +0000 Subject: [PATCH 3/5] move main identifiers object --- modules/identifiers.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/identifiers.js b/modules/identifiers.js index 5b95e70b..cfe1f9b8 100644 --- a/modules/identifiers.js +++ b/modules/identifiers.js @@ -429,9 +429,10 @@ function windows_identifiers() var ret = { windows: {} }; var items, item, i; + ret['identifiers'] = {}; + var values = require('win-wmi').query('ROOT\\CIMV2', "SELECT * FROM Win32_Bios", ['ReleaseDate', 'Manufacturer', 'SMBIOSBIOSVersion', 'SerialNumber']); if(values[0]){ - ret['identifiers'] = {}; ret['identifiers']['bios_date'] = values[0]['ReleaseDate']; ret['identifiers']['bios_vendor'] = values[0]['Manufacturer']; ret['identifiers']['bios_version'] = values[0]['SMBIOSBIOSVersion']; From 99eebecb0fe4cb730666008f596c6630e0882a72 Mon Sep 17 00:00:00 2001 From: Simon Smith Date: Sun, 8 Oct 2023 14:15:35 +0000 Subject: [PATCH 4/5] remove tpm as only testing Signed-off-by: Simon Smith --- modules/identifiers.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/modules/identifiers.js b/modules/identifiers.js index cfe1f9b8..6e514525 100644 --- a/modules/identifiers.js +++ b/modules/identifiers.js @@ -492,10 +492,6 @@ function windows_identifiers() ret.windows.drives = values; } - values = require('win-wmi').query('ROOT\\CIMV2\\Security\\MicrosoftTpm', "SELECT * FROM Win32_Tpm", ['IsActivated_InitialValue','IsEnabled_InitialValue','IsOwned_InitialValue','ManufacturerIdTxt','ManufacturerVersion','ManufacturerVersionInfo','PhysicalPresenceVersionInfo','SpecVersion']); - if(values[0]) { - ret.tpm = values; - } // Insert GPU names ret.identifiers.gpu_name = []; From 03dcd9e576f3c4ffed2035aef4351774330ac420 Mon Sep 17 00:00:00 2001 From: Simon Smith Date: Sun, 8 Oct 2023 14:17:00 +0000 Subject: [PATCH 5/5] remove extra line Signed-off-by: Simon Smith --- modules/identifiers.js | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/identifiers.js b/modules/identifiers.js index 6e514525..eb267011 100644 --- a/modules/identifiers.js +++ b/modules/identifiers.js @@ -492,7 +492,6 @@ function windows_identifiers() ret.windows.drives = values; } - // Insert GPU names ret.identifiers.gpu_name = []; for (var gpuinfo in ret.windows.gpu)