mirror of
https://github.com/nmap/nmap.git
synced 2025-12-29 10:59:02 +00:00
Some fixes for script crashes due to updated shortport.ssl
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user