ruff: run previously unincluded PIE790 fixes in ruff 0.0.292
parent
0cb67d3016
commit
f1af5b8959
|
@ -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}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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: ")
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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()
|
||||
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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:")
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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))
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue