1. Resources
  2. Identity Threats
  3. Active Directory

Credentials in SYSVOL Scripts, File Shares and Configuration Files

Also known as: Passwords in logon scripts, Share hunting, Credentials in files, Unattend.xml passwords, Snaffling

Any domain user can search SYSVOL scripts, deployment shares and application configuration files for passwords that administrators left in readable files.

Platform
Active Directory
Impact
High
Last updated
Attack difficulty
Low
Detection difficulty
High
Privileges required: Any authenticated identity
Any authenticated domain account. Read access to SYSVOL is given to all domain users; other shares depend on their share and NTFS permissions.
What the attacker gains
Cleartext passwords, keys and connection strings for service, deployment, database and administrator accounts.
Threat groups
APT3APT33Ember BearFIN13Fox KittenIndrik SpiderKimsukyLeafminerMuddyWaterOilRigRedCurlSalt TyphoonScattered SpiderShinyHuntersand 22 more in MITRE ATT&CKGroups that MITRE ATT&CK records using T1552.001, T1135, T1039.

How it works

Administrators and deployment tools leave passwords in files, and files are shared. This attack is a search: the attacker uses the read access of an ordinary domain account to look through shares for files that contain a secret. It exploits no vulnerability. The weakness is a hardcoded credential in a place with a wider audience than its author intended.

Four places account for most findings:

  • SYSVOL scripts. Logon, logoff, startup and shutdown scripts are stored under \\<domain>\SYSVOL\<domain>\scripts (the NETLOGON share) and inside GPO folders. They are readable by every domain user. A script that maps a drive, joins a domain or installs software with explicit credentials publishes those credentials to the whole domain. A password in a comment travels with the script just the same. Retired scripts kept for rollback are still readable.
  • Shared deployment files. Installation bundles pass through staging shares that are open to far more people than the service they install. Answer files for unattended Windows setup (unattend.xml, sysprep.inf), software deployment scripts, task sequences and release manifests can carry a local administrator password, a domain join account or a license server credential.
  • Application configuration. A deployment template may hold only a reference to a secret, while the rendered configuration file holds the resolved value. web.config connection strings, .ini and .config files, and scripts next to the application are typical. The copy on a share or in a backup folder is the one that leaks.
  • IT asset and inventory platforms. Inventory and deployment servers, such as Lansweeper, hold scanning credentials that work across their whole target scope, often with local administrator rights. Their configuration exports, installer folders and deployment package shares are a concentrated source of privileged credentials, and a platform that can deploy packages can run code on every endpoint it manages.

A match is not yet a credential. A string that looks like a password may be a ticket number, a placeholder or a value rotated years ago, and a function that converts a secure string may be reading from a protected store. The attacker's last step is always to test what was found.

Passwords stored by Group Policy Preferences are a special case with their own decryption step: see GPP passwords.

Prerequisites

  • A valid domain account and SMB access (TCP 445) to domain controllers and file servers.
  • Shares that the account can read. SYSVOL and NETLOGON always qualify. Other shares qualify when they grant Authenticated Users, Domain Users or Everyone read access, which is common on staging, software and "temp" shares.
  • A file on one of those shares that holds a secret that is still valid.

Attack steps

For authorized security testing and lab use only. Run these steps against systems you own or have written permission to assess.

1. Search SYSVOL scripts

SYSVOL is small and always readable, so it is searched first. From a domain-joined Windows host:

findstr /S /I /N /C:"password" /C:"pwd" /C:"net use" \\corp.example.com\SYSVOL\corp.example.com\scripts\*.bat \\corp.example.com\SYSVOL\corp.example.com\scripts\*.cmd \\corp.example.com\SYSVOL\corp.example.com\scripts\*.ps1 \\corp.example.com\SYSVOL\corp.example.com\scripts\*.vbs

/S searches subdirectories, /I ignores case, /N prints line numbers and each /C: is a literal search string. PowerShell gives the same result with more control over the pattern:

Get-ChildItem -Path '\\corp.example.com\SYSVOL\corp.example.com' -Recurse -File `
    -Include *.bat, *.cmd, *.ps1, *.vbs, *.xml, *.ini, *.txt |
    Select-String -Pattern 'password|passwd|pwd\s*=|cpassword|net use .* /user:' |
    Select-Object Path, LineNumber, Line

2. Find readable shares and search them

Snaffler automates the whole hunt. It gets the list of computers from Active Directory, finds the shares the current user can read, walks them, and scores files by name, extension and content with a built-in rule set:

:: Whole domain: discover computers and shares, print results and write a log
Snaffler.exe -s -o snaffler.log

:: Name the domain and the domain controller to query
Snaffler.exe -s -d corp.example.com -c DC01.corp.example.com -o snaffler.log

:: Only list readable shares, without walking files
Snaffler.exe -s -a -o shares.log

:: One path only, with no computer or share discovery
Snaffler.exe -s -i \\SRV01\Deploy -o deploy.log

-n takes a comma-separated list of hosts and skips computer discovery, -f limits share discovery to DFS, and -u pulls account names from the directory and searches for them inside files.

From Linux, NetExec's spider_plus module lists every file on every share the account can read, and can download them for offline searching:

# List all readable files on the host's shares
nxc smb 192.0.2.20 -u alice -p '<password>' -M spider_plus

# Download them as well
nxc smb 192.0.2.20 -u alice -p '<password>' -M spider_plus -o DOWNLOAD_FLAG=True

# Look for file names that contain a string on one share
nxc smb 192.0.2.20 -u alice -p '<password>' --spider Deploy --pattern unattend

3. Read the files that matter

File names that repay a manual look:

Kind Typical names
Unattended setup unattend.xml, autounattend.xml, sysprep.inf, sysprep.xml
Scripts *.bat, *.cmd, *.ps1, *.vbs, *.kix
Application configuration web.config, app.config, *.config, *.ini, appsettings.json
Database connection strings, *.udl, *.dsn, *.sql
Key material *.kdbx, *.pfx, *.p12, *.ppk, id_rsa
Notes passwords.txt, *.xlsx, handover documents

A password in an answer file is often Base64 encoded, not encrypted, and decodes directly.

4. Validate and use

The attacker pairs each value with the account named next to it and tests it once against the system the file belongs to. A deployment or scanning account usually has local administrator rights on many machines; a connection string gives the database.

Impact

The result is credential theft with nothing more than read access. Files tend to hold exactly the accounts that are painful to rotate: service accounts, deployment accounts, database logins, a local Administrator password shared by a whole fleet, scanning credentials with administrator rights everywhere. These are long-lived secrets, so a file written years ago often still works.

From there the path depends on the account: lateral movement to the servers it administers, data access through a database login, or domain compromise when a privileged account's password was left in a script.

OPSEC and artifacts

  • Narrow targeting. A full crawl of every share touches a very large number of files. A careful operator searches SYSVOL first, then picks servers by name and role, limits the crawl to DFS or to named hosts, and keeps the thread count low. Each file opened still passes a share access check on the server: event 5145, with the account, the client address, the share and the relative path, when Audit Detailed File Share is enabled there.
  • Discovery traffic. Automatic discovery makes an LDAP query for all computer objects and then opens an SMB session to each one to list shares. Every server visited records a network logon, event 4624 type 3, and a share access, event 5140, from the same workstation within minutes.
  • Running from an expected host. Reads from a workstation look like the user's normal file access. The tool itself does not: a process named Snaffler.exe, or an unknown binary that opens thousands of SMB connections, appears in process creation logs (event 4688) and endpoint telemetry.
  • Copying files out. Downloading files for offline search moves many megabytes from file servers to one client, and leaves the copies on the attacker's host. Searching in place leaves only the access checks.
  • Limits of the evidence. An access check shows that a file was requested with a given access mask. It does not show which bytes reached the client. A file server without detailed file share auditing records only the session.

Detection

Most file servers do not audit individual file access, so the read itself is usually invisible. What can be seen:

  • Fan-out. One account or one source address opening sessions to many servers, or requesting many distinct files, in a short window. This needs event 5140 or 5145 from the file servers, or network telemetry.
  • Sensitive file names. Event 5145 where RelativeTargetName ends in unattend.xml, web.config, .kdbx or similar, requested by an account that has no deployment or administration role.
  • Decoy files. A file with an attractive name on a readable share, holding the credentials of a decoy account. Any logon attempt with that account is an alert with almost no false positives.
  • Preference files on SYSVOL. The Group Policy Preferences passwords rules use the same event to catch user accounts reading computer-side preference files, a common first stop of the same hunt.
  • Script changes. A new or changed logon script is where a password can enter SYSVOL. See the logon script path rules and the GPO modified rules.
// Accounts that requested many distinct files on one server in 15 minutes
WindowsEvent
| where Channel == "Security" and EventID == 5145
| extend Account = tostring(EventData.SubjectUserName),
         Source = tostring(EventData.IpAddress),
         Share = tostring(EventData.ShareName),
         Path = tostring(EventData.RelativeTargetName)
| where Account !endswith "$"
| summarize Files = dcount(Path), Shares = dcount(Share) by Computer, Account, Source, bin(TimeGenerated, 15m)
| where Files >= 500
| order by Files desc

The threshold is a starting value. Backup agents, indexers, antivirus scans and deployment tools read many files in normal operation; build the exclusion list from your own baseline. Do not project file contents or matched strings into the SIEM, because that copies the exposed secret into another system.

Prevention gives a better return than detection here: run the same search yourself, on a schedule, and fix what it finds.

Mitigation

  • Take the passwords out of the files. Replace a credential in a script with an identity that needs no stored password: a group managed service account for services and tasks, the computer account for startup scripts, or retrieval from a secret store at run time.
  • Rotate everything that was found. Nobody can tell who read a file before it was fixed. Check the retained rollback version of a script and older release bundles separately; correcting the current file does not rewrite those.
  • Stop sharing one local administrator password. Windows LAPS removes the need to set that password from a script or an answer file.
  • Restrict staging and deployment shares to the identities that really read them, and remove answer files and installers after use.
  • Keep rendered configuration out of shared locations. Find the packaging step that writes the resolved value into the file, and limit read access on the result to the service's own identity.
  • Review asset and deployment platforms. List the scanning identities and their target scope, who can approve deployment packages and which identity runs them. Give each scanning credential the minimum scope and rights it needs.
  • Reduce what a leaked account can do. The service account security guide covers removing excess privileges and logon rights from service accounts.
  • Audit the shares that matter. Enable Audit Detailed File Share on the servers that hold deployment and configuration content. The audit policy guide covers the subcategories and their volume.

Detection rules for this attack

Log events to collect

FAQ

Why are passwords in SYSVOL scripts readable by everyone?

Logon and startup scripts are delivered from the SYSVOL share of the domain controllers, and every domain user and computer must be able to read that share for policy and scripts to apply. A password written in a script or in a comment travels with the script to every reader.

Does share hunting need special privileges?

No. The attacker uses the read access that a normal domain account already has. The work is in finding which shares are readable and which files hold something useful, and tools such as Snaffler automate both.

How can share hunting be detected?

With Audit Detailed File Share enabled, each file opened writes event 5145 on the file server. One account touching a very large number of files across many servers in a short time, or opening files with names such as unattend.xml or web.config, is the signal. A decoy file with a decoy credential gives a clearer alert.

Is deleting the file enough when a password is found?

No. The password has to be changed, because nobody can tell who read the file before it was removed. Older copies also survive in backups, shadow copies, previous release bundles and rollback versions of the script.

References

Techniques, tactics and threat groups: MITRE ATT&CK® Enterprise v20.1. © The MITRE Corporation. This work is reproduced and distributed with the permission of The MITRE Corporation. Last updated 2026-11-29.

Does this attack work in your environment?

Forestall maps every identity and the attack paths between them across Active Directory, Entra ID and cloud, read-only and agentless.