Overview
Imported from the upstream repository chinarulezzz/nmap-extra-nse. Attempts to detect the Kubernetes API version.
Attempts to detect the Kubernetes API version.
Ports
Any
Protocols
n/a
Attribution
Jon Mosco (upstream: chinarulezzz/nmap-extra-nse)
Copy the command and adjust the target or script arguments as needed.
nmap --script kubernetes-version <host> The full script source is stored with this entry and is hidden by default to keep the page easier to scan.
description = [[
Attempts to detect the Kubernetes API version.
]]
categories = {"safe", "version"}
author = "Jon Mosco"
license = "Same as Nmap--See https://nmap.org/book/man-legal.html"
---
-- @usage
-- nmap --script kubernetes-version <host>
-- @output
-- PORT STATE SERVICE VERSION
-- 8443/tcp open kubernetes-api
local shortport = require "shortport"
local json = require "json"
local http = require "http"
local nmap = require "nmap"
portrule = shortport.version_port_or_service({6443, 8443}, {"kubernetes", "kubernetes-api"}, "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["major"] and response["minor"] then
---Detected
port.version.name = 'kubernetes-api'
port.version.version = response["gitVersion"]
port.version.product = "Kubernetes"
nmap.set_port_version(host, port)
return response
end
return
end
Imported from the upstream repository chinarulezzz/nmap-extra-nse. Attempts to detect the Kubernetes API version.