From 086a403559459869b7e549e65dd35839febb4ba0 Mon Sep 17 00:00:00 2001 From: oriagmon Date: Tue, 16 Oct 2018 17:03:57 +0300 Subject: [PATCH] locked variables --- kube-hunter.py | 12 +++++++++--- src/core/events/types/common.py | 10 ++++++++-- src/modules/report/collector.py | 3 +++ 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/kube-hunter.py b/kube-hunter.py index 10932d5..77fa06c 100755 --- a/kube-hunter.py +++ b/kube-hunter.py @@ -91,7 +91,7 @@ def list_hunters(): print("* {}\n {}\n".format( name, docs)) -tlock3 = threading.Lock +tlock3 = threading.Lock() tlock3.acquire() hunt_started = False tlock3.release() @@ -112,7 +112,7 @@ def main(): if not any(scan_options): if not interactive_set_config(): return - tlock = threading.Lock + tlock = threading.Lock() tlock.acquire() hunt_started = True tlock.release() @@ -138,4 +138,10 @@ def main(): if __name__ == '__main__': - main() + for i in range(6): + try: + main() + except: + import traceback + print ('\n\n\n\n\n\n\n\n\n') + traceback.print_exc() diff --git a/src/core/events/types/common.py b/src/core/events/types/common.py index 74c5c88..d19dc2f 100644 --- a/src/core/events/types/common.py +++ b/src/core/events/types/common.py @@ -65,8 +65,11 @@ class Vulnerability(object): def explain(self): return self.__doc__ - +tlock1 = threading.Lock() +tlock1.acquire() event_id_count = 0 +tlock1.release() + """ Discovery/Hunting Events """ @@ -74,9 +77,12 @@ class NewHostEvent(Event): def __init__(self, host, cloud=None): global event_id_count self.host = host - self.event_id = event_id_count self.cloud = cloud + tlock = threading.Lock() + tlock.acquire() + self.event_id = event_id_count event_id_count += 1 + tlock.release() def __str__(self): return str(self.host) diff --git a/src/modules/report/collector.py b/src/modules/report/collector.py index db6b77f..fa50cb0 100644 --- a/src/modules/report/collector.py +++ b/src/modules/report/collector.py @@ -38,6 +38,8 @@ class Collector(object): def execute(self): """function is called only when collecting data""" + tlock = threading.Lock() + tlock.acquire() global services, vulnerabilities bases = self.event.__class__.__mro__ if Service in bases: @@ -59,6 +61,7 @@ class Collector(object): port=self.event.port, desc=wrap_last_line(console_trim(self.event.explain(), '| ')) )) + tlock.release() class TablesPrinted(Event):