Windows
Introduction
In this section, you will find several useful commands for the Post-Exploitation phase in Windows systems.
User
Creating a user
Add a user to a group
Add a user to the RDP group
By default, you cannot log in as a user through RDP unless it is a member of the "Remote Management Users" group.
Powershell credentials and how to use them
If you have obtained some credentials and want to perform an action impersonating the actual account, you can use PowerShell.
Recursive Grep (Powershell)
There is not a grep command on the Windows system, but thanks to PowerShell we can achieve something similar.
Remote Command Execution
During a pentest, it is quite common to obtain credentials that can be used for getting access to other machines. However, most Windows machines will lack of CLI services like SSH to execute commands remotely. Nonetheless, there are other Windows services that can be used to perform the same actions.
WinRM
Port: 5985
Windows Remote Management (WinRM) is a protocol that allows systems to access and exchange management information. An attacker can use this protocol to obtain RCE.
In order to check who can use the WinRM Protocol run the following command.
During the session, the commands you type are executed on the remote computer, as if you were typing directly on the remote computer, but you can have only one interactive session at a time.
As an alternative, you can use tools like evil-winrm or crackmapexec to execute commands.
Remote Desktop (RDP)
Port: 3389
If the user is a member of the "Remote Management Users" group and port 3389 is available, an attacker with the users' credentials could connect to the victim's computer.
/dynamic-resolution
: This allows us to change the size of the window, adjusting the resolution of the lens in the process./size: WIDTHxHEIGHT
: Set a specific size for machines that do not automatically resize with/dynamic-resolution
.+clipboard
: Enables the use of clipboards./drive:<LOCAL_DIRECTORY>,<SHARE_NAME>
: Creates a shared drive between the attacking machine and the target.
Note: A useful directory to share is the /usr/share/windows-resources
directory in Kali, because it contains several Windows tools like Mimikatz.
SMB
Port: 445
The SMB service can always allow an attacker to execute remote code against a windows system, as long as you have a valid account on that machine with sufficient permissions to create and run a service.
There are different tools that can achieve this goal, each one in its own way.
PSEXEC
Uploads to ADMIN$
a service binary with an arbitrary name. The obtained reverse shell is not interactive thus programs like PowerShell, vssadmin and plink will cause the service to fail.
Furthermore, there is a high probability of being detected by AVs or EDRs.
SmbExec
Creates a service in the same way as psexec but it does not drop any binary on the host so it is stealthier than psexec. However, it is still a non-interactive shell.
Crackmapexec
WMiexec
It creates a semi-interactive shell without installing any service or agent, being the stealthiest of the before mentioned.
Last updated