ssh.exe
Full path
c:\windows\system32\OpenSSH\ssh.exeCommands
Execute specified command, can be used for defense evasion.
ssh localhost "{CMD}"Executes specified command on host machine. The prompt for password can be eliminated by adding the host’s public key in the user’s authorized_keys file. Adversaries can do the same for execution on remote machines.
os: Windows 10 1809, Windows Server 2019
Performs execution of specified file, can be used as a defensive evasion.
ssh -o ProxyCommand="{CMD}" .Executes specified command from ssh.exe
os: Windows 10
Performs indirect execution of a specified DLL from a remote share, can be used for defense evasion.
ssh -o PKCS11Provider="\\\\127.0.0.1\\Temp\\example.dll" win@github.comExecutes a DLL from an SMB share by abusing the PKCS11Provider option. The payload executes upon DLL load (DllMain) and requires exporting C_GetFunctionList to prevent premature termination by
ssh.exe. Note that all backslashes should be escaped (i.e. every\should be turned into\\).os: Windows 10, Windows 11
Performs execution of specified file, can be used as a defensive evasion.
ssh.exe -o "StrictHostKeyChecking=no" -o "PermitLocalCommand=yes" -o "LocalCommand={CMD}" user@hostExecutes a local command via the
LocalCommandoption (enabled byPermitLocalCommand=yes) after the SSH session is successfully established and authenticated.os: Windows 10, Windows 11, Windows Server 2019, Windows Server 2022
Performs execution of specified file, can be used as a defensive evasion.
ssh.exe -o "StrictHostKeyChecking=no" -o "KnownHostsCommand=C:\Windows\System32\cmd.exe /c {CMD}" win@github.comExecutes a local command through the
KnownHostsCommandoption, which OpenSSH invokes to retrieve host keys during key exchange prior to user authentication. Does not requirePermitLocalCommandand executes before authentication completes.os: Windows 10, Windows 11, Windows Server 2019, Windows Server 2022
Detection
- Sigma https://github.com/SigmaHQ/sigma/blob/c04bef2fbbe8beff6c7620d5d7ea6872dbe7acba/rules/windows/process_creation/proc_creation_win_lolbin_ssh.yml
- IOCEvent ID 4624 with process name C:\Windows\System32\OpenSSH\sshd.exe.
- IOCcommand line arguments specifying execution.
- IOCssh.exe process creation containing PermitLocalCommand or LocalCommand in command line arguments (note that options loaded from an SSH config file via -F or the default %USERPROFILE%\.ssh\config do not appear on the ssh.exe command line).
- IOCssh.exe spawning a child process such as cmd.exe, powershell.exe, msiexec.exe or rundll32.exe. LocalCommand executes through cmd.exe (ssh.exe spawns cmd.exe which spawns the payload). This parent-child relationship also catches config-file (-F) variants where execution flags are absent from the command line.
- IOCssh.exe process creation containing KnownHostsCommand in command line arguments (note that options loaded from an SSH config file via -F or the default %USERPROFILE%\.ssh\config do not appear on the ssh.exe command line).
- IOCssh.exe spawning a child process such as cmd.exe or powershell.exe during SSH key exchange prior to user authentication.
Code samples
Resources
acknowledgement: Akshat Pradhan, Felix Boulet, Edo Maland, Will Dormann @wdormann, Yared Henriquez @DevCop95