diff --git a/nxc/helpers/powershell.py b/nxc/helpers/powershell.py index 6b00712f..b8d226c7 100644 --- a/nxc/helpers/powershell.py +++ b/nxc/helpers/powershell.py @@ -128,9 +128,7 @@ def create_ps_command(ps_command, force_ps32=False, dont_obfs=False, custom_amsi """ if custom_amsi: with open(custom_amsi) as file_in: - lines = [] - for line in file_in: - lines.append(line) + lines = list(file_in) amsi_bypass = "".join(lines) else: amsi_bypass = """[Net.ServicePointManager]::ServerCertificateValidationCallback = {$true} diff --git a/nxc/loaders/moduleloader.py b/nxc/loaders/moduleloader.py index 8ba4f54c..49feabb1 100755 --- a/nxc/loaders/moduleloader.py +++ b/nxc/loaders/moduleloader.py @@ -129,5 +129,4 @@ class ModuleLoader: modules.update(module_data) except Exception as e: self.logger.debug(f"Error loading module {module}: {e}") - pass return modules diff --git a/nxc/modules/find-computer.py b/nxc/modules/find-computer.py index 565de7d4..9eb281af 100644 --- a/nxc/modules/find-computer.py +++ b/nxc/modules/find-computer.py @@ -45,7 +45,6 @@ class NXCModule: if e.getErrorString().find("sizeLimitExceeded") >= 0: context.log.debug("sizeLimitExceeded exception caught, giving up and processing the data received") resp = e.getAnswers() - pass else: nxc_logger.debug(e) return False @@ -68,7 +67,6 @@ class NXCModule: except Exception as e: context.log.debug("Exception:", exc_info=True) context.log.debug(f"Skipping item, cannot process due to error {e}") - pass if len(answers) > 0: context.log.success("Found the following computers: ") for answer in answers: diff --git a/nxc/modules/get-desc-users.py b/nxc/modules/get-desc-users.py index 5d3bfdd1..685e2405 100644 --- a/nxc/modules/get-desc-users.py +++ b/nxc/modules/get-desc-users.py @@ -53,7 +53,6 @@ class NXCModule: # We reached the sizeLimit, process the answers we have already and that's it. Until we implement # paged queries resp = e.getAnswers() - pass else: nxc_logger.debug(e) return False @@ -76,7 +75,6 @@ class NXCModule: except Exception as e: context.log.debug("Exception:", exc_info=True) context.log.debug(f"Skipping item, cannot process due to error {str(e)}") - pass answers = self.filter_answer(context, answers) if len(answers) > 0: context.log.success("Found following users: ") diff --git a/nxc/modules/group_members.py b/nxc/modules/group_members.py index 454bba71..104080ff 100644 --- a/nxc/modules/group_members.py +++ b/nxc/modules/group_members.py @@ -93,7 +93,6 @@ def do_search(self, context, connection, searchFilter, attributeName): except Exception as e: context.log.debug("Exception:", exc_info=True) context.log.debug(f"Skipping item, cannot process due to error {e}") - pass except Exception as e: context.log.debug(f"Exception: {e}") return False diff --git a/nxc/modules/groupmembership.py b/nxc/modules/groupmembership.py index 56502003..9867e605 100644 --- a/nxc/modules/groupmembership.py +++ b/nxc/modules/groupmembership.py @@ -50,7 +50,6 @@ class NXCModule: # We reached the sizeLimit, process the answers we have already and that's it. Until we implement # paged queries resp = e.getAnswers() - pass else: context.log.debug(e) return False @@ -79,7 +78,6 @@ class NXCModule: except Exception as e: context.log.debug("Exception:", exc_info=True) context.log.debug(f"Skipping item, cannot process due to error {str(e)}") - pass if len(memberOf) > 0: context.log.success(f"User: {self.user} is member of following groups: ") for group in memberOf: diff --git a/nxc/modules/hash_spider.py b/nxc/modules/hash_spider.py index aeb289ef..f56493a0 100644 --- a/nxc/modules/hash_spider.py +++ b/nxc/modules/hash_spider.py @@ -108,7 +108,7 @@ def process_creds(context, connection, credentials_data, dbconnection, cursor, d for path in paths: if path: - for _key, value in path.items(): + for value in path.values(): for item in value: if isinstance(item, dict): if {item["name"]} not in reported_da: diff --git a/nxc/modules/pso.py b/nxc/modules/pso.py index 340f40bb..e2614e6f 100644 --- a/nxc/modules/pso.py +++ b/nxc/modules/pso.py @@ -58,7 +58,6 @@ class NXCModule: # We reached the sizeLimit, process the answers we have already and that's it. Until we implement # paged queries resp = e.getAnswers() - pass else: context.log.debug(e) return False @@ -83,7 +82,6 @@ class NXCModule: except Exception as e: context.log.debug("Exception:", exc_info=True) context.log.debug(f"Skipping item, cannot process due to error {e}") - pass if len(pso_list) > 0: context.log.success("Password Settings Objects (PSO) found:") for pso in pso_list: diff --git a/nxc/modules/rdcman.py b/nxc/modules/rdcman.py index 280530b4..3b2bea02 100644 --- a/nxc/modules/rdcman.py +++ b/nxc/modules/rdcman.py @@ -67,7 +67,6 @@ class NXCModule: self.pvkbytes = backupkey.backupkey_v2 except Exception as e: context.log.debug(f"Could not get domain backupkey: {e}") - pass target = Target.create( domain=domain, diff --git a/nxc/modules/rdp.py b/nxc/modules/rdp.py index 1ae329b8..9c26ce96 100644 --- a/nxc/modules/rdp.py +++ b/nxc/modules/rdp.py @@ -95,7 +95,6 @@ class NXCModule: context.log.fail("System version under NT6 not support restricted admin mode") else: context.log.fail(str(e)) - pass else: try: wmi_rdp.rdp_wrapper(self.action, self.oldSystem) @@ -104,7 +103,6 @@ class NXCModule: context.log.fail("Looks like target system version is under NT6, please add 'OLD=true' in module options.") else: context.log.fail(str(e)) - pass wmi_rdp._rdp_WMI__dcom.disconnect() diff --git a/nxc/modules/scan-network.py b/nxc/modules/scan-network.py index 780422bb..a6ac73ad 100644 --- a/nxc/modules/scan-network.py +++ b/nxc/modules/scan-network.py @@ -133,7 +133,6 @@ class NXCModule: # We reached the sizeLimit, process the answers we have already and that's it. Until we implement # paged queries list_sites = e.getAnswers() - pass else: raise get_dns_resolver(connection.host, context.log) diff --git a/nxc/modules/spider_plus.py b/nxc/modules/spider_plus.py index ea20d83c..2cde2489 100755 --- a/nxc/modules/spider_plus.py +++ b/nxc/modules/spider_plus.py @@ -42,7 +42,6 @@ def make_dirs(path): except OSError as e: if e.errno != errno.EEXIST: raise - pass def get_list_from_option(opt): diff --git a/nxc/modules/trust.py b/nxc/modules/trust.py index e265a3bb..22be1159 100644 --- a/nxc/modules/trust.py +++ b/nxc/modules/trust.py @@ -77,7 +77,6 @@ class NXCModule: trusts.append((flat_name, trust_partner, trust_direction, trust_transitive)) except Exception as e: context.log.debug(f"Cannot process trust relationship due to error {e}") - pass if trusts: context.log.success("Found the following trust relationships:") diff --git a/nxc/protocols/ldap.py b/nxc/protocols/ldap.py index 19f30db1..13df8e29 100644 --- a/nxc/protocols/ldap.py +++ b/nxc/protocols/ldap.py @@ -267,7 +267,6 @@ class ldap(connection): except Exception as e: if "STATUS_NOT_SUPPORTED" in str(e): self.no_ntlm = True - pass if not self.no_ntlm: self.domain = self.conn.getServerDNSDomainName() self.hostname = self.conn.getServerName() @@ -747,7 +746,6 @@ class ldap(connection): # 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() - pass else: self.logger.fail(e) return False @@ -784,7 +782,6 @@ class ldap(connection): self.logger.highlight(f"{sAMAccountName:<30} {description}") except Exception as e: self.logger.debug(f"Skipping item, cannot process due to error {e}") - pass return def groups(self): @@ -807,7 +804,6 @@ class ldap(connection): except Exception as e: self.logger.debug("Exception:", exc_info=True) self.logger.debug(f"Skipping item, cannot process due to error {e}") - pass return def dc_list(self): @@ -889,7 +885,6 @@ class ldap(connection): except Exception as e: self.logger.debug("Exception:", exc_info=True) self.logger.debug(f"Skipping item, cannot process due to error {e}") - pass if len(answers) > 0: for user in answers: hash_TGT = KerberosAttacks(self).get_tgt_asroast(user[0]) @@ -969,7 +964,6 @@ class ldap(connection): ]) except Exception as e: nxc_logger.error(f"Skipping item, cannot process due to error {str(e)}") - pass if len(answers) > 0: self.logger.display(f"Total of records returned {len(answers):d}") @@ -1064,7 +1058,6 @@ class ldap(connection): except Exception as e: self.logger.debug("Exception:", exc_info=True) self.logger.debug(f"Skipping item, cannot process due to error {e}") - pass if len(answers) > 0: self.logger.debug(answers) for value in answers: @@ -1094,7 +1087,6 @@ class ldap(connection): # We reached the sizeLimit, process the answers we have already and that's it. Until we implement # paged queries resp = e.getAnswers() - pass else: return False answers = [] @@ -1139,7 +1131,6 @@ class ldap(connection): except Exception as e: self.logger.debug("Exception:", exc_info=True) self.logger.debug(f"Skipping item, cannot process due to error {str(e)}") - pass if len(answers) > 0: self.logger.debug(answers) for value in answers: @@ -1197,7 +1188,6 @@ class ldap(connection): except Exception as e: self.logger.debug("Exception:", exc_info=True) self.logger.debug(f"Skipping item, cannot process due to error {str(e)}") - pass if len(answers) > 0: self.logger.debug(answers) for value in answers: diff --git a/nxc/protocols/smb.py b/nxc/protocols/smb.py index e1c7dc62..9cbc48d7 100755 --- a/nxc/protocols/smb.py +++ b/nxc/protocols/smb.py @@ -213,7 +213,6 @@ class smb(connection): if "STATUS_NOT_SUPPORTED" in str(e): # no ntlm supported self.no_ntlm = True - pass self.domain = self.conn.getServerDNSDomainName() if not self.no_ntlm else self.args.domain self.hostname = self.conn.getServerName() if not self.no_ntlm else self.host @@ -227,7 +226,6 @@ class smb(connection): self.signing = self.conn.isSigningRequired() if self.smbv1 else self.conn._SMBConnection._Connection["RequireSigning"] except Exception as e: self.logger.debug(e) - pass self.os_arch = self.get_os_arch() self.output_filename = os.path.expanduser(f"~/.nxc/logs/{self.hostname}_{self.host}_{datetime.now().strftime('%Y-%m-%d_%H%M%S')}".replace(":", "-")) @@ -249,7 +247,6 @@ class smb(connection): self.conn.logoff() except Exception as e: self.logger.debug(f"Error logging off system: {e}") - pass if self.args.domain: self.domain = self.args.domain @@ -627,7 +624,6 @@ class smb(connection): self.admin_privs = True except scmr.DCERPCException: self.admin_privs = False - pass def gen_relay_list(self): if self.server_os.lower().find("windows") != -1 and self.signing is False: @@ -768,7 +764,6 @@ class smb(connection): except Exception as e: error = get_error_string(e) self.logger.fail(f"Error getting user: {error}") - pass try: shares = self.conn.listShares() @@ -801,7 +796,6 @@ class smb(connection): except SessionError as e: error = get_error_string(e) self.logger.debug(f"Error checking READ access on share: {error}") - pass if not self.args.no_write_check: try: @@ -812,7 +806,6 @@ class smb(connection): except SessionError as e: error = get_error_string(e) self.logger.debug(f"Error checking WRITE access on share: {error}") - pass permissions.append(share_info) @@ -823,7 +816,6 @@ class smb(connection): except Exception as e: error = get_error_string(e) self.logger.debug(f"Error adding share: {error}") - pass self.logger.display("Enumerated shares") self.logger.highlight(f"{'Share':<15} {'Permissions':<15} {'Remark'}") @@ -1440,7 +1432,6 @@ class smb(connection): self.no_da = False except Exception as e: self.logger.fail(f"Could not get domain backupkey: {e}") - pass target = Target.create( domain=self.domain, diff --git a/nxc/protocols/smb/wmiexec.py b/nxc/protocols/smb/wmiexec.py index 273e6435..fe3e66d8 100755 --- a/nxc/protocols/smb/wmiexec.py +++ b/nxc/protocols/smb/wmiexec.py @@ -156,7 +156,6 @@ class WMIEXEC: if str(e).find("STATUS_SHARING_VIOLATION") >= 0 or str(e).find("STATUS_OBJECT_NAME_NOT_FOUND") >= 0: sleep(2) tries += 1 - pass else: self.logger.debug(str(e)) diff --git a/nxc/protocols/winrm.py b/nxc/protocols/winrm.py index 28f738b2..4fd6ed63 100644 --- a/nxc/protocols/winrm.py +++ b/nxc/protocols/winrm.py @@ -57,7 +57,6 @@ class winrm(connection): if "STATUS_NOT_SUPPORTED" in str(e): # no ntlm supported no_ntlm = True - pass self.domain = smb_conn.getServerDNSDomainName() if not no_ntlm else self.args.domain self.hostname = smb_conn.getServerName() if not no_ntlm else self.host diff --git a/nxc/servers/http.py b/nxc/servers/http.py index 490e28de..01ae0d64 100755 --- a/nxc/servers/http.py +++ b/nxc/servers/http.py @@ -90,7 +90,6 @@ class NXCHTTPServer(threading.Thread): self.server.serve_forever() except Exception as e: nxc_logger.debug(f"Error starting HTTP server: {e}") - pass def shutdown(self): try: @@ -112,4 +111,3 @@ class NXCHTTPServer(threading.Thread): thread._stop() except Exception as e: nxc_logger.debug(f"Error stopping HTTP server: {e}") - pass diff --git a/nxc/servers/smb.py b/nxc/servers/smb.py index e12b1991..d71338b1 100755 --- a/nxc/servers/smb.py +++ b/nxc/servers/smb.py @@ -38,7 +38,6 @@ class NXCSMBServer(threading.Thread): self.server.start() except Exception as e: nxc_logger.debug(f"Error starting SMB server: {e}") - pass def shutdown(self): # TODO: should fine the proper way @@ -49,4 +48,3 @@ class NXCSMBServer(threading.Thread): self._stop() except Exception as e: nxc_logger.debug(f"Error stopping SMB server: {e}") - pass