1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-15 04:09:01 +00:00

Check for service name before port number to work on nonstandard ports

This commit is contained in:
dmiller
2016-03-26 13:42:12 +00:00
parent a8086a222e
commit c8c4da0d6f

View File

@@ -646,10 +646,10 @@ function getPrepareTLSWithoutReconnect(port)
if ( port.version and port.version.service_tunnel == 'ssl') then if ( port.version and port.version.service_tunnel == 'ssl') then
return nil return nil
end end
return (SPECIALIZED_PREPARE_TLS_WITHOUT_RECONNECT[port.number] or return (SPECIALIZED_PREPARE_TLS_WITHOUT_RECONNECT[port.service] or
SPECIALIZED_PREPARE_TLS_WITHOUT_RECONNECT[port.service] or SPECIALIZED_PREPARE_TLS_WITHOUT_RECONNECT[port.number] or
SPECIALIZED_WRAPPED_TLS_WITHOUT_RECONNECT[port.number] or SPECIALIZED_WRAPPED_TLS_WITHOUT_RECONNECT[port.service] or
SPECIALIZED_WRAPPED_TLS_WITHOUT_RECONNECT[port.service]) SPECIALIZED_WRAPPED_TLS_WITHOUT_RECONNECT[port.number])
end end
--- Get a specialized SSL connection function to create an SSL socket --- Get a specialized SSL connection function to create an SSL socket
@@ -665,8 +665,8 @@ function isPortSupported(port)
if ( port.version and port.version.service_tunnel == 'ssl') then if ( port.version and port.version.service_tunnel == 'ssl') then
return nil return nil
end end
return (SPECIALIZED_PREPARE_TLS[port.number] or return (SPECIALIZED_PREPARE_TLS[port.service] or
SPECIALIZED_PREPARE_TLS[port.service]) SPECIALIZED_PREPARE_TLS[port.number])
end end
-- returns a function that yields a new tls record each time it is called -- returns a function that yields a new tls record each time it is called
@@ -713,7 +713,7 @@ function getCertificate(host, port)
local cert local cert
-- do we have to use a wrapper and do a manual handshake? -- do we have to use a wrapper and do a manual handshake?
local wrapper = SPECIALIZED_WRAPPED_TLS_WITHOUT_RECONNECT[port.number] or SPECIALIZED_WRAPPED_TLS_WITHOUT_RECONNECT[port.service] local wrapper = SPECIALIZED_WRAPPED_TLS_WITHOUT_RECONNECT[port.service] or SPECIALIZED_WRAPPED_TLS_WITHOUT_RECONNECT[port.number]
if wrapper then if wrapper then
local status, socket = wrapper(host, port) local status, socket = wrapper(host, port)
if not status then if not status then
@@ -779,7 +779,7 @@ function getCertificate(host, port)
end end
else else
-- Is there a specialized function for this port? -- Is there a specialized function for this port?
local specialized = SPECIALIZED_PREPARE_TLS[port.number] local specialized = SPECIALIZED_PREPARE_TLS[port.service] or SPECIALIZED_PREPARE_TLS[port.number]
local status local status
local socket = nmap.new_socket() local socket = nmap.new_socket()
if specialized then if specialized then