Skip to content

Commit db93f5b

Browse files
committed
add change requests
Signed-off-by: Sebastian Pauli <sebastian.pauli@protonmail.com>
1 parent 1a4ea1e commit db93f5b

1 file changed

Lines changed: 15 additions & 33 deletions

File tree

nxc/modules/get-info-users.py

Lines changed: 15 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,13 @@ def options(self, context, module_options):
2323

2424
def on_login(self, context, connection):
2525
# Building the search filter
26-
searchFilter = "(objectclass=user)"
26+
searchFilter = "(info=*)"
2727

28-
try:
29-
context.log.debug(f"Search Filter={searchFilter}")
30-
resp = connection.ldap_connection.search(
31-
searchFilter=searchFilter,
32-
attributes=["sAMAccountName", "info"],
33-
sizeLimit=0,
34-
)
35-
except ldap_impacket.LDAPSearchError as e:
36-
if e.getErrorString().find("sizeLimitExceeded") >= 0:
37-
context.log.debug("sizeLimitExceeded exception caught, giving up and processing the data received")
38-
resp = e.getAnswers()
39-
else:
40-
nxc_logger.debug(e)
41-
return False
28+
context.log.debug(f"Search Filter={searchFilter}")
29+
resp = connection.search(
30+
searchFilter=searchFilter,
31+
attributes=["sAMAccountName", "info"]
32+
)
4233

4334
context.log.debug(f"Total of records returned {len(resp)}")
4435
resp_parsed = parse_result_attributes(resp)
@@ -51,26 +42,17 @@ def on_login(self, context, connection):
5142
context.log.highlight(f"User: {answer[0]} Info: {answer[1]}")
5243

5344
def filter_answer(self, context, answers):
54-
# No option to filter
45+
answersFiltered = []
46+
# No option to filter
5547
if self.FILTER == "":
5648
context.log.debug("No filter option enabled")
5749
return answers
58-
59-
answersFiltered = []
50+
# Filter
6051
context.log.debug("Prepare to filter")
61-
if len(answers) > 0:
62-
for answer in answers:
63-
conditionFilter = False
64-
info = str(answer[1])
65-
# Filter
66-
if self.FILTER != "":
67-
conditionFilter = False
68-
if self.FILTER in info:
69-
conditionFilter = True
70-
71-
if conditionFilter:
72-
context.log.highlight(f"'{self.FILTER}' found in Info: '{info}'")
73-
elif self.FILTER == "":
74-
answersFiltered.append([answer[0], info])
52+
for answer in answers:
53+
if self.FILTER and self.FILTER in str(answer[1]):
54+
answersFiltered.append(answer)
55+
elif not self.FILTER:
56+
answersFiltered.append(answer)
7557

76-
return answersFiltered
58+
return answersFiltered

0 commit comments

Comments
 (0)