mirror of
https://github.com/aquasecurity/kube-hunter.git
synced 2026-05-21 16:45:05 +00:00
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.
33 lines
1017 B
Python
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())
|