Files
kube-hunter/discovery/proxy.py
daniel_sagi 290f87de70 1. added log/
2. Started adding kubelet scanning.
3. Changed events architecture. All events are inheriting from "Event" class. when instantiating and defining a new event class, attributes other than what is important for that perticular event are not needed. the event handler will be stacking the events, so that each event will have all the attributes of its successors.
This proccess is invisible to the developer, but needs to be acknowledged.
*note: from now on, all executors needs to set self.event to given arg on init*
Example (pseudo):

@subscribe(NewHostEvent)
def PortScan(event):
		publish(OpenPortEvent(port="8080"))

@subscribe(OpenPortEvent)
def print(event):
		print(event.host)

publish(NewHostEvent(host="0.0.0.0"))
>> output: 0.0.0.0

the print function recieves an open port event. even though when publishing the OpenPortEvent we did not specify a host, the print function can access the "host" attribute, as the OpenPortEvent successor was NewHostEvent. if "host" was not defined on the succesors, it is "None"
2018-05-24 15:39:31 +03:00

20 lines
541 B
Python

from events import handler, OpenPortEvent, KubeProxyEvent
from collections import defaultdict
from requests import get
import logging
@handler.subscribe(OpenPortEvent, predicate=lambda x: x.port == 8001)
class KubeProxy(object):
def __init__(self, event):
self.event = event
self.host = event.host
self.port = event.port or 8001
@property
def accesible(self):
return True
def execute(self):
if self.accesible:
handler.publish_event(KubeProxyEvent())