From be0ebe8859e988d1a75976606f392a36982d2fac Mon Sep 17 00:00:00 2001 From: patrik Date: Fri, 15 Jun 2012 21:43:41 +0000 Subject: [PATCH] Fixed a bug that would make the smb-system-info script fail, due to a trailing zero terminator in the processor count, resulting in a failure to convert the string to a number. --- scripts/smb-system-info.nse | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/scripts/smb-system-info.nse b/scripts/smb-system-info.nse index 5a49c8f92..8cf7c1953 100644 --- a/scripts/smb-system-info.nse +++ b/scripts/smb-system-info.nse @@ -129,7 +129,10 @@ local function get_info_registry(host) result['status-processor_level'], result['processor_level'] = reg_get_value(smbstate, openhklm_result['handle'], "SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment", "PROCESSOR_LEVEL") result['status-processor_revision'], result['processor_revision'] = reg_get_value(smbstate, openhklm_result['handle'], "SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment", "PROCESSOR_REVISION") - for i = 0, result['number_of_processors'] - 1, 1 do + -- remove trailing zero terminator + local num_procs = result['number_of_processors']:match("^[^%z]*") + + for i = 0, tonumber(num_procs) - 1, 1 do result['status-~mhz'..i], result['~mhz' .. i] = reg_get_value(smbstate, openhklm_result['handle'], "HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\" .. i, "~MHz") result['status-identifier'..i], result['identifier' .. i] = reg_get_value(smbstate, openhklm_result['handle'], "HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\" .. i, "Identifier") result['status-processornamestring'..i], result['processornamestring' .. i] = reg_get_value(smbstate, openhklm_result['handle'], "HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\" .. i, "ProcessorNameString") @@ -201,7 +204,9 @@ action = function(host) local hardware = {} hardware['name'] = "Hardware" - for i = 0, result['number_of_processors'] - 1, 1 do + -- remove trailing zero terminator + local num_procs = result['number_of_processors']:match("^[^%z]*") + for i = 0, tonumber(num_procs) - 1, 1 do if(result['status-processornamestring'..i] == false) then result['status-processornamestring'..i] = "Unknown" end