From 622c14c11526d9b76c0b883d6efe9ef09280c1f5 Mon Sep 17 00:00:00 2001 From: dmiller Date: Thu, 12 Jul 2018 04:14:35 +0000 Subject: [PATCH] Some fixes for script crashes due to updated shortport.ssl --- nselib/comm.lua | 8 ++++---- nselib/http.lua | 2 +- nselib/shortport.lua | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/nselib/comm.lua b/nselib/comm.lua index 7f264be34..426862fb8 100644 --- a/nselib/comm.lua +++ b/nselib/comm.lua @@ -189,11 +189,11 @@ local function bestoption(port) service = port.service, protocol = port.protocol or "tcp", state = port.state or "open", - version = port.version or {} + version = port.version } if is_ssl(_port) then return "ssl","tcp" end elseif type(port) == 'number' then - if is_ssl({number=port, protocol="tcp", state="open", version={}}) then return "ssl","tcp" end + if is_ssl({number=port, protocol="tcp", state="open"}) then return "ssl","tcp" end end return "tcp","ssl" end @@ -292,7 +292,7 @@ end test_suite = unittest.TestSuite:new() test_suite:add_test(unittest.table_equal({bestoption(443)}, {"ssl", "tcp"}), "bestoption ssl number") test_suite:add_test(unittest.table_equal({bestoption(80)}, {"tcp", "ssl"}), "bestoption tcp number") -test_suite:add_test(unittest.table_equal({bestoption({number=8443,protocol="tcp",state="open",version={}})}, {"ssl", "tcp"}), "bestoption ssl table") -test_suite:add_test(unittest.table_equal({bestoption({number=1234,protocol="tcp",state="open",version={}})}, {"tcp", "ssl"}), "bestoption tcp table") +test_suite:add_test(unittest.table_equal({bestoption({number=8443,protocol="tcp",state="open"})}, {"ssl", "tcp"}), "bestoption ssl table") +test_suite:add_test(unittest.table_equal({bestoption({number=1234,protocol="tcp",state="open"})}, {"tcp", "ssl"}), "bestoption tcp table") return _ENV; diff --git a/nselib/http.lua b/nselib/http.lua index 7c5cb242d..16c9cbe31 100644 --- a/nselib/http.lua +++ b/nselib/http.lua @@ -174,7 +174,7 @@ 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", version={}} + 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 diff --git a/nselib/shortport.lua b/nselib/shortport.lua index c174f14cd..df2583889 100644 --- a/nselib/shortport.lua +++ b/nselib/shortport.lua @@ -235,7 +235,7 @@ function ssl(host, port) return true end -- if we didn't detect something *not* SSL, check it ourselves - if port.version.name_confidence <= 3 and host.registry then + if port.version and port.version.name_confidence <= 3 and host.registry then comm = comm or require "comm" host.registry.ssl = host.registry.ssl or {} local mtx = nmap.mutex(host.registry.ssl)