mirror of
https://github.com/nmap/nmap.git
synced 2025-12-06 04:31:29 +00:00
New, broader portrule for SSH scripts. Closes #1825
This commit is contained in:
@@ -1,5 +1,9 @@
|
|||||||
#Nmap Changelog ($Id$); -*-text-*-
|
#Nmap Changelog ($Id$); -*-text-*-
|
||||||
|
|
||||||
|
o [NSE][GH#1825] SSH scripts now run on several ports likely to be SSH based on
|
||||||
|
empirical data from Shodan.io, as well as the netconf-ssh service.
|
||||||
|
[Lim Shi Min Jonathan, Daniel Miller]
|
||||||
|
|
||||||
o [Zenmap][GH#1777] Stop creating a debugging output file 'tmp.txt' on the
|
o [Zenmap][GH#1777] Stop creating a debugging output file 'tmp.txt' on the
|
||||||
desktop in macOS. [Roland Linder]
|
desktop in macOS. [Roland Linder]
|
||||||
|
|
||||||
|
|||||||
@@ -292,6 +292,35 @@ function ssl(host, port)
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local LIKELY_SSH_PORTS = {
|
||||||
|
-- Top ssh ports on shodanhq.com
|
||||||
|
22,
|
||||||
|
2222,
|
||||||
|
55554,
|
||||||
|
--666, -- 86% SSH, but we'd like to be more certain.
|
||||||
|
22222,
|
||||||
|
2382,
|
||||||
|
-- And others reported by users
|
||||||
|
830, -- netconf-ssh
|
||||||
|
}
|
||||||
|
|
||||||
|
-- This part isn't really necessary, since -sV will reliably detect SSH
|
||||||
|
local LIKELY_SSH_SERVICES = {
|
||||||
|
'ssh', 'netconf-ssh'
|
||||||
|
}
|
||||||
|
|
||||||
|
-- A portrule that matches likely SSH services.
|
||||||
|
--
|
||||||
|
-- @name ssh
|
||||||
|
-- @class function
|
||||||
|
-- @param host The host table to match against.
|
||||||
|
-- @param port The port table to match against.
|
||||||
|
-- @return <code>true</code> if the port is likely to be SSH,
|
||||||
|
-- <code>false</code> otherwise.
|
||||||
|
-- @usage
|
||||||
|
-- portrule = shortport.ssh
|
||||||
|
|
||||||
|
ssh = port_or_service(LIKELY_SSH_PORTS, LIKELY_SSH_SERVICES)
|
||||||
|
|
||||||
--- Return a portrule that returns true when given an open port matching a port range
|
--- Return a portrule that returns true when given an open port matching a port range
|
||||||
--
|
--
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ license = "Same as Nmap--See https://nmap.org/book/man-legal.html"
|
|||||||
categories = {"auth", "intrusive"}
|
categories = {"auth", "intrusive"}
|
||||||
|
|
||||||
local username = stdnse.get_script_args("ssh.user") or rand.random_alpha(5)
|
local username = stdnse.get_script_args("ssh.user") or rand.random_alpha(5)
|
||||||
portrule = shortport.port_or_service(22, 'ssh')
|
portrule = shortport.ssh
|
||||||
|
|
||||||
function action (host, port)
|
function action (host, port)
|
||||||
local result = stdnse.output_table()
|
local result = stdnse.output_table()
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ categories = {
|
|||||||
'intrusive',
|
'intrusive',
|
||||||
}
|
}
|
||||||
|
|
||||||
portrule = shortport.port_or_service(22, 'ssh')
|
portrule = shortport.ssh
|
||||||
|
|
||||||
local arg_timeout = stdnse.get_script_args(SCRIPT_NAME .. ".timeout") or "5s"
|
local arg_timeout = stdnse.get_script_args(SCRIPT_NAME .. ".timeout") or "5s"
|
||||||
|
|
||||||
|
|||||||
@@ -139,7 +139,7 @@ license = "Same as Nmap--See https://nmap.org/book/man-legal.html"
|
|||||||
categories = {"safe","default","discovery"}
|
categories = {"safe","default","discovery"}
|
||||||
|
|
||||||
|
|
||||||
portrule = shortport.port_or_service(22, "ssh")
|
portrule = shortport.ssh
|
||||||
|
|
||||||
postrule = function() return (nmap.registry.sshhostkey ~= nil) end
|
postrule = function() return (nmap.registry.sshhostkey ~= nil) end
|
||||||
|
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ local usernames = stdnse.get_script_args "ssh.usernames"
|
|||||||
local knownbad = stdnse.get_script_args "knownbad"
|
local knownbad = stdnse.get_script_args "knownbad"
|
||||||
local publickeys = stdnse.get_script_args "ssh.publickeys"
|
local publickeys = stdnse.get_script_args "ssh.publickeys"
|
||||||
local publickeydb = stdnse.get_script_args "publickeydb" or nmap.fetchfile("nselib/data/publickeydb")
|
local publickeydb = stdnse.get_script_args "publickeydb" or nmap.fetchfile("nselib/data/publickeydb")
|
||||||
portrule = shortport.port_or_service(22, 'ssh')
|
portrule = shortport.ssh
|
||||||
|
|
||||||
function action (host, port)
|
function action (host, port)
|
||||||
local result = stdnse.output_table()
|
local result = stdnse.output_table()
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ categories = {
|
|||||||
'intrusive',
|
'intrusive',
|
||||||
}
|
}
|
||||||
|
|
||||||
portrule = shortport.port_or_service(22, 'ssh')
|
portrule = shortport.ssh
|
||||||
|
|
||||||
local username = stdnse.get_script_args 'ssh-run.username'
|
local username = stdnse.get_script_args 'ssh-run.username'
|
||||||
local cmd = stdnse.get_script_args 'ssh-run.cmd'
|
local cmd = stdnse.get_script_args 'ssh-run.cmd'
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ license = "Same as Nmap--See https://nmap.org/book/man-legal.html"
|
|||||||
categories = {"safe", "discovery"}
|
categories = {"safe", "discovery"}
|
||||||
|
|
||||||
|
|
||||||
portrule = shortport.port_or_service(22, "ssh")
|
portrule = shortport.ssh
|
||||||
|
|
||||||
-- Build onto lists{} and possibly modify parsed{} based on whether the
|
-- Build onto lists{} and possibly modify parsed{} based on whether the
|
||||||
-- algorithm name-lists are identical between the server-to-client and
|
-- algorithm name-lists are identical between the server-to-client and
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ categories = {"default", "safe"}
|
|||||||
-- true
|
-- true
|
||||||
|
|
||||||
|
|
||||||
portrule = shortport.port_or_service(22, "ssh")
|
portrule = shortport.ssh
|
||||||
|
|
||||||
action = function(host, port)
|
action = function(host, port)
|
||||||
local socket = nmap.new_socket()
|
local socket = nmap.new_socket()
|
||||||
|
|||||||
Reference in New Issue
Block a user