Add 's' service names to portrules
Some checks are pending
nmap multiplatform autobuilds / build (arm64, gcc, ubuntu-latest-gcc-arm64, ubuntu-latest) (push) Waiting to run
nmap multiplatform autobuilds / build (clang, freebsd-15-clang, ubuntu-latest) (push) Waiting to run
nmap multiplatform autobuilds / build (clang, macos-15-clang, macos-15) (push) Waiting to run
nmap multiplatform autobuilds / build (clang, macos-26-clang, macos-26) (push) Waiting to run
nmap multiplatform autobuilds / build (clang, netbsd-10-clang, ubuntu-latest) (push) Waiting to run
nmap multiplatform autobuilds / build (clang, openbsd-7-clang, ubuntu-latest) (push) Waiting to run
nmap multiplatform autobuilds / build (clang, solaris-11-clang, ubuntu-latest) (push) Waiting to run
nmap multiplatform autobuilds / build (clang, ubuntu-latest-clang, ubuntu-latest) (push) Waiting to run
nmap multiplatform autobuilds / build (egcc, openbsd-7-gcc, ubuntu-latest) (push) Waiting to run
nmap multiplatform autobuilds / build (gcc, freebsd-15-gcc, ubuntu-latest) (push) Waiting to run
nmap multiplatform autobuilds / build (gcc, netbsd-10-gcc, ubuntu-latest) (push) Waiting to run
nmap multiplatform autobuilds / build (gcc, solaris-11-gcc, ubuntu-latest) (push) Waiting to run
nmap multiplatform autobuilds / build (gcc, ubuntu-latest-gcc, ubuntu-latest) (push) Waiting to run
nmap multiplatform autobuilds / build (msvc, windows-latest-msvc, windows-latest) (push) Waiting to run

This commit is contained in:
dmiller 2026-07-23 18:06:50 +00:00
parent 727203392a
commit 72544c0b9e
31 changed files with 39 additions and 38 deletions

View file

