Skip to content

Commit b6cfec6

Browse files
authored
Do not fail with gdb.debug() over ssh when given an absolute path (#894)
* Do not fail with gdb.debug() over ssh when given an absolute path Fixes #885 * Prevent failing on stable since this directory doesn't exist
1 parent 4ebcbee commit b6cfec6

2 files changed

Lines changed: 9 additions & 6 deletions

File tree

pwnlib/gdb.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ def debug(args, execute=None, exe=None, ssh=None, env=None, **kwargs):
226226
if not ssh and context.os == 'android':
227227
host = context.adb_host
228228

229-
attach((host, port), exe=exe, execute=execute, need_ptrace_scope = False)
229+
attach((host, port), exe=exe, execute=execute, need_ptrace_scope = False, ssh=ssh)
230230

231231
# gdbserver outputs a message when a client connects
232232
garbage = gdbserver.recvline(timeout=1)
@@ -247,8 +247,8 @@ def get_gdb_arch():
247247

248248

249249
@LocalContext
250-
def attach(target, execute = None, exe = None, need_ptrace_scope = True):
251-
"""attach(target, execute = None, exe = None, arch = None) -> None
250+
def attach(target, execute = None, exe = None, need_ptrace_scope = True, ssh = None):
251+
"""attach(target, execute = None, exe = None, arch = None, ssh = None) -> None
252252
253253
Start GDB in a new terminal and attach to `target`.
254254
:func:`pwnlib.util.proc.pidof` is used to find the PID of `target` except
@@ -401,8 +401,11 @@ def findexe():
401401
cmd += ' -q '
402402

403403
if exe and context.native:
404+
if ssh:
405+
ssh.download_file(exe)
406+
exe = os.path.basename(exe)
404407
if not os.path.isfile(exe):
405-
log.error('no such file: %s' % exe)
408+
log.error('No such file: %s' % exe)
406409
cmd += ' "%s"' % exe
407410

408411
if pid and not context.os == 'android':
@@ -460,7 +463,7 @@ def ssh_gdb(ssh, process, execute = None, arch = None, **kwargs):
460463
l = tubes.listen.listen(0)
461464
forwardport = l.lport
462465

463-
attach(('127.0.0.1', forwardport), execute, local_exe, arch)
466+
attach(('127.0.0.1', forwardport), execute, local_exe, arch, ssh=ssh)
464467
l.wait_for_connection() <> ssh.connect_remote('127.0.0.1', gdbport)
465468
return c
466469

travis/install.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ setup_android_emulator()
9696

9797
# However, the file needs to be present or else things break.
9898
touch 'docs/source/adb.rst'
99-
touch 'docs/source/protocols/adb.rst'
99+
touch 'docs/source/protocols/adb.rst' || true
100100

101101
echo "Skipping Android emulator install, Android tests disabled."
102102
return

0 commit comments

Comments
 (0)