1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-09 06:01:28 +00:00
Files
nmap/scripts/showSSHVersion.nse
2006-12-11 00:34:26 +00:00

45 lines
863 B
Lua

id = "Stealth SSH version"
description = "Connects to an SSH server, queries the version string and echos it back. This tends to result\
in the scanning attempt not being logged by the ssh daemon on the target."
author = "Diman Todorov <diman.todorov@gmail.com>"
license = "See nmaps COPYING for licence"
categories = {"demo"}
portrule = function(host, port)
if
port.service == "ssh"
and port.protocol == "tcp"
and port.state == "open"
then
return true
else
return false
end
end
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