COMP-221 · Lesson 7 of 12 · 20 min
Enumerating users, shares and directories
▶ Video coming soon A video version of this lesson is on the way.
The Prairiefold test was gray box, which meant the client provided some information and access up front. For the internal phase, that included a standard domain user account, created for Ironwhistle with the same rights as a new branch employee. On Wednesday, October 14, Dario logged the account's first use and showed Tobias how much a single ordinary account can see in a typical Windows domain. By lunchtime Tobias had stopped being surprised and started taking notes.
This lesson covers objective 2.2's share enumeration, local user enumeration, permission enumeration, secrets enumeration and attack path mapping, together with directory enumeration in the sense of directory services such as Active Directory. (Enumeration of web directories is lesson 8.) It describes what each technique reveals, what tools testers use, and how defenders reduce what an ordinary account can learn.
Why internal enumeration matters
Most serious breaches involve an attacker who already has a foothold inside: a phished user, a compromised laptop, a malicious insider. The question the internal test answers is what that foothold leads to. Enumeration maps the directory, the shares, the permissions and the relationships between accounts and computers. Each is information an attacker uses to move from one ordinary account toward the systems that matter. For a credit union, those are the systems holding member data and the accounts that administer them.
Enumeration with valid credentials is active and authenticated: every query is logged against the test account. That is a feature. It means the client can later see exactly what Ironwhistle did, and it tests whether the security team notices unusual directory queries.
Password policy first
Before enumerating anything that could involve authentication attempts, testers check the domain password and lockout policy. A lockout threshold of five failed attempts means any careless tool that tries credentials could lock real users out of their accounts, which at a credit union means tellers who cannot serve members. Ironwhistle's rules of engagement prohibited password guessing against domain accounts entirely, but knowing the policy is still essential, and a weak policy is a finding.
# From a domain-joined Windows host, using the test account
net accounts /domainForce user logoff how long after time expires?: Never Minimum password age (days): 1 Maximum password age (days): 90 Minimum password length: 8 Length of password history maintained: 12 Lockout threshold: 5 Lockout duration (minutes): 30 Lockout observation window (minutes): 30
Users and groups in the directory
Active Directory stores users, groups, computers, organizational units and policies, and by default any authenticated user can read most of it over LDAP. That is how Windows works: computers and users need to look things up. It also means an ordinary account can list every user, every group and its members, every computer, and many attributes such as descriptions, last logon times and password change dates.
# PowerShell with the Active Directory module (part of the Remote Server Administration Tools)
Get-ADUser -Filter * -Properties Description,LastLogonDate,PasswordLastSet |
Select-Object SamAccountName,Description,LastLogonDate,PasswordLastSet
Get-ADGroupMember -Identity "Domain Admins" -Recursive | Select-Object SamAccountName
# The same kind of query from a Linux test host over LDAP
ldapsearch -H ldap://192.0.2.10 -D "pt-ironwhistle01@corp.prairiefold.example" -W \
-b "DC=corp,DC=prairiefold,DC=example" "(objectClass=user)" sAMAccountName descriptionWhat testers look for in the results is not the list itself but the patterns and outliers.
| Look for | Why it matters | Prairiefold observation |
|---|---|---|
| Size of privileged groups | Every member of Domain Admins is a high-value target | 11 members, including two accounts for staff who had changed roles |
| Service accounts | Often old, rarely rotated, sometimes highly privileged | svc_backup in a privileged group, password last set in 2019 |
| Descriptions and notes fields | Admins sometimes write passwords or hints there | One test account description contained a temporary password |
| Stale accounts | Enabled accounts not used for months widen the attack surface | 63 enabled accounts with no logon in over 180 days |
| Accounts with unusual settings | For example passwords that never expire, or Kerberos pre-authentication disabled | 14 accounts set to never expire |
The description field holding a temporary password was a secret enumeration finding of the simplest kind. Ironwhistle recorded it with the value masked, did not try it, and told Felix, who confirmed the account was disabled the same afternoon.
Local users
Local user enumeration means listing the accounts on an individual host rather than in the directory. It matters because local administrator accounts, if they share a password across many machines, let an attacker who compromises one move to all of them. On Windows, the tester checks local accounts and group membership on hosts they can access; on Linux, the accounts in the passwd file and the groups that grant privileges.
| Platform | Command or source | What it shows |
|---|---|---|
| Windows | net user and net localgroup administrators | Local accounts and members of the local Administrators group |
| Windows | whoami /all | The current account's groups and privileges |
| Windows (PowerShell) | Get-LocalUser and Get-LocalGroupMember | The same, with object output |
| Linux | The /etc/passwd file and id | Local accounts, shells and group membership |
| Linux | sudo -l | What the current user may run as root |
On the Branch 07 workstation used for testing, the local Administrators group contained a domain group, Branch IT Support, and a local account named branchadmin. Felix confirmed that Prairiefold used Microsoft's local administrator password solution on newer machines but that older branch workstations still shared one local administrator password. That was a finding about lateral movement risk, which COMP-224, PenTest+: Post-Exploitation and Lateral Movement, examines from the attacker's side.
Shares
File shares are where organizations keep their documents, scripts and backups, and they are often far more open than their owners think. Share enumeration lists the shares on each host and checks what the test account can read and write.
Share enumeration can begin without credentials. Older or misconfigured Windows and Samba servers sometimes allow null sessions, anonymous connections that list shares and even users. Modern Windows restricts this by default, so a successful anonymous listing is a finding in itself. With credentials, tools list shares across many hosts at once and report the access level for each.
# List shares on one server with the test account
smbclient -L //192.0.2.20 -U "CORP/pt-ironwhistle01"
# Check share access across the server network in one pass
nxc smb 192.0.2.0/25 -u pt-ironwhistle01 -p <test-account-password> --shares
# Anonymous checks: users, shares and policy where null sessions are allowed
enum4linux-ng -A 192.0.2.20
# Nmap scripts for SMB share enumeration
sudo nmap -p 445 --script smb-enum-shares 192.0.2.20nxc smb 192.0.2.20 -u pt-ironwhistle01 -p <test-account-password> --sharesSMB 192.0.2.20 445 FS01 [*] Windows Server 2019 Build 17763 x64 (name:FS01) (domain:corp.prairiefold.example) (signing:False) (SMBv1:False) SMB 192.0.2.20 445 FS01 [+] corp.prairiefold.example\pt-ironwhistle01 SMB 192.0.2.20 445 FS01 [*] Enumerated shares SMB 192.0.2.20 445 FS01 Share Permissions Remark SMB 192.0.2.20 445 FS01 ----- ----------- ------ SMB 192.0.2.20 445 FS01 ADMIN$ Remote Admin SMB 192.0.2.20 445 FS01 C$ Default share SMB 192.0.2.20 445 FS01 IPC$ READ Remote IPC SMB 192.0.2.20 445 FS01 Branches READ SMB 192.0.2.20 445 FS01 ITTools READ SMB 192.0.2.20 445 FS01 Scans READ,WRITE SMB 192.0.2.20 445 FS01 Finance
Two lines stood out. The ITTools share, meant for the IT team, was readable by every domain user. The Scans share, where branch scanners dropped scanned documents, was writable by every domain user, which meant scanned member documents could be read, altered or replaced by anyone on the network. The header line also showed that SMB signing was not required on the file server, which matters for relay attacks covered in COMP-223.
Permission enumeration
Permission enumeration asks who can do what to which object: files and folders, shares, registry keys, services, directory objects and cloud resources. Share-level and file-level permissions combine, and the most restrictive applies, so a share listing alone does not tell the whole story. On Windows, icacls shows file and folder permissions; in Active Directory, each object has an access control list that may grant rights such as resetting passwords or changing group membership to unexpected accounts.
| Object | Permission to look for | Why it matters |
|---|---|---|
| Share or folder | Everyone or Domain Users with write or modify | Anyone can alter or plant files |
| Script or executable used by others | Write access for ordinary users | Changes run with someone else's privileges |
| Windows service | Ability to change the service configuration or binary | Leads to running code as the service account |
| AD user or group object | GenericAll, GenericWrite, WriteDacl, reset password | Control over another account or group |
| Linux file or binary | World-writable files, unusual set-user-ID programs | Local privilege escalation paths |
Secrets on shares and in the directory
Objective 2.2 lists secrets enumeration for cloud access keys, passwords, API keys and session tokens. Internally, secrets turn up in scripts, configuration files, spreadsheets, backups and the directory itself. A classic example is the SYSVOL share on domain controllers, which every domain user can read; old Group Policy Preferences files there once stored passwords in a form that anyone could decrypt, and remnants still appear in long-lived domains. Searching readable shares for files and terms that suggest credentials is standard practice.
In the ITTools share, Tobias found a folder of maintenance scripts. One of them, used to map a backup drive, contained the svc_backup account name and its password in clear text. This was exactly the situation the rules of engagement anticipated. Tobias stopped, called Dario, and Dario called Gwendolyn. The secret was recorded with all but its first two characters masked, the file path and timestamp were captured, and the script's hash was noted so the evidence could be verified later. Gwendolyn approved validating, once, that the password was current, without using it to access anything else, and then had the password changed that evening. The finding went into the report as critical, because svc_backup was a member of a privileged group.
| Step | What Ironwhistle did |
|---|---|
| Stop | Paused searching and did not use or test the credential |
| Record | Path, timestamp, file hash, masked value, account affected |
| Report | Called the lead, who called the sponsor the same hour |
| Act only as approved | One validation, in writing, then immediate rotation by the client |
| Protect | Stored the evidence only on the encrypted engagement share |
Attack path mapping
Individually, enumerated facts look minor: a user is in a group, a group has rights over a computer, an administrator is logged on to that computer. Combined, they can form a chain from an ordinary account to the domain's most powerful groups. Attack path mapping, listed in objective 2.2, means building and analyzing those chains.
BloodHound is the best-known tool for this. A collector, such as SharpHound on Windows or a Python-based collector on Linux, queries the directory and, optionally, computers for sessions and local group membership. BloodHound loads the data into a graph database and shows relationships as nodes and edges. Queries such as shortest path to Domain Admins reveal chains that would take days to find by hand. Defenders use exactly the same tool to find and cut those paths.
Prairiefold's graph held a path of exactly that shape. Branch staff were local administrators on their own workstations, an old setting for a branch application. A helpdesk technician regularly logged on to branch workstations, leaving a session. The IT Helpdesk group had been granted full control over the Domain Admins group years earlier, probably during a migration. In theory, an attacker who compromised any branch user could capture the technician's credentials from the workstation and use the helpdesk group's rights to add themselves to Domain Admins. Each edge was a verified fact; the path itself was a hypothesis, reported with its evidence. Whether to demonstrate any part of it was a decision for the attacks phase and the client, not for reconnaissance.
Defending against internal enumeration
Organizations cannot stop authenticated users from reading the directory entirely, but they can reduce what is worth finding and notice unusual reading.
| Area | Defensive measure |
|---|---|
| Directory hygiene | Small privileged groups, removal of stale accounts, no secrets in descriptions, regular rights reviews |
| Anonymous access | Disable null sessions and anonymous LDAP binds |
| Shares | Least-privilege share and file permissions, owners for every share, periodic access reviews |
| Secrets | Vault service account passwords, use managed service accounts, scan shares for credentials |
| Local administrators | Unique local administrator passwords per machine, users not local admins |
| Attack paths | Run BloodHound defensively, apply administrative tiering, fix risky access control entries |
| Detection | Alert on bulk LDAP queries and collector behavior; plant decoy accounts that should never be queried |
Prairiefold's security team had not detected the BloodHound collection, which ran from the head office test laptop on October 15. That gap, together with the findings above, gave Gwendolyn a strong case for the identity security project she had been proposing.
Worked problem
Reading a share listing
A share listing for 192.0.2.22 shows: Policies READ, HRArchive READ,WRITE, Software READ, Backups (blank). The test account is an ordinary branch user. Which entries need follow-up, and how?
Show solution
- HRArchive READ,WRITE: an ordinary user can write to what is probably sensitive human resources data. Check folder permissions with care, list file names only, and report without opening personal files beyond what proves access.
- Software READ: may hold installers and scripts. Search for configuration files and scripts that might contain secrets.
- Policies READ: likely expected; check for scripts with credentials.
- Backups blank: no access, which is correct. Record as a positive control.
Answer: HRArchive is the priority finding; Software and Policies need a secrets search; Backups is correctly restricted.
Common mistakes
MistakeRunning tools that attempt logons before checking the lockout policy.
InsteadCheck the policy first, and follow the rules of engagement on password guessing.
MistakeOpening every readable file to prove a share is exposed.
InsteadProve access with the minimum: listings, file names and a single non-sensitive file if needed.
MistakeUsing a discovered service account password to explore further.
InsteadStop, record with masking, report, and act only on written approval.
MistakeReporting a BloodHound path as a confirmed compromise.
InsteadReport it as a path built from verified facts, with evidence for each edge.
MistakeRecommending that users be blocked from reading the directory.
InsteadRecommend hygiene, least privilege, tiering and detection; directory reads are normal.
Summary and key terms
- Internal enumeration shows what an ordinary foothold can learn and reach.
- Check the password and lockout policy before anything that could involve authentication.
- Any authenticated user can usually read most of Active Directory; look for privileged groups, service accounts, stale accounts and secrets in attributes.
- Local user enumeration reveals shared local administrator passwords and privilege settings.
- Share and permission enumeration find over-permissive access; null sessions are a finding in themselves.
- Discovered secrets are masked, reported and used only as approved.
- BloodHound maps attack paths from enumerated facts; defenders use it to cut those paths.
- Null session
- An anonymous SMB connection that may allow listing shares and users on misconfigured systems.
- Share enumeration
- Listing network shares and the access a given account has to each.
- Permission enumeration
- Determining which accounts have which rights over files, services, directory objects and other resources.
- Secrets enumeration
- Searching for exposed credentials, keys and tokens.
- Attack path
- A chain of relationships that leads from one account or system to a more privileged one.
- BloodHound
- A tool that graphs Active Directory relationships to reveal attack paths.
- SYSVOL
- A share on domain controllers, readable by all domain users, holding policies and logon scripts.
- Lockout threshold
- The number of failed logons that locks an account.
Practice problems
Work each problem on paper first, then reveal the answer to check.
Why is it significant that any authenticated user can read most of Active Directory?
Show answer
A single compromised ordinary account can map users, groups, computers and relationships, which guides an attacker toward privileged targets.
Name two places where internal secrets are commonly found.
Show answer
Any two of: scripts on shares, configuration files, directory attribute fields such as descriptions, SYSVOL, backups and spreadsheets.
What does a WriteDacl right on a group object allow?
Show answer
Changing the group's access control list, which can be used to grant oneself rights such as adding members.
Lesson quiz · 5 questions
Score 60% or more to complete this lesson.
Create a free account to save your progress, take quizzes and earn a certificate.