Persistence
Maintain Access
Password hash (Pass-the-Hash / Crack-the-Hash) --> Services
Backdoor
New users
Meterpreter - run hashdump
Dump hashes from SAM database:
Sometimes this will fail. Workaround: migrate!
Or we can use:
Then in metasploit:
Pass-the-Hash in Metasploit
We may use psexec:
And interestingly, we can use the password hash as SMBPass!
And of course, the account has to be admin one to use psexec.
Also, if a user is in the Administrators group, but not an actual administrator, we may get the error STATUS_ACCESS_DENIED
. We have to make changes in the registry:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System
> Add a new DWORD (32-bit) LocalAccountTokenFilterPolicy and set the value to 1HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\LanManServer\Parameters
> Add a new DWORD (32-bit) RequireSecuritySignature and set the value to 0
Or in powershell:
Or use reg ...
Pass-the-Hash via RDP
We may use xfreerdp in Kali Linux.
Mimikatz in Meterpreter
The best situation is that the target system is a 64-bit one. Also, do migrate Meterpreter to a 64-bit process. To find a good candidate, find 64-bit process with System privilege:
Then load Mimikatz:
Retrieve credentials using wdigest:
Enable RDP
To check if RDP is enabled:
Or WMIC:
Or in Meterpreter:
Then enable it. In Meterpreter:
And of course the user has to be in the RDP group (Allow log on through Remote Desktop Services in local policy). In cmd:
Then we can RDP using rdesktop:
Also, there is a little trick on shell. We can enable shell connection using TelnetClients group :)
Persistence in Meterpreter
Persistence module options:
The steps of creating this persistence:
Create the payload using msfvenom
Upload the backdoor
Execute the backdoor
Add entry in Windows Registry
HKLM\Software\Microsoft\Windows\CurrentVersion\Run\xxxx
reg setval -k HKLM\\SOFTWARE\\microsoft\\windows\\currentversion\\run -d "<path_to_backdoor>" -v <backdoor_name>
Use
multi/handler
to get shell
Add new users
Add a new admin:
DLL Hijacking / Preloading
Abuse DLL Search Order. When a program launches, the DLL Search Order is most likely to be:
Directory of the executable
C:\Windows\System32
C:\windows\system
C:\windows
Current directory at the time of execution
Directories in
%PATH%
To search for opportunity of DLL Hijacking, use Process Monitor to inspect the DLL used by the processes.
Create a procmon filter for a specific executable. Also create a filter for NAME NOT FOUND for result column so we can quickly filter on relevant entries.
Identify the DLL in a directory which we have write/modify permission.
Drop the modified payload in the writable directory
Restart the service / Restart the application ... etc
Note that we can use msfvenom to generate DLL:
Last updated