1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-06 04:31:29 +00:00

Let ssl-cert grab certs from DTLS services. Fix rules for TCP-only scripts

This commit is contained in:
dmiller
2024-06-03 19:00:33 +00:00
parent ff0b70f6dd
commit 74a88c0804
17 changed files with 39 additions and 32 deletions

View File

@@ -38,7 +38,7 @@ license = "Same as Nmap--See https://nmap.org/book/man-legal.html"
categories = {"vuln", "safe"}
portrule = function(host, port)
return shortport.ssl(host, port) or sslcert.isPortSupported(port)
return port.protocol == "tcp" and (shortport.ssl(host, port) or sslcert.isPortSupported(port))
end
action = function(host, port)

View File

@@ -37,7 +37,7 @@ license = "Same as Nmap--See https://nmap.org/book/man-legal.html"
categories = {"vuln", "safe"}
portrule = function(host, port)
return shortport.ssl(host, port) or sslcert.isPortSupported(port)
return port.protocol == "tcp" and (shortport.ssl(host, port) or sslcert.isPortSupported(port))
end
action = function(host, port)

View File

@@ -37,7 +37,7 @@ license = "Same as Nmap--See https://nmap.org/book/man-legal.html"
categories = {"vuln", "safe"}
portrule = function(host, port)
return shortport.ssl(host, port) or sslcert.isPortSupported(port)
return port.protocol == "tcp" and (shortport.ssl(host, port) or sslcert.isPortSupported(port))
end
action = function(host, port)

View File

@@ -37,7 +37,7 @@ license = "Same as Nmap--See https://nmap.org/book/man-legal.html"
categories = {"vuln", "safe"}
portrule = function(host, port)
return shortport.ssl(host, port) or sslcert.isPortSupported(port)
return port.protocol == "tcp" and (shortport.ssl(host, port) or sslcert.isPortSupported(port))
end
action = function(host, port)

View File

@@ -69,7 +69,7 @@ categories = { "vuln", "safe" }
dependencies = {"https-redirect"}
portrule = function(host, port)
return shortport.ssl(host, port) or sslcert.getPrepareTLSWithoutReconnect(port)
return port.protocol == "tcp" and (shortport.ssl(host, port) or sslcert.getPrepareTLSWithoutReconnect(port))
end
local Error = {

View File

@@ -40,7 +40,7 @@ categories = {"discovery", "safe", "default"}
dependencies = {"https-redirect"}
portrule = function(host, port)
return shortport.ssl(host, port) or sslcert.getPrepareTLSWithoutReconnect(port)
return port.protocol == "tcp" and (shortport.ssl(host, port) or sslcert.getPrepareTLSWithoutReconnect(port))
end
-- Miscellaneous script-wide constants

View File

@@ -788,7 +788,7 @@ end
portrule = function(host, port)
return shortport.ssl(host, port) or sslcert.getPrepareTLSWithoutReconnect(port)
return port.protocol == "tcp" and (shortport.ssl(host, port) or sslcert.getPrepareTLSWithoutReconnect(port))
end
local function format_check(t, label)

View File

@@ -1095,7 +1095,7 @@ local function try_protocol(host, port, protocol, upresults)
end
portrule = function (host, port)
return shortport.ssl(host, port) or sslcert.getPrepareTLSWithoutReconnect(port)
return port.protocol == "tcp" and (shortport.ssl(host, port) or sslcert.getPrepareTLSWithoutReconnect(port))
end
action = function(host, port)

View File

@@ -47,7 +47,7 @@ dependencies = {"https-redirect"}
local arg_protocols = stdnse.get_script_args(SCRIPT_NAME .. ".protocols") or {'TLSv1.0', 'TLSv1.1', 'TLSv1.2'}
portrule = function(host, port)
return shortport.ssl(host, port) or sslcert.getPrepareTLSWithoutReconnect(port)
return port.protocol == "tcp" and (shortport.ssl(host, port) or sslcert.getPrepareTLSWithoutReconnect(port))
end
local function recvhdr(s)

View File

@@ -103,7 +103,9 @@ local get_fingerprints = function(path)
return true, fingerprints
end
portrule = shortport.ssl
portrule = function(host, port)
return shortport.ssl(host, port) or sslcert.isPortSupported(port) or sslcert.getPrepareTLSWithoutReconnect(port)
end
action = function(host, port)
-- Get script arguments.

View File

@@ -308,7 +308,7 @@ local function check_fallback_scsv(host, port, protocol, ciphers)
end
portrule = function (host, port)
return shortport.ssl(host, port) or sslcert.getPrepareTLSWithoutReconnect(port)
return port.protocol == "tcp" and (shortport.ssl(host, port) or sslcert.getPrepareTLSWithoutReconnect(port))
end
action = function(host, port)

View File

@@ -95,7 +95,7 @@ for k, v in pairs(sslv2.SSL_CIPHERS) do
end
portrule = function(host, port)
return shortport.ssl(host, port) or sslcert.getPrepareTLSWithoutReconnect(port)
return port.protocol == "tcp" and (shortport.ssl(host, port) or sslcert.getPrepareTLSWithoutReconnect(port))
end
-- Return whether all values of "t1" are also values in "t2".

View File

@@ -40,7 +40,7 @@ categories = {"default", "safe"}
portrule = function(host, port)
return shortport.ssl(host, port) or sslcert.getPrepareTLSWithoutReconnect(port)
return port.protocol == "tcp" and (shortport.ssl(host, port) or sslcert.getPrepareTLSWithoutReconnect(port))
end
action = function(host, port)

View File

@@ -40,7 +40,7 @@ categories = {"discovery", "safe", "default"}
dependencies = {"https-redirect"}
portrule = function(host, port)
return shortport.ssl(host, port) or sslcert.getPrepareTLSWithoutReconnect(port)
return port.protocol == "tcp" and (shortport.ssl(host, port) or sslcert.getPrepareTLSWithoutReconnect(port))
end

View File

@@ -43,7 +43,7 @@ categories = {"discovery", "safe", "default"}
dependencies = {"https-redirect"}
portrule = function(host, port)
return shortport.ssl(host, port) or sslcert.getPrepareTLSWithoutReconnect(port)
return port.protocol == "tcp" and (shortport.ssl(host, port) or sslcert.getPrepareTLSWithoutReconnect(port))
end

View File

@@ -68,7 +68,7 @@ portrule = function(host, port)
return false
end
return shortport.ssl(host, port) or sslcert.getPrepareTLSWithoutReconnect(port)
return port.protocol == "tcp" and (shortport.ssl(host, port) or sslcert.getPrepareTLSWithoutReconnect(port))
end
local function is_vuln(host, port, version)