diff --git a/monkey/common/utils/mongo_utils.py b/monkey/common/utils/mongo_utils.py index 66f606473..6d784d7ac 100644 --- a/monkey/common/utils/mongo_utils.py +++ b/monkey/common/utils/mongo_utils.py @@ -37,12 +37,12 @@ class MongoUtils: # ISWbemObjectEx interface. Class Uint8Array ? if str(o._oleobj_.GetTypeInfo().GetTypeAttr().iid) == "{269AD56A-8A67-4129-BC8C-0506DCFE9880}": return o.Value - except: + except Exception: pass try: return o.GetObjectText_() - except: + except Exception: pass return repr(o) diff --git a/monkey/infection_monkey/exploit/smbexec.py b/monkey/infection_monkey/exploit/smbexec.py index a9776136b..193b81ecf 100644 --- a/monkey/infection_monkey/exploit/smbexec.py +++ b/monkey/infection_monkey/exploit/smbexec.py @@ -148,7 +148,7 @@ class SmbExploiter(HostExploiter): try: scmr.hRStartServiceW(scmr_rpc, service) status = ScanStatus.USED - except: + except Exception: status = ScanStatus.SCANNED pass T1035Telem(status, UsageEnum.SMB).send() diff --git a/monkey/infection_monkey/exploit/tools/smb_tools.py b/monkey/infection_monkey/exploit/tools/smb_tools.py index e5185b266..a68d52471 100644 --- a/monkey/infection_monkey/exploit/tools/smb_tools.py +++ b/monkey/infection_monkey/exploit/tools/smb_tools.py @@ -42,7 +42,7 @@ class SmbTools(object): try: smb.logoff() - except: + except Exception: pass return None @@ -134,7 +134,7 @@ class SmbTools(object): return remote_full_path LOG.debug("Remote monkey file is found but different, moving along with attack") - except: + except Exception: pass # file isn't found on remote victim, moving on try: @@ -163,7 +163,7 @@ class SmbTools(object): finally: try: smb.logoff() - except: + except Exception: pass smb = None diff --git a/monkey/infection_monkey/exploit/tools/wmi_tools.py b/monkey/infection_monkey/exploit/tools/wmi_tools.py index e1e002d72..f62190076 100644 --- a/monkey/infection_monkey/exploit/tools/wmi_tools.py +++ b/monkey/infection_monkey/exploit/tools/wmi_tools.py @@ -58,7 +58,7 @@ class WmiTools(object): try: self._iWbemServices = iWbemLevel1Login.NTLMLogin('//./root/cimv2', NULL, NULL) self._dcom = dcom - except: + except Exception: dcom.disconnect() raise diff --git a/monkey/infection_monkey/network/firewall.py b/monkey/infection_monkey/network/firewall.py index a88427650..85191551f 100644 --- a/monkey/infection_monkey/network/firewall.py +++ b/monkey/infection_monkey/network/firewall.py @@ -46,7 +46,7 @@ class WinAdvFirewall(FirewallApp): state = l.split()[-1].strip() return state == "ON" - except: + except Exception: return None def add_firewall_rule(self, name="Firewall", direction="in", action="allow", program=sys.executable, **kwargs): @@ -61,7 +61,7 @@ class WinAdvFirewall(FirewallApp): return True else: return False - except: + except Exception: return None def remove_firewall_rule(self, name="Firewall", **kwargs): @@ -75,7 +75,7 @@ class WinAdvFirewall(FirewallApp): return True else: return False - except: + except Exception: return None def listen_allowed(self, **kwargs): @@ -94,7 +94,7 @@ class WinAdvFirewall(FirewallApp): try: for rule in list(self._rules.keys()): self.remove_firewall_rule(name=rule) - except: + except Exception: pass @@ -114,7 +114,7 @@ class WinFirewall(FirewallApp): return False return state == "Enable" - except: + except Exception: return None def add_firewall_rule(self, rule='allowedprogram', name="Firewall", mode="ENABLE", program=sys.executable, @@ -131,7 +131,7 @@ class WinFirewall(FirewallApp): return True else: return False - except: + except Exception: return None def remove_firewall_rule(self, rule='allowedprogram', name="Firewall", mode="ENABLE", program=sys.executable, @@ -145,7 +145,7 @@ class WinFirewall(FirewallApp): return True else: return False - except: + except Exception: return None def listen_allowed(self, **kwargs): @@ -161,14 +161,14 @@ class WinFirewall(FirewallApp): try: for rule in list(self._rules.values()): self.remove_firewall_rule(**rule) - except: + except Exception: pass if sys.platform == "win32": try: win_ver = int(platform.version().split('.')[0]) - except: + except Exception: win_ver = 0 if win_ver > 5: app = WinAdvFirewall() diff --git a/monkey/infection_monkey/transport/http.py b/monkey/infection_monkey/transport/http.py index 1502e844c..e2ed053af 100644 --- a/monkey/infection_monkey/transport/http.py +++ b/monkey/infection_monkey/transport/http.py @@ -47,7 +47,7 @@ class FileServHTTPRequestHandler(http.server.BaseHTTPRequestHandler): chunk = end_range - start_range try: self.wfile.write(f.read(chunk)) - except: + except Exception: break total += chunk start_range += chunk diff --git a/monkey/infection_monkey/transport/tcp.py b/monkey/infection_monkey/transport/tcp.py index 329ef1875..dac2a0938 100644 --- a/monkey/infection_monkey/transport/tcp.py +++ b/monkey/infection_monkey/transport/tcp.py @@ -32,13 +32,13 @@ class SocketsPipe(Thread): other = self.dest if r is self.source else self.source try: data = r.recv(READ_BUFFER_SIZE) - except: + except Exception: break if data: try: other.sendall(data) update_last_serve_time() - except: + except Exception: break self._keep_connection = True