Skip to content

Commit 68e36dc

Browse files
authored
Merge pull request Pennyw0rth#769 from sepauli/add-info-field
Add get-info-users module
2 parents fc71ef8 + 5dd82ff commit 68e36dc

2 files changed

Lines changed: 47 additions & 0 deletions

File tree

nxc/modules/get-info-users.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
from nxc.parsers.ldap_results import parse_result_attributes
2+
3+
4+
class NXCModule:
5+
"""
6+
Get the info field of users
7+
Module by @sepauli
8+
"""
9+
name = "get-info-users"
10+
description = "Get the info field of all users. May contain password"
11+
supported_protocols = ["ldap"]
12+
opsec_safe = True
13+
multiple_hosts = True
14+
15+
def options(self, context, module_options):
16+
"""FILTER Apply the FILTER (grep-like) (default: '')"""
17+
self.FILTER = ""
18+
if "FILTER" in module_options:
19+
self.FILTER = module_options["FILTER"]
20+
21+
def on_login(self, context, connection):
22+
# Building the search filter
23+
resp = connection.search(
24+
searchFilter="(info=*)",
25+
attributes=["sAMAccountName", "info"]
26+
)
27+
28+
context.log.debug(f"Total of records returned {len(resp)}")
29+
resp_parsed = parse_result_attributes(resp)
30+
answers = [[x["sAMAccountName"], x["info"]] for x in resp_parsed]
31+
32+
answers = self.filter_answer(context, answers)
33+
if answers:
34+
context.log.success("Found following users: ")
35+
for answer in answers:
36+
context.log.highlight(f"User: {answer[0]:<20} Info: {answer[1]}")
37+
38+
def filter_answer(self, context, answers):
39+
# No option to filter
40+
if not self.FILTER:
41+
context.log.debug("No filter option enabled")
42+
return answers
43+
# Filter
44+
context.log.debug(f"Filter info field with: {self.FILTER}")
45+
return [answer for answer in answers if self.FILTER in answer[1]]
46+

tests/e2e_commands.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ netexec ldap TARGET_HOST -u LOGIN_USERNAME -p LOGIN_PASSWORD KERBEROS -L
201201
netexec ldap TARGET_HOST -u LOGIN_USERNAME -p LOGIN_PASSWORD KERBEROS -M adcs
202202
netexec ldap TARGET_HOST -u LOGIN_USERNAME -p LOGIN_PASSWORD KERBEROS -M daclread -o TARGET=LOGIN_USERNAME ACTION=read
203203
netexec ldap TARGET_HOST -u LOGIN_USERNAME -p LOGIN_PASSWORD KERBEROS -M get-desc-users
204+
netexec ldap TARGET_HOST -u LOGIN_USERNAME -p LOGIN_PASSWORD KERBEROS -M get-info-users
204205
netexec ldap TARGET_HOST -u LOGIN_USERNAME -p LOGIN_PASSWORD KERBEROS -M get-network
205206
netexec ldap TARGET_HOST -u LOGIN_USERNAME -p LOGIN_PASSWORD KERBEROS -M groupmembership -o USER=LOGIN_USERNAME
206207
netexec ldap TARGET_HOST -u LOGIN_USERNAME -p LOGIN_PASSWORD KERBEROS -M laps

0 commit comments

Comments
 (0)