@ -1,5 +1,9 @@
#Nmap Changelog ($Id$); -*-text-*-
o [NSE][GH#1066] Added service names for SSL-protected services like
amt-soap-https to portrules for several scripts, ensuring they run on these
as well as the standard unencrypted services.
o Audited and converted most instances of strcat, strcpy, and sprintf to use
bounded functions instead.

View file

@ -4,6 +4,7 @@
-- @copyright Same as Nmap--See https://nmap.org/book/man-legal.html
local comm = require "comm"
local shortport = require "shortport"
local stdnse = require "stdnse"
local string = require "string"
local table = require "table"
@ -11,6 +12,10 @@ local ipOps = require "ipOps"
local nmap = require "nmap"
_ENV = stdnse.module("ftp", stdnse.seeall)
--- Portrule for FTP services
-- @class function
portrule = shortport.port_or_service({21, 990}, {"ftp", "ftps"})
local ERROR_MESSAGES = {
["EOF"] = "connection closed",
["TIMEOUT"] = "connection timeout",

View file

@ -37,7 +37,7 @@ license = "Same as Nmap--See https://nmap.org/book/man-legal.html"
categories = {"default", "discovery", "safe", "version"}
portrule = shortport.version_port_or_service(5672, "amqp", "tcp", "open")
portrule = shortport.version_port_or_service(5672, {"amqp", "amqps"}, "tcp", "open")
action = function(host, port)
local cli = amqp.AMQP:new( host, port )

View file

@ -73,8 +73,7 @@ author = "Mak Kolybabi <mak@kolybabi.com>"
license = "Same as Nmap--See https://nmap.org/book/man-legal.html"
categories = {"safe", "discovery"}
-- TODO: Add 5684 "coaps" if DTLS support is added
portrule = shortport.port_or_service(5683, "coap", "udp")
portrule = shortport.port_or_service({5683, 5684}, {"coap", "coaps"}, "udp")
format_payload = function(payload)
-- Leave strings alone.

View file

@ -1,7 +1,6 @@
local ftp = require "ftp"
local match = require "match"
local nmap = require "nmap"
local shortport = require "shortport"
local stdnse = require "stdnse"
local string = require "string"
local table = require "table"
@ -38,7 +37,7 @@ license = "Same as Nmap--See https://nmap.org/book/man-legal.html"
categories = {"default", "auth", "safe"}
portrule = shortport.port_or_service({21,990}, {"ftp","ftps"})
portrule = ftp.portrule
-- ---------------------
-- Directory listing function.

View file

@ -1,5 +1,4 @@
local nmap = require "nmap"
local shortport = require "shortport"
local stdnse = require "stdnse"
local string = require "string"
local ftp = require "ftp"
@ -29,7 +28,7 @@ license = "Same as Nmap--See https://nmap.org/book/man-legal.html"
categories = {"default", "safe"}
portrule = shortport.port_or_service({21, 990}, {"ftp", "ftps"})
portrule = ftp.portrule
local function get_portfmt()
local arghost = stdnse.get_script_args(SCRIPT_NAME .. ".checkhost") or "scanme.nmap.org"

View file

@ -1,6 +1,5 @@
local brute = require "brute"
local creds = require "creds"
local shortport = require "shortport"
local stdnse = require "stdnse"
local ftp = require "ftp"
@ -37,7 +36,7 @@ author = "Aleksandar Nikolic"
license = "Same as Nmap--See https://nmap.org/book/man-legal.html"
categories = {"intrusive", "brute"}
portrule = shortport.port_or_service(21, "ftp")
portrule = ftp.portrule
local arg_timeout = stdnse.parse_timespec(stdnse.get_script_args(SCRIPT_NAME .. ".timeout"))
arg_timeout = (arg_timeout or 5) * 1000

View file

@ -37,7 +37,7 @@ author = "Ange Gutek"
license = "Same as Nmap--See https://nmap.org/book/man-legal.html"
categories = {"vuln","intrusive"}
-- TODO: use comm.lua or ftp.lua and add ftps
portrule = shortport.port_or_service(21, "ftp")
action = function(host, port)

View file

@ -1,6 +1,5 @@
local ftp = require "ftp"
local nmap = require "nmap"
local shortport = require "shortport"
local stdnse = require "stdnse"
-- -*- mode: lua -*-
@ -48,7 +47,7 @@ portrule = function (host, port)
return false
end
return shortport.port_or_service(21, "ftp")(host, port)
return ftp.portrule(host, port)
end
action = function(host, port)

View file

@ -1,5 +1,4 @@
local ftp = require "ftp"
local shortport = require "shortport"
local stdnse = require "stdnse"
description = [[
@ -63,7 +62,7 @@ categories = {"default", "discovery", "safe"}
-- No data connection
-- End of status</elem>
portrule = shortport.port_or_service({21,990}, {"ftp","ftps"})
portrule = ftp.portrule
local function do_syst(socket, buffer)
end

View file

@ -1,6 +1,5 @@
local ftp = require "ftp"
local nmap = require "nmap"
local shortport = require "shortport"
local stdnse = require "stdnse"
local string = require "string"
local table = require "table"
@ -68,7 +67,7 @@ portrule = function (host, port)
return false
end
return shortport.port_or_service(21, "ftp")(host, port)
return ftp.portrule(host, port)
end
local function finish_ftp(socket, status, message)

View file

@ -1,5 +1,4 @@
local ftp = require "ftp"
local shortport = require "shortport"
local stdnse = require "stdnse"
local string = require "string"
local stringaux = require "stringaux"
@ -54,7 +53,7 @@ portrule = function (host, port)
if port.version.product ~= nil and port.version.product ~= "ProFTPD" then
return false
end
return shortport.port_or_service(21, "ftp")(host, port)
return ftp.portrule(host, port)
end
local function get_proftpd_banner(banner)

View file

@ -57,7 +57,7 @@ local table = require "table"
local string = require "string"
local httpspider = require "httpspider"
portrule = shortport.port_or_service( {80, 443}, {"http", "https"}, "tcp", "open")
portrule = shortport.http
-- Checks if this is really a token.
isToken = function(value)

View file

@ -48,7 +48,7 @@ local stdnse = require "stdnse"
local httpspider = require "httpspider"
local _G = require "_G"
portrule = shortport.port_or_service( {80, 443}, {"http", "https"}, "tcp", "open")
portrule = shortport.http
local function loadFingerprints(filename)

View file

@ -67,7 +67,7 @@ JS_CALLS_PATTERNS = {
'location',
}
portrule = shortport.port_or_service( {80, 443}, {"http", "https"}, "tcp", "open")
portrule = shortport.http
action = function(host, port)

View file

@ -90,7 +90,7 @@ categories = {"intrusive", "auth"}
dependencies = {"http-brute", "http-form-brute"}
portrule = shortport.port_or_service({80, 443}, {"http","https"}, "tcp", "open")
portrule = shortport.http
--- Checks if the <code>path</code> require authentication
--

View file

@ -42,7 +42,7 @@ local stdnse = require "stdnse"
local table = require "table"
local httpspider = require "httpspider"
portrule = shortport.port_or_service( {80, 443}, {"http", "https"}, "tcp", "open")
portrule = shortport.http
local function compare(a, b)
return a[1] < b[1]

View file

@ -33,7 +33,7 @@ local table = require "table"
local string = require "string"
local httpspider = require "httpspider"
portrule = shortport.port_or_service( {80, 443}, {"http", "https"}, "tcp", "open")
portrule = shortport.http
FEEDS = { RSS = { search = { '<rss(.*)>' }, version = 'version=["\'](.-)["\']' },
Atom = { search = { '<feed(.*)>' }, version = 'version=["\'](.-)["\']' },

View file

@ -63,7 +63,7 @@ local shortport = require "shortport"
local stdnse = require "stdnse"
local table = require "table"
portrule = shortport.port_or_service( {80, 443}, {"http", "https"}, "tcp", "open")
portrule = shortport.http
-- A list of payloads. The interpreted code in the 'content' variable should

View file

@ -109,7 +109,7 @@ license = "Same as Nmap--See https://nmap.org/book/man-legal.html"
categories = {"intrusive", "brute"}
portrule = shortport.port_or_service( {80, 443}, {"http", "https"}, "tcp", "open")
portrule = shortport.http
-- Miscellaneous script-wide constants

View file

@ -57,7 +57,7 @@ getLastLoc = function(host, port, useragent)
end
portrule = shortport.port_or_service( {80, 443}, {"http", "https"}, "tcp", "open")
portrule = shortport.http
action = function(host, port)

View file

@ -47,7 +47,7 @@ license = "Same as Nmap--See https://nmap.org/book/man-legal.html"
categories = {"safe","discovery"}
portrule = shortport.port_or_service ({443,8080}, "https", "tcp")
portrule = shortport.http
action = function(host, port)

View file

@ -29,7 +29,7 @@ local stdnse = require "stdnse"
local table = require "table"
local httpspider = require "httpspider"
portrule = shortport.port_or_service( {80, 443}, {"http", "https"}, "tcp", "open")
portrule = shortport.http
action = function(host, port)

View file

@ -177,7 +177,7 @@ local function check_responses(urls, responses)
return suspects
end
portrule = shortport.port_or_service( {80, 443}, {"http", "https"}, "tcp", "open")
portrule = shortport.http
function action(host, port)
inclusion_url = stdnse.get_script_args('http-rfi-spider.inclusionurl') or 'http://tools.ietf.org/html/rfc13?'

View file

@ -96,7 +96,7 @@ author = {"Icaro Torres", "Vinamra Bhatia"}
license = "Same as Nmap--See https://nmap.org/book/man-legal.html"
categories = {"discovery", "safe"}
portrule = shortport.port_or_service({80,443}, "http", "tcp")
portrule = shortport.http
local function fail (err) return stdnse.format_output(false, err) end

View file

@ -54,7 +54,7 @@ local httpspider = require 'httpspider'
local string = require 'string'
local table = require 'table'
portrule = shortport.port_or_service( {80, 443}, {"http", "https"}, "tcp", "open")
portrule = shortport.http
local function dict_add(d, k, v)
if not d[k] then

View file

@ -61,7 +61,7 @@ categories = {"intrusive", "vuln"}
--
portrule = shortport.port_or_service({80, 443}, {"http","https"})
portrule = shortport.http
--[[
Pattern match response from a submitted injection query to see

View file

@ -65,7 +65,7 @@ local shortport = require "shortport"
local stdnse = require "stdnse"
local table = require "table"
portrule = shortport.port_or_service( {80, 443}, {"http", "https"}, "tcp", "open")
portrule = shortport.http
-- A list of payloads.

View file

@ -105,7 +105,7 @@ getLastLoc = function(host, port, useragent)
end
portrule = shortport.port_or_service( {80, 443}, {"http", "https"}, "tcp", "open")
portrule = shortport.http
action = function(host, port)

View file

@ -34,7 +34,7 @@ author = "nnposter"
license = "Same as Nmap--See https://nmap.org/book/man-legal.html"
categories = {'brute', 'intrusive'}
portrule = shortport.port_or_service(23, 'telnet')
portrule = shortport.port_or_service({23, 992}, {'telnet', 'telnets'})
-- Miscellaneous script-wide parameters and constants

View file

@ -75,13 +75,13 @@ local tnap_login_packet = string.pack("<BBBBBBB I4I4",
.. ntlm_auth_blob .. string.pack("<BB",
0xff, 0xf0) -- Sub-option End
portrule = shortport.port_or_service(23, "telnet")
portrule = shortport.port_or_service({23, 992}, {'telnet', 'telnets'})
action = function(host, port)
local output = stdnse.output_table()
local socket, response, early_resp = comm.opencon(host, port, tnap_login_packet, {recv_before=true})
local socket, response, _, early_resp = comm.tryssl(host, port, tnap_login_packet, {recv_before=true})
if not socket then
return nil