diff --git a/scripts/http-server-header.nse b/scripts/http-server-header.nse index 9ea75580c..0b1832698 100644 --- a/scripts/http-server-header.nse +++ b/scripts/http-server-header.nse @@ -48,19 +48,21 @@ action = function(host, port) end if #responses == 0 then -- Have to send the probe ourselves. - local status, result = comm.tryssl(host, port, "GET / HTTP/1.0\r\n\r\n") + local socket, result = comm.tryssl(host, port, "GET / HTTP/1.0\r\n\r\n") - if (not status) then + if (not socket) then return nil end + socket:close() responses[1] = result end -- Also send a probe with host header if we can. IIS reported to send -- different Server headers depending on presence of Host header. - local status, result = comm.tryssl(host, port, + local socket, result = comm.tryssl(host, port, ("GET / HTTP/1.1\r\nHost: %s\r\n\r\n"):format(stdnse.get_hostname(host))) - if status then + if socket then + socket:close() responses[#responses+1] = result end