diff --git a/nxc/modules/handlekatz.py b/nxc/modules/handlekatz.py index d0974d96..bcca6fec 100644 --- a/nxc/modules/handlekatz.py +++ b/nxc/modules/handlekatz.py @@ -57,7 +57,7 @@ class NXCModule: try: with open(handlekatz_loc, "wb") as handlekatz: handlekatz.write(self.handlekatz_embeded) - except FileNotFoundError as e: + except FileNotFoundError: context.log.fail(f"Handlekatz file specified '{handlekatz_loc}' does not exist!") sys.exit(1) diff --git a/nxc/modules/impersonate.py b/nxc/modules/impersonate.py index 3adac7aa..e6e8664d 100644 --- a/nxc/modules/impersonate.py +++ b/nxc/modules/impersonate.py @@ -52,7 +52,7 @@ class NXCModule: try: with open(file_to_upload, "wb") as impersonate: impersonate.write(self.impersonate_embedded) - except FileNotFoundError as e: + except FileNotFoundError: context.log.fail(f"Impersonate file specified '{file_to_upload}' does not exist!") sys.exit(1) else: diff --git a/nxc/modules/ms17-010.py b/nxc/modules/ms17-010.py index 32c46673..ac5020ca 100644 --- a/nxc/modules/ms17-010.py +++ b/nxc/modules/ms17-010.py @@ -396,7 +396,7 @@ def check(ip, port=445): raw_proto = session_setup_andx_request() client.send(raw_proto) tcp_response = client.recv(buffersize) - netbios = tcp_response[:4] + tcp_response[:4] smb_header = tcp_response[4:36] smb = SmbHeader(smb_header) @@ -404,14 +404,14 @@ def check(ip, port=445): # Extract native OS from session setup response session_setup_andx_response = tcp_response[36:] - native_os = session_setup_andx_response[9:].split("\x00")[0] + session_setup_andx_response[9:].split("\x00")[0] # Send tree connect request and receive response raw_proto = tree_connect_andx_request(ip, user_id) client.send(raw_proto) tcp_response = client.recv(buffersize) - netbios = tcp_response[:4] + tcp_response[:4] smb_header = tcp_response[4:36] smb = SmbHeader(smb_header) @@ -425,7 +425,7 @@ def check(ip, port=445): client.send(raw_proto) tcp_response = client.recv(buffersize) - netbios = tcp_response[:4] + tcp_response[:4] smb_header = tcp_response[4:36] smb = SmbHeader(smb_header) diff --git a/nxc/modules/msol.py b/nxc/modules/msol.py index 1a5064e6..0daa3e6e 100644 --- a/nxc/modules/msol.py +++ b/nxc/modules/msol.py @@ -54,7 +54,7 @@ class NXCModule: try: with open(file_to_upload, "w") as msol: msol.write(self.msol_embedded) - except FileNotFoundError as e: + except FileNotFoundError: context.log.fail(f"Impersonate file specified '{file_to_upload}' does not exist!") sys.exit(1) diff --git a/nxc/protocols/ldap.py b/nxc/protocols/ldap.py index 13df8e29..530962a6 100644 --- a/nxc/protocols/ldap.py +++ b/nxc/protocols/ldap.py @@ -745,7 +745,7 @@ class ldap(connection): if e.getErrorString().find("sizeLimitExceeded") >= 0: # We should never reach this code as we use paged search now self.logger.fail("sizeLimitExceeded exception caught, giving up and processing the data received") - resp = e.getAnswers() + e.getAnswers() else: self.logger.fail(e) return False diff --git a/nxc/protocols/smb/smbexec.py b/nxc/protocols/smb/smbexec.py index 17999b64..d00211ee 100755 --- a/nxc/protocols/smb/smbexec.py +++ b/nxc/protocols/smb/smbexec.py @@ -130,7 +130,7 @@ class SMBEXEC: self.logger.debug(f"Remote service {self.__serviceName} deleted.") scmr.hRDeleteService(self.__scmr, service) scmr.hRCloseServiceHandle(self.__scmr, service) - except Exception as e: + except Exception: pass self.get_output_remote() diff --git a/nxc/protocols/smb/smbspider.py b/nxc/protocols/smb/smbspider.py index cb8f571c..e1c42537 100755 --- a/nxc/protocols/smb/smbspider.py +++ b/nxc/protocols/smb/smbspider.py @@ -227,7 +227,6 @@ class SMBSpider: traceback.print_exc() def get_lastm_time(self, result_obj): - lastm_time = None with contextlib.suppress(Exception): return strftime("%Y-%m-%d %H:%M", localtime(result_obj.get_mtime_epoch())) diff --git a/nxc/protocols/winrm.py b/nxc/protocols/winrm.py index 7e908582..ca0baa3f 100644 --- a/nxc/protocols/winrm.py +++ b/nxc/protocols/winrm.py @@ -192,7 +192,7 @@ class winrm(connection): for url in endpoints: try: self.logger.debug(f"Requesting URL: {url}") - res = requests.post(url, verify=False, timeout=self.args.http_timeout) + requests.post(url, verify=False, timeout=self.args.http_timeout) self.logger.debug("Received response code: {res.status_code}") self.endpoint = url if self.endpoint.startswith("https://"): diff --git a/pyproject.toml b/pyproject.toml index d4a8e565..ecc06fa9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -82,7 +82,7 @@ build-backend = "poetry.core.masonry.api" # Other options: pep8-naming (N), flake8-annotations (ANN), flake8-blind-except (BLE), flake8-commas (COM), flake8-pyi (PYI), flake8-pytest-style (PT), flake8-unused-arguments (ARG), etc # Should tackle flake8-use-pathlib (PTH) at some point select = ["E", "F", "D", "UP", "YTT", "ASYNC", "B", "A", "C4", "ISC", "ICN", "PIE", "PT", "Q", "RSE", "RET", "SIM", "TID", "ERA", "FLY", "PERF"] -ignore = [ "E501", "F405", "F841", "D100", "D101", "D102", "D103", "D104", "D105", "D106", "D107", "D203", "D204", "D205", "D212", "D213", "D400", "D401", "D415", "D417", "D419", "RET505", "RET506", "RET507", "RET508", "PERF203"] +ignore = [ "E501", "F405", "D100", "D101", "D102", "D103", "D104", "D105", "D106", "D107", "D203", "D204", "D205", "D212", "D213", "D400", "D401", "D415", "D417", "D419", "RET505", "RET506", "RET507", "RET508", "PERF203"] # Allow autofix for all enabled rules (when `--fix`) is provided. fixable = ["ALL"]