Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gdb.debug: avoid 2s timeout if possible #2435

Merged
merged 1 commit into from
Aug 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ The table below shows which release corresponds to each branch, and what date th
- [#2405][2405] Add "none" ssh authentication method
- [#2427][2427] Document behaviour of remote()'s sni argument as string.
- [#2382][2382] added optional port, gdb_args and gdbserver_args parameters to gdb.debug()
- [#2435][2435] Speed up gdbserver handshake in gdb.debug()

[2360]: https://github.com/Gallopsled/pwntools/pull/2360
[2356]: https://github.com/Gallopsled/pwntools/pull/2356
Expand Down
11 changes: 6 additions & 5 deletions pwnlib/gdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -717,12 +717,13 @@ def debug(args, gdbscript=None, gdb_args=None, exe=None, ssh=None, env=None, por

# gdbserver outputs a message when a client connects
garbage = gdbserver.recvline(timeout=1)

# Some versions of gdbserver output an additional message
try:
garbage2 = gdbserver.recvline_startswith(b"Remote debugging from host ", timeout=2)
except EOFError:
pass
message = b"Remote debugging from host "
if not garbage.startswith(message):
try:
garbage2 = gdbserver.recvline_startswith(message, timeout=2)
except EOFError:
pass

return gdbserver

Expand Down