← cd ..OSBinaries

ssh.exe

Ssh.exe is the OpenSSH compatible client can be used to connect to Windows 10 (build 1809 and later) and Windows Server 2019 devices.

Full path

c:\windows\system32\OpenSSH\ssh.exe

Commands

  1. ExecuteUser T1202

    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

    Execute: CMD

  2. ExecuteUser T1202

    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

    Execute: CMD

  3. ExecuteUser T1202

    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.com

    Executes 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

    Execute: DLLExecute: Remote

  4. ExecuteUser T1202

    Performs execution of specified file, can be used as a defensive evasion.

    ssh.exe -o "StrictHostKeyChecking=no" -o "PermitLocalCommand=yes" -o "LocalCommand={CMD}" user@host

    Executes a local command via the LocalCommand option (enabled by PermitLocalCommand=yes) after the SSH session is successfully established and authenticated.

    os: Windows 10, Windows 11, Windows Server 2019, Windows Server 2022

    Execute: CMD

  5. ExecuteUser T1202

    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.com

    Executes a local command through the KnownHostsCommand option, which OpenSSH invokes to retrieve host keys during key exchange prior to user authentication. Does not require PermitLocalCommand and executes before authentication completes.

    os: Windows 10, Windows 11, Windows Server 2019, Windows Server 2022

    Execute: CMD

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