Files
kube-hunter/modules/discovery/dashboard.py
daniel_sagi 36e87807e6 1. completely transferred all event types to their corresponding module
2. started working on results table.
3. *added convention* from now on, every vulnerability/service event, should have a __doc__ that describes them. notice the new get_name(), component, and explain() attributes that needs to be implemented as well.
2018-06-10 16:43:05 +03:00

33 lines
1017 B
Python

import json
import requests
from ..events import handler
from ..events.types import Event, Service, OpenPortEvent
from ..types import Hunter
class KubeDashboardEvent(Service, Event):
"""Allows multiple arbitrary operations on the cluster from all connections"""
def __init__(self, path="/", secure=False):
self.path = path
self.secure
Service.__init__(self, name="Kubernetes Dashboard")
@handler.subscribe(OpenPortEvent, predicate=lambda x: x.port == 30000)
class KubeDashboard(Hunter):
def __init__(self, event):
self.event = event
self.host = event.host
self.port = event.port
@property
def secure(self):
default = json.loads(requests.get("http://{}:{}/api/v1/service/default".format(self.host, self.port)).text)
if "errors" in default and len(default["errors"]) == 0:
return False
return False
def execute(self):
if not self.secure:
self.publish_event(KubeDashboardEvent())