-
Notifications
You must be signed in to change notification settings - Fork 1
/
kubernetes-version.nse
46 lines (39 loc) · 1.28 KB
/
kubernetes-version.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
local shortport = require "shortport"
local json = require "json"
local http = require "http"
local nmap = require "nmap"
description = [[Detects the Kubernetes service version.]]
---
-- @output
-- PORT STATE SERVICE VERSION
-- 8443/tcp open kubernetes Kubernetes 1.10
-- | Major: 1
-- | Minor: 10
-- | GitVersion: v1.10.0
-- | GitCommit: fc32d2f3698e36b93322a3465f63a14e9f0eaead
-- | GitTreeState: clean
-- | BuildDate: 2018-03-26T16:44:10Z
-- | GoVersion: go1.9.3
-- | Compiler: gc
-- | Platform: linux/amd64
author = "Jeremy Pruitt"
license = "Same as Nmap--See https://nmap.org/book/man-legal.html"
categories = {"version"}
portrule = shortport.version_port_or_service({6443,8443}, {"kubernetes"}, "tcp")
action = function(host, port)
local http_response = http.get(host, port, "/version")
if not http_response or not http_response.status or
http_response.status ~= 200 or not http_response.body then
return
end
local ok_json, response = json.parse(http_response.body)
if ok_json and response["gitVersion"] and response["goVersion"] then
---Detected
port.version.name = 'kubernetes'
port.version.version = response["gitVersion"]
port.version.product = "Kubernetes"
nmap.set_port_version(host, port)
return response
end
return
end