diff --git a/.gitignore b/.gitignore index 7e99e36..64bf867 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -*.pyc \ No newline at end of file +*.pyc +Dockerfile \ No newline at end of file diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index a41d5dc..0000000 --- a/Dockerfile +++ /dev/null @@ -1,12 +0,0 @@ -FROM python:2.7.15-jessie - -WORKDIR /usr/src/kube-hunter - -RUN apt-get update && apt-get install -y tcpdump - -COPY requirements.txt ./ -RUN pip install --no-cache-dir -r requirements.txt - -COPY . . - -ENTRYPOINT ["python", "kube-hunter.py"] \ No newline at end of file diff --git a/kube-hunter.py b/kube-hunter.py index 7cbee62..06b89b5 100644 --- a/kube-hunter.py +++ b/kube-hunter.py @@ -7,6 +7,7 @@ import time parser = argparse.ArgumentParser(description='Kube-Hunter, Hunter for weak Kubernetes cluster') parser.add_argument('--pod', action="store_true", help="set hunter as an insider pod") +parser.add_argument('--cidr', type=str, help="set manual cidr to scan, example: 192.168.0.0/16") parser.add_argument('--quick', action="store_true", help="scanning only known small sections of the subnet") parser.add_argument('--remote', nargs='+', metavar="HOST", default=list(), help="one or more remote ip/dns to hunt") parser.add_argument('--active', action="store_true", help="enables active hunting") @@ -35,6 +36,8 @@ def main(): handler.free() logging.debug("Cleaned Queue") log.print_results() + if config.pod: + while True: time.sleep(5) if __name__ == '__main__': main() diff --git a/src/modules/discovery/hosts.py b/src/modules/discovery/hosts.py index f0fffce..d0b922a 100644 --- a/src/modules/discovery/hosts.py +++ b/src/modules/discovery/hosts.py @@ -50,7 +50,15 @@ class HostDiscovery(Hunter): def execute(self): logging.info("Discovering Open Kubernetes Services...") - if config.pod: + if config.cidr: + try: + ip, sn = config.cidr.split('/') + cloud = self.get_cloud(ip) + for ip in self.generate_subnet(ip, sn=sn): + self.publish_event(NewHostEvent(host=ip, cloud=cloud)) + except: + logging.error("unable to parse cidr") + elif config.pod: if self.is_azure_pod(): self.azure_metadata_discovery() else: