mirror of
https://github.com/aquasecurity/kube-hunter.git
synced 2026-05-11 19:57:03 +00:00
Added .gitignore file, ignoring .pyc files,
Also changed modules structure
This commit is contained in:
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
*.pyc
|
||||
6
discovery/__init__.py
Normal file
6
discovery/__init__.py
Normal file
@@ -0,0 +1,6 @@
|
||||
from .dashboard import KubeDashboard
|
||||
from .ports import PortDiscovery
|
||||
from .hosts import HostDiscovery
|
||||
|
||||
__all__ = [HostDiscovery, KubeDashboard, PortDiscovery]
|
||||
|
||||
16
discovery/dashboard.py
Normal file
16
discovery/dashboard.py
Normal file
@@ -0,0 +1,16 @@
|
||||
import events
|
||||
import requests
|
||||
|
||||
class KubeDashboard(object):
|
||||
def __init__(self, task):
|
||||
self.task = task
|
||||
self.host = task['host']
|
||||
self.port = task['port'] or 80
|
||||
pass
|
||||
|
||||
def execute(self):
|
||||
# TODO: insert logic for detremining dashboard/insecure dashboard is there
|
||||
events.handler.publish_event('KUBE_DASHBOARD', {'host': self.host, 'port': self.port})
|
||||
|
||||
|
||||
events.handler.subscribe_event('OPEN_PORT_30000', KubeDashboard)
|
||||
@@ -1,8 +1,8 @@
|
||||
from socket import socket
|
||||
import events
|
||||
|
||||
default_ports = [8001, 10250, 10255, 30000]
|
||||
|
||||
default_ports = [8001, 10250, 10255, 30000]
|
||||
|
||||
class PortDiscovery(object):
|
||||
def __init__(self, task):
|
||||
@@ -11,9 +11,7 @@ class PortDiscovery(object):
|
||||
def execute(self):
|
||||
for single_port in default_ports:
|
||||
if self.test_connection(self.host, single_port):
|
||||
events.handler.publish_event('OPEN_PORT', {'host': self.host, 'port': single_port})
|
||||
events.handler.publish_event('OPEN_PORT_{port}'.format(port=single_port),
|
||||
{'host': self.host, 'port': single_port})
|
||||
events.handler.publish_event('OPEN_PORT_{port}'.format(port=single_port), {'host': self.host, 'port': single_port})
|
||||
|
||||
@staticmethod
|
||||
def test_connection(host, port):
|
||||
@@ -16,8 +16,8 @@ class EventQueue(Queue, object):
|
||||
t.start()
|
||||
|
||||
def publish_event(self, name, item):
|
||||
safe_print('Event {} got published with {}'.format(name, item))
|
||||
if name in self.hooks:
|
||||
safe_print('Event {} got published with {}'.format(name, item))
|
||||
for single_hook in self.hooks[name]:
|
||||
self.put(single_hook(item))
|
||||
|
||||
|
||||
BIN
events.pyc
BIN
events.pyc
Binary file not shown.
4
hunting/__init__.py
Normal file
4
hunting/__init__.py
Normal file
@@ -0,0 +1,4 @@
|
||||
from .dashboard import KubeDashboard
|
||||
|
||||
__all__ = [KubeDashboard]
|
||||
|
||||
29
hunting/dashboard.py
Normal file
29
hunting/dashboard.py
Normal file
@@ -0,0 +1,29 @@
|
||||
import events
|
||||
import requests
|
||||
from events import safe_print
|
||||
|
||||
class KubeDashboard(object):
|
||||
def __init__(self, task):
|
||||
self.host = task['host']
|
||||
self.port = task['port'] or 30000
|
||||
|
||||
def execute(self):
|
||||
print("KUBEDASHBOARD At: {} {}".format(self.host, self.port))
|
||||
if self.secured:
|
||||
safe_print("SECURED DASHBOARD")
|
||||
else:
|
||||
safe_print("INSECURE DASHBOARD")
|
||||
|
||||
@property
|
||||
def secured(self):
|
||||
try:
|
||||
r = requests.get("http://{host}:{port}/api/v1/node?itemsPerPage=100".format(host=self.host, port=self.port))
|
||||
except requests.exceptions.ConnectionError:
|
||||
return True
|
||||
|
||||
ret = r.json()
|
||||
if 'listMeta' in ret:
|
||||
return False
|
||||
return True
|
||||
|
||||
events.handler.subscribe_event('KUBE_DASHBOARD', KubeDashboard)
|
||||
@@ -1,11 +1,12 @@
|
||||
import modules
|
||||
import discovery
|
||||
import hunting
|
||||
import threading
|
||||
import time
|
||||
import sys
|
||||
|
||||
def main():
|
||||
try:
|
||||
modules.HostDiscovery({}).execute()
|
||||
discovery.HostDiscovery({}).execute()
|
||||
# Blocking to see discovery output
|
||||
while(True):
|
||||
time.sleep(1)
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
from .kube_open_dashboard import KubeOpenDashboard
|
||||
from .port_discovery import PortDiscovery
|
||||
from .host_discovery import HostDiscovery
|
||||
|
||||
__all__ = [HostDiscovery, KubeOpenDashboard, PortDiscovery]
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,29 +0,0 @@
|
||||
import events
|
||||
import requests
|
||||
|
||||
class KubeOpenDashboard(object):
|
||||
def __init__(self, task):
|
||||
self.task = task
|
||||
self.host = task['host']
|
||||
self.port = task['port'] or 80
|
||||
pass
|
||||
|
||||
def execute(self):
|
||||
try:
|
||||
r = requests.get("http://{host}:{port}/api/v1/node?itemsPerPage=100".format(host=self.host, port=self.port))
|
||||
except requests.exceptions.ConnectionError:
|
||||
return None
|
||||
|
||||
ret = r.json()
|
||||
if 'listMeta' in ret:
|
||||
events.safe_print("KubeOpenDashboard :: Open Dashboard!", self.host)
|
||||
|
||||
|
||||
events.handler.subscribe_event('OPEN_PORT_30000', KubeOpenDashboard)
|
||||
|
||||
if __name__ == "__main__":
|
||||
queue = list()
|
||||
queue.append(KubeOpenDashboard({'host': '192.168.1.117', 'port': 30000}))
|
||||
queue.append(KubeOpenDashboard({'host': '192.168.1.117', 'port': None}))
|
||||
for i in queue:
|
||||
i.execute()
|
||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user