diff --git a/kube-hunter.py b/kube-hunter.py index 1b4fecd..7f91fe4 100644 --- a/kube-hunter.py +++ b/kube-hunter.py @@ -19,10 +19,10 @@ logging.basicConfig(level=loglevel, format='%(asctime)s - [%(levelname)s]: %(mes import log # executes all registrations from sub packages -import modules -from modules.discovery import HostDiscovery -from modules.events import handler -from modules.discovery.hosts import HostScanEvent +import src.modules +from src.modules.discovery import HostDiscovery +from src.core.events import handler +from src.modules.discovery.hosts import HostScanEvent def main(): logging.info("Started") diff --git a/log/reporter.py b/log/reporter.py index e530437..0856f8b 100644 --- a/log/reporter.py +++ b/log/reporter.py @@ -1,8 +1,8 @@ import logging from prettytable import PrettyTable -from modules.events import handler -from modules.events.types import Vulnerability, Information, Service -from modules.discovery.kubelet import KubeletExposedHandler +from src.core.events import handler +from src.core.events.types import Vulnerability, Information, Service +from src.modules.discovery.kubelet import KubeletExposedHandler services = list() vulnerabilities = list() diff --git a/modules/__init__.py b/modules/__init__.py deleted file mode 100644 index 172cc6b..0000000 --- a/modules/__init__.py +++ /dev/null @@ -1,4 +0,0 @@ -import discovery -import hunting -import events -import types \ No newline at end of file diff --git a/src/__init__.py b/src/__init__.py new file mode 100644 index 0000000..d96bb8d --- /dev/null +++ b/src/__init__.py @@ -0,0 +1,2 @@ +import core +import modules \ No newline at end of file diff --git a/src/core/__init__.py b/src/core/__init__.py new file mode 100644 index 0000000..979a6f5 --- /dev/null +++ b/src/core/__init__.py @@ -0,0 +1,2 @@ +from events import * +from types import * \ No newline at end of file diff --git a/modules/events/__init__.py b/src/core/events/__init__.py similarity index 100% rename from modules/events/__init__.py rename to src/core/events/__init__.py diff --git a/modules/events/handler.py b/src/core/events/handler.py similarity index 100% rename from modules/events/handler.py rename to src/core/events/handler.py diff --git a/modules/events/types/__init__.py b/src/core/events/types/__init__.py similarity index 100% rename from modules/events/types/__init__.py rename to src/core/events/types/__init__.py diff --git a/modules/events/types/common.py b/src/core/events/types/common.py similarity index 100% rename from modules/events/types/common.py rename to src/core/events/types/common.py diff --git a/modules/types/__init__.py b/src/core/types/__init__.py similarity index 100% rename from modules/types/__init__.py rename to src/core/types/__init__.py diff --git a/modules/types/defaults.py b/src/core/types/defaults.py similarity index 80% rename from modules/types/defaults.py rename to src/core/types/defaults.py index 8475622..5cb988a 100644 --- a/modules/types/defaults.py +++ b/src/core/types/defaults.py @@ -1,4 +1,4 @@ -from ..events import handler +from ...core.events import handler class Hunter(object): def __init__(self): diff --git a/src/modules/__init__.py b/src/modules/__init__.py new file mode 100644 index 0000000..647c3e4 --- /dev/null +++ b/src/modules/__init__.py @@ -0,0 +1,2 @@ +import discovery +import hunting \ No newline at end of file diff --git a/modules/discovery/__init__.py b/src/modules/discovery/__init__.py similarity index 100% rename from modules/discovery/__init__.py rename to src/modules/discovery/__init__.py diff --git a/modules/discovery/dashboard.py b/src/modules/discovery/dashboard.py similarity index 86% rename from modules/discovery/dashboard.py rename to src/modules/discovery/dashboard.py index 28fef2b..a55012b 100644 --- a/modules/discovery/dashboard.py +++ b/src/modules/discovery/dashboard.py @@ -2,9 +2,9 @@ import json import requests -from ..events import handler -from ..events.types import Event, Service, OpenPortEvent -from ..types import Hunter +from ...core.events import handler +from ...core.events.types import Event, Service, OpenPortEvent +from ...core.types import Hunter class KubeDashboardEvent(Service, Event): """Allows multiple arbitrary operations on the cluster from all connections""" diff --git a/modules/discovery/hosts.py b/src/modules/discovery/hosts.py similarity index 96% rename from modules/discovery/hosts.py rename to src/modules/discovery/hosts.py index b4f5526..e66e732 100644 --- a/modules/discovery/hosts.py +++ b/src/modules/discovery/hosts.py @@ -8,9 +8,9 @@ import requests from netaddr import IPNetwork from netifaces import AF_INET, ifaddresses, interfaces -from ..events import handler -from ..events.types import Event, NewHostEvent -from ..types import Hunter +from ...core.events import handler +from ...core.events.types import Event, NewHostEvent +from ...core.types import Hunter class HostScanEvent(Event): def __init__(self, pod=False, active=False, predefined_hosts=list()): diff --git a/modules/discovery/kubelet.py b/src/modules/discovery/kubelet.py similarity index 95% rename from modules/discovery/kubelet.py rename to src/modules/discovery/kubelet.py index 2ed8127..6b64a15 100644 --- a/modules/discovery/kubelet.py +++ b/src/modules/discovery/kubelet.py @@ -1,13 +1,13 @@ import json import logging from enum import Enum -from ..types import Hunter +from ...core.types import Hunter import requests import urllib3 -from ..events import handler -from ..events.types import OpenPortEvent, Kubelet, Vulnerability, Event, Service +from ...core.events import handler +from ...core.events.types import OpenPortEvent, Kubelet, Vulnerability, Event, Service urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) """ Services """ diff --git a/modules/discovery/ports.py b/src/modules/discovery/ports.py similarity index 85% rename from modules/discovery/ports.py rename to src/modules/discovery/ports.py index 1ae72a6..b575dbd 100644 --- a/modules/discovery/ports.py +++ b/src/modules/discovery/ports.py @@ -1,8 +1,8 @@ from socket import socket -from ..types import Hunter +from ...core.types import Hunter -from ..events import handler -from ..events.types import NewHostEvent, OpenPortEvent +from ...core.events import handler +from ...core.events.types import NewHostEvent, OpenPortEvent default_ports = [8001, 10250, 10255, 30000] diff --git a/modules/discovery/proxy.py b/src/modules/discovery/proxy.py similarity index 83% rename from modules/discovery/proxy.py rename to src/modules/discovery/proxy.py index eed83fa..c94e5dd 100644 --- a/modules/discovery/proxy.py +++ b/src/modules/discovery/proxy.py @@ -1,11 +1,11 @@ import logging from collections import defaultdict -from ..types import Hunter +from ...core.types import Hunter from requests import get -from ..events import handler -from ..events.types import Service, Event, OpenPortEvent +from ...core.events import handler +from ...core.events.types import Service, Event, OpenPortEvent class KubeProxyEvent(Event, Service): """proxies from a localhost address to the Kubernetes apiserver""" diff --git a/modules/hunting/__init__.py b/src/modules/hunting/__init__.py similarity index 100% rename from modules/hunting/__init__.py rename to src/modules/hunting/__init__.py diff --git a/modules/hunting/dashboard.py b/src/modules/hunting/dashboard.py similarity index 81% rename from modules/hunting/dashboard.py rename to src/modules/hunting/dashboard.py index fb5c246..dc9bbe6 100644 --- a/modules/hunting/dashboard.py +++ b/src/modules/hunting/dashboard.py @@ -1,9 +1,9 @@ import logging -from ..types import Hunter +from ...core.types import Hunter import requests -from ..events import handler +from ...core.events import handler from ..discovery.dashboard import KubeDashboardEvent @handler.subscribe(KubeDashboardEvent) diff --git a/modules/hunting/kubelet.py b/src/modules/hunting/kubelet.py similarity index 98% rename from modules/hunting/kubelet.py rename to src/modules/hunting/kubelet.py index 8bcb802..84a5273 100644 --- a/modules/hunting/kubelet.py +++ b/src/modules/hunting/kubelet.py @@ -5,10 +5,10 @@ from enum import Enum import requests import urllib3 -from ..events import handler -from ..events.types import (KubernetesCluster, Kubelet, Vulnerability, Information, Event) +from ...core.events import handler +from ...core.events.types import (KubernetesCluster, Kubelet, Vulnerability, Information, Event) from ..discovery.kubelet import KubeletExposedHandler, ReadOnlyKubeletEvent, SecureKubeletEvent -from ..types import Hunter +from ...core.types import Hunter urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) diff --git a/modules/hunting/proxy.py b/src/modules/hunting/proxy.py similarity index 93% rename from modules/hunting/proxy.py rename to src/modules/hunting/proxy.py index 16a95bd..0808f88 100644 --- a/modules/hunting/proxy.py +++ b/src/modules/hunting/proxy.py @@ -5,9 +5,9 @@ from requests import get from ..discovery.dashboard import KubeDashboardEvent from ..discovery.proxy import KubeProxyEvent -from ..events import handler -from ..events.types import Vulnerability, Event, KubernetesCluster -from ..types import Hunter +from ...core.events import handler +from ...core.events.types import Vulnerability, Event, KubernetesCluster +from ...core.types import Hunter class Service(Enum):