Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Specify the distro name when pop up a debugging window in wsl
  • Loading branch information
RoderickChan authored and vboxuser committed Sep 10, 2023
1 parent 83c5c3b commit 5dee2cf
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions pwnlib/util/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,8 +340,14 @@ def run_in_new_terminal(command, terminal=None, args=None, kill_at_exit=True, pr
with open('/proc/sys/kernel/osrelease', 'rb') as f:
is_wsl = b'icrosoft' in f.read()
if is_wsl and which('cmd.exe') and which('wsl.exe') and which('bash.exe'):
terminal = 'cmd.exe'
args = ['/c', 'start', 'bash.exe', '-c']
terminal = 'cmd.exe'
args = ['/c', 'start']
distro_name = os.getenv('WSL_DISTRO_NAME')
if distro_name:
args.extend(['wsl.exe', '-d', distro_name, 'bash', '-c'])
else:
args.extend(['bash.exe', '-c'])


if not terminal:
log.error('Could not find a terminal binary to use. Set context.terminal to your terminal.')
Expand Down

0 comments on commit 5dee2cf

Please sign in to comment.