Skip to content

Specify the distro name when pop up a debugging window in wsl #2044

@RoderickChan

Description

@RoderickChan

There is a bug in run_in_new_terminal, this function cannot work in multiple wsl distributions.

When there're two or more wsl distros, bash.exe may be linked to the default one. Once I use pwntools in other distro, I cannot get a debugging window from wsl.

I think the right args should be :

distro_name = os.getenv('WSL_DISTRO_NAME')
args = ['/c', 'start', 'wsl.exe', '-d', distro_name, 'bash', '-c']

And I test the args:

$ wsl.exe --list --all
Windows Subsystem for Linux Distributions:
Ubuntu-18.04 (Default)
docker-desktop-data
docker-desktop
kali-linux
Ubuntu-16.04
Ubuntu-20.04

$ echo $WSL_DISTRO_NAME
Ubuntu-16.04

$ cat exp.py     
from pwn import *

context.log_level='debug'
distro_name = os.getenv('WSL_DISTRO_NAME')
context.terminal = ['cmd.exe', '/c', 'start', 'wsl.exe', '-d', distro_name, 'bash', '-c']
context.binary = './test'

p = context.binary.debug()

p.interactive()

$ python3 exp.py # get a debugging window now

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions