1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-09 06:01:28 +00:00
Files
nmap/scripts/showSSHVersion.nse
david 84afa54d3a Update and proofread documentation of all the scripts, with the exception of
nbstat.nse and smb-*.nse, which Ron is going to do.
2008-10-25 03:11:25 +00:00

44 lines
824 B
Lua

id = "Stealth SSH version"
description = [[
Connects to an SSH server and retrieves the version banner.
This typically does not result in any logs of the connection being made.
]]
---
-- @output
-- 22/tcp open ssh
-- |_ Stealth SSH version: SSH-2.0-OpenSSH_3.9p1
author = "Diman Todorov <diman.todorov@gmail.com>"
license = "Same as Nmap--See http://nmap.org/book/man-legal.html"
categories = {"demo"}
require "shortport"
portrule = shortport.service("ssh")
action = function(host, port)
local result, socket
local catch = function()
socket:close()
end
local try = nmap.new_try(catch)
result = ""
socket = nmap.new_socket()
try(socket:connect(host.ip, port.number))
result = try(socket:receive_lines(1));
try(socket:send(result))
try(socket:close())
return (string.gsub(result, "\n", ""))
end