@@ -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
0 commit comments