1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-15 04:09:01 +00:00

Merged libssh2-integration branch

This commit is contained in:
devin
2014-08-14 02:09:00 +00:00
parent f6f59a7cd7
commit 63f997ed28
13 changed files with 1089 additions and 32 deletions

View File

@@ -0,0 +1,35 @@
local shortport = require "shortport"
local stdnse = require "stdnse"
local libssh2 = require "libssh2"
description = [[
Returns authenication methods a ssh server supports.
]]
---
-- @usage
-- nmap -p 22 --script ssh-auth-methods --script-args="ssh.user=<username>" <target>
--
-- @output
-- 22/tcp open ssh syn-ack
-- | ssh-auth-methods:
-- | Supported authentication methods:
-- | publickey
-- |_ password
author = "Devin Bjelland"
license = "Same as Nmap--See http://nmap.org/book/man-legal.html"
local username = stdnse.get_script_args("ssh.user") or stdnse.generate_random_string(5)
portrule = shortport.port_or_service(22, 'ssh')
action = function (host, port)
local result = stdnse.output_table()
local session = libssh2.session_open(host, port.number)
local authmethods = libssh2.userauth_list(session, username)
result["Supported authentication methods"] = authmethods
return result
end