From b2deb019edefbcb1f19685dfa3cff0e3f671c73a Mon Sep 17 00:00:00 2001 From: dmiller Date: Sat, 11 Aug 2018 21:23:58 +0000 Subject: [PATCH] Don't use shortport.ssl to determine Host header. The only reason this was used was to determine if port 443 was HTTPS. Simply dropping the port if it's 80 or 443 yields the same outcome. Maybe we want to be more clear, but then we'd need to have the caller pass in the URI scheme, too. This is faster and avoids the new SSL probes in shortport.ssl. --- nselib/http.lua | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/nselib/http.lua b/nselib/http.lua index 16c9cbe31..c6c8ca56a 100644 --- a/nselib/http.lua +++ b/nselib/http.lua @@ -173,14 +173,11 @@ local get_default_port = url.get_default_port local function get_host_field(host, port) if host_header then return host_header end if not host then return nil end - if type(port) == "number" then - port = {number=port, protocol="tcp", state="open"} - end - local scheme = shortport.ssl(host, port) and "https" or "http" - if port.number == get_default_port(scheme) then + local number = (type(port) == "number") and port or port.number + if number == 443 or number == 80 then return stdnse.get_hostname(host) else - return stdnse.get_hostname(host) .. ":" .. port.number + return stdnse.get_hostname(host) .. ":" .. number end end