-
Notifications
You must be signed in to change notification settings - Fork 3
/
951-winrm-auth-methods.nse
57 lines (48 loc) · 1.58 KB
/
951-winrm-auth-methods.nse
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
local http = require "http"
local shortport = require "shortport"
local stdnse = require "stdnse"
local string = require "string"
local table = require "table"
description = [[
Returns authentication methods a winrm server supports.
]]
---
-- @usage
-- nmap --script winrm-auth-methods -p 5985 <target>
--
-- @output
-- 5985/tcp open wsman
-- | winrm-auth-methods:
-- | Accepted Authentication Methods:
-- | Negotiate
-- | Basic
-- | Kerberos
-- |_ CredSSP
author = "Evangelos Deirmentzoglou"
license = "Same as Nmap--See https://nmap.org/book/man-legal.html"
categories = {"default", "discovery", "safe"}
portrule = shortport.port_or_service({5985, 5986},{'wsman','wsmans'})
action = function(host, port)
local r = {}
local result = stdnse.output_table()
local url = "/wsman"
local response = http.post( host, port, url, nil, nil, stdnse.generate_random_string(5) )
if response.header["www-authenticate"] and string.match(response.header["www-authenticate"], "Negotiate") then
table.insert(r, "Negotiate")
end
if response.header["www-authenticate"] and string.match(response.header["www-authenticate"], "Basic") then
table.insert(r, "Basic")
end
if response.header["www-authenticate"] and string.match(response.header["www-authenticate"], "Kerberos") then
table.insert(r, "Kerberos")
end
if response.header["www-authenticate"] and string.match(response.header["www-authenticate"], "CredSSP") then
table.insert(r, "CredSSP")
end
if #r > 0 then
result = r
else
result = "Server does not support authentication."
end
return result
end