diff --git a/infection_monkey/exploit/weblogic.py b/infection_monkey/exploit/weblogic.py index 4ea80c1d4..f8db585a5 100644 --- a/infection_monkey/exploit/weblogic.py +++ b/infection_monkey/exploit/weblogic.py @@ -24,8 +24,6 @@ SERVER_TIMEOUT = 4 REQUEST_TIMEOUT = 2 # How long to wait for response in exploitation EXECUTION_TIMEOUT = 15 -# Server might get response faster than it starts listening to it, we need a lock -LOCK = threading.Lock() URLS = ["/wls-wsat/CoordinatorPortType", "/wls-wsat/CoordinatorPortType11", "/wls-wsat/ParticipantPortType", @@ -133,13 +131,15 @@ class WebLogicExploiter(WebRCE): return def check_if_exploitable(self, url): + # Server might get response faster than it starts listening to it, we need a lock + lock = threading.Lock() local_port = get_free_tcp_port() local_ip = get_interface_to_target(self.host.ip_addr) httpd = WebLogicExploiter.HTTPServer(local_ip, local_port) httpd.daemon = True - LOCK.acquire() + lock.acquire() httpd.start() - LOCK.acquire() + lock.acquire() generic_check_payload = ''' @@ -164,7 +164,7 @@ class WebLogicExploiter(WebRCE): except Exception as e: LOG.error("Something went wrong: %s" % e) - LOCK.release() + lock.release() httpd.join(SERVER_TIMEOUT) httpd.stop() if httpd.get_requests > 0: