Skip to content

Commit

Permalink
ruff: manually fix flake8-bugbear issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Marshall-Hallenbeck committed Oct 12, 2023
1 parent 4045beb commit bfd32f1
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 17 deletions.
13 changes: 3 additions & 10 deletions nxc/modules/add_computer.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,7 @@ def do_samr_add(self, context):
if e.error_code == 0xC0000073:
context.log.highlight(f"{self.__computerName} not found in domain {selected_domain}")
self.noLDAPRequired = True
raise Exception()
else:
raise
context.log.exception(e)

user_rid = check_for_user["RelativeIds"]["Element"][0]
if self.__delete:
Expand All @@ -174,9 +172,7 @@ def do_samr_add(self, context):
if e.error_code == 0xC0000022:
context.log.highlight(f"{self.__username + ' does not have the right to ' + message + ' ' + self.__computerName}")
self.noLDAPRequired = True
raise Exception()
else:
raise
context.log.exception(e)
else:
if self.__computerName is not None:
try:
Expand Down Expand Up @@ -211,12 +207,9 @@ def do_samr_add(self, context):
except samr.DCERPCSessionError as e:
if e.error_code == 0xC0000022:
context.log.highlight("{}".format('The following user does not have the right to create a computer account: "' + self.__username + '"'))
raise Exception()
elif e.error_code == 0xC00002E7:
context.log.highlight("{}".format('The following user exceeded their machine account quota: "' + self.__username + '"'))
raise Exception()
else:
raise
context.log.exception(e)
user_handle = create_user["UserHandle"]

if self.__delete:
Expand Down
2 changes: 1 addition & 1 deletion nxc/modules/wcc.py
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ def get_value(subkey_handle, dwIndex=0):
_, _, data = get_value(subkey_handle)
else:
found = False
for _, name, data in subkey_values(subkey_handle):
for _, name, _data in subkey_values(subkey_handle):
if name.upper() == valueName.upper():
found = True
break
Expand Down
2 changes: 1 addition & 1 deletion nxc/modules/winscp_dump.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def decrypt_passwd(self, host: str, username: str, password: str) -> str:

# decrypt the password
clearpass = ""
for i in range(pw_length):
for _i in range(pw_length):
val, pass_bytes = self.dec_next_char(pass_bytes)
clearpass += chr(val)
if pw_flag == self.PW_FLAG:
Expand Down
4 changes: 1 addition & 3 deletions nxc/protocols/ldap.py
Original file line number Diff line number Diff line change
Expand Up @@ -847,8 +847,6 @@ def dc_list(self):
self.logger.highlight(f"{name} = {colored(ip_address, host_info_colors[0])}")
except socket.gaierror:
self.logger.fail(f"{name} = Connection timeout")
except socket.gaierror:
self.logger.fail(f"{name} = Connection timeout")
except Exception as e:
self.logger.fail("Exception:", exc_info=True)
self.logger.fail(f"Skipping item, cannot process due to error {e}")
Expand Down Expand Up @@ -1004,7 +1002,7 @@ def kerberoasting(self):
self.logger.display(f"Total of records returned {len(answers):d}")
TGT = KerberosAttacks(self).get_tgt_kerberoasting()
dejavue = []
for (_SPN, sAMAccountName, memberOf, pwdLastSet, lastLogon, delegation,) in answers:
for (_SPN, sAMAccountName, memberOf, pwdLastSet, lastLogon, _delegation) in answers:
if sAMAccountName not in dejavue:
downLevelLogonName = self.targetDomain + "\\" + sAMAccountName

Expand Down
4 changes: 2 additions & 2 deletions nxc/protocols/smb.py
Original file line number Diff line number Diff line change
Expand Up @@ -1111,8 +1111,8 @@ def hosts(self):
)

self.logger.success("Enumerated domain computer(s)")
for hosts in hosts:
domain, host_clean = self.domainfromdnshostname(hosts.dnshostname)
for host in hosts:
domain, host_clean = self.domainfromdnshostname(host.dnshostname)
self.logger.highlight(f"{domain}\\{host_clean:<30}")
break
except Exception as e:
Expand Down

0 comments on commit bfd32f1

Please sign in to comment.