Investigating WSL Endpoints
Investigating WSL Endpoints
Asif Matadar
@d1r4c
OSDFCon 2020
#whoami
• Seasoned Incident Response professional with over a decade working in InfoSec and
specifically leading high-profile cases around the world, such as advanced targeted attacks,
nation-state attacks, and data breaches, to name a few
• Research focus on memory analysis and automation, *nix-based forensics, cloud forensics,
and triage analysis
• Since the announcement of the Windows Subsystem for Linux (WSL) back in 2016, there has been
a lot of excitement to try and leverage WSL across workstations and servers a like by organisations
and those that work in the industry.
• What does that mean for someone who works as a Digital Forensics & Incident Response
professional?
• Well adversaries and malware authors have already started focussing their attention on WSL;
therefore, it is important to understand the underlying architecture changes that will allow one
to investigate a compromised Windows 10 or Windows Server 2019 in the not too distant
future.
• This talk will highlight the nuances to be aware of from a Digital Forensics & Incident Response
perspective and illustrate forensic artefacts of interest, which will consist of a forensic examination
on a WSL Endpoint to provide the audience an appreciation of what that entails and share insights
that will assist them when the time arises.
• What is WSL 2?
• What does that mean for Digital Forensics & Incident Response professionals?
• WSL 1 had a translation layer to interpret the system calls, that allows them to
work on the Windows NT kernel
• Raw sockets
• Developed in-house kernel from stable branch at kernel.org source from version 4.19 kernel
• As it’s developed by Microsoft, updates to the kernel will be serviced by Windows Update
• Lightweight Utility VM
• Hyper-V hypervisor
• Lightweight Utility VM
• Hyper-V hypervisor
• Not a traditional Virtual Machine
• EXT4 Virtual Disk
• C:\Users\User\AppData\Local\Packages\CanonicalGroupLimited.UbuntuonWindow
s_79rhkp1fndgsc\LocalState\ext4.vhdx
• Management of WSL
• wsl.exe (WSL 2)
• wslconfig (WSL 1)
Environment Variables
Microsoft Store
WindowsApps
WindowsApps
WindowsApps
WindowsApps
Windows Terminal
• Environment:
• Windows 10 Pro
• Version 2004
• Installed on 12/12/2019
• OS Build 19041.84
• Experiments
1. Persistence: Bashrc
2. Persistence: Persistence through Inception! (Systemd)
3. Persistence: Crontab
4. Execution: Bourne Shell Reverse Shell
5. Execution: PowerShell Reverse Shell
6. Execution: Python Download File
7. Lateral Movement: Remote File Copy
8. Command and Control: Custom Command and Control Protocol
9. Execution: wsl.exe
10. Execution: bash.exe
11. Execution: curl.exe
• Process Execution:
• AMCache Program Entries
• 2020-02-26 10:21:57,CanonicalGroupLimited.UbuntuonWindows,1804.2019.521
• AMCache Associated File Entries
• CanonicalGroupLimited.UbuntuonWindows,2019-12-12 21:48:22
• AppCompactCache
• C:\Program
Files\WindowsApps\CanonicalGroupLimited.UbuntuonWindows_1804.2019.521.0_x64
__79rhkp1fndgsc\ubuntu.exe
• CanonicalGroupLimited.UbuntuonWindows
• UserAssist
• Prefetch
• /Windows/Prefetch/UBUNTU.EXE-39E7ED6A.pf
• MFT
• /Users/User/AppData/Local/Packages/CanonicalGroupLimited.UbuntuonWindows_79rhkp1
fndgsc/LocalState/ext4.vhdx
• /Users/User/AppData/Local/Microsoft/WindowsApps/ubuntu.exe
• /Users/User/AppData/Local/Microsoft/WindowsApps/CanonicalGroupLimited.UbuntuonWi
ndows_79rhkp1fndgsc/ubuntu.exe
• Systemd Journals
• /run/log/journal/*/system.journal
• /run/systemd/journal/*
• /etc/systemd/system/*
• /run/systemd/*
• /var/lib/systemd/*
• /usr/lib/systemd/*
PowerShell
Reverse
Shell
Attacker
Listener
Python
Download
File
Enable trace
Stop trace
Stop trace
wsl.exe Execution
wsl.exe Execution
wsl.exe Execution
• Process lineage
• Caveat:
• Execution of Linux commands will not be saved in ~/.bash_history, ~/.sh_history, etc,
bash.exe Execution
curl.exe Execution
• Adversaries and malware authors will continue to explore attack surfaces on WSL 2, as it
becomes more prevalent across enterprise environments
• WSL 2 Endpoints is going to make Digital Forensics and Incident Response professionals lives a
lot more interesting
• I highlighted 11 techniques based on my initial research, but I expect there to be more attack
surfaces with WSL 2
• https://lolbas-project.github.io/lolbas/OtherMSBinaries/Wsl/
• https://twitter.com/d1r4c/status/1280196218308694016
• https://lolbas-project.github.io/lolbas/Binaries/Bash/
• https://twitter.com/d1r4c/status/1279085773522862082
• https://twitter.com/d1r4c/status/1279042657508081664