Fixes #955: don't return 'target:' prefix in pwndbg.proc.exe

Before this commit the `pwndbg.proc.exe` could return a "target:" prefix when `pwndbg.proc.exe` was executed on remote targets. This could be seen by:

1. Executing gdbserver in one terminal: gdbserver 127.0.0.1:1234 `which ps`
2. Executing `gdb -ex 'target remote :1234'` in another terminal and then invoking `pi pwndbg.proc.exe`.

This resulted in `checksec` (and some other) commands crashes which were using the `pwndbg.file.get_fille` functionality as it downloaded the remote file by using the `gdb.execute("remote get %s %s")` command passing it a path prefixed with `"target:"` which this GDB command does not support.
pull/958/head
Disconnect3d 4 years ago
parent 56e0ce4881
commit 3e4ad608af

@ -58,7 +58,19 @@ class module(ModuleType):
@property @property
def exe(self): def exe(self):
return gdb.current_progspace().filename """
We lstrip "target:" for remote debugging. Otherwise, the
`pwndbg.file.get_file(pwndbg.proc.exe)` would not work on remote targets.
This should not be a problem on local targets as `gdb.current_progspace().filename`
seems to return absolute paths.
"""
fn = gdb.current_progspace().filename
if fn.startswith('target:'):
return fn[7:] # len('target') == 7
return fn
@property @property
def mem_page(self): def mem_page(self):

Loading…
Cancel
Save