Skip to content

Commit 443a87b

Browse files
committed
Simplify logic
1 parent b9827e5 commit 443a87b

1 file changed

Lines changed: 4 additions & 12 deletions

File tree

nxc/modules/get-info-users.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,8 @@ def options(self, context, module_options):
2020

2121
def on_login(self, context, connection):
2222
# Building the search filter
23-
searchFilter = "(info=*)"
24-
2523
resp = connection.search(
26-
searchFilter=searchFilter,
24+
searchFilter="(info=*)",
2725
attributes=["sAMAccountName", "info"]
2826
)
2927

@@ -32,23 +30,17 @@ def on_login(self, context, connection):
3230
answers = [[x["sAMAccountName"], x["info"]] for x in resp_parsed]
3331

3432
answers = self.filter_answer(context, answers)
35-
if len(answers) > 0:
33+
if answers:
3634
context.log.success("Found following users: ")
3735
for answer in answers:
3836
context.log.highlight(f"User: {answer[0]} Info: {answer[1]}")
3937

4038
def filter_answer(self, context, answers):
41-
answersFiltered = []
4239
# No option to filter
43-
if self.FILTER == "":
40+
if not self.FILTER:
4441
context.log.debug("No filter option enabled")
4542
return answers
4643
# Filter
4744
context.log.debug(f"Filter info field with: {self.FILTER}")
48-
for answer in answers:
49-
if self.FILTER and self.FILTER in str(answer[1]):
50-
answersFiltered.append(answer)
51-
elif not self.FILTER:
52-
answersFiltered.append(answer)
45+
return [answer for answer in answers if self.FILTER in answer[1]]
5346

54-
return answersFiltered

0 commit comments

Comments
 (0)