-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Make interactive() exit when recv side disconnects #2108
base: dev
Are you sure you want to change the base?
Conversation
I haven't really looked at this problem at all, but can't we do something like You can definetely detect disconnects with |
4873414
to
c359571
Compare
Thanks! I originally didn't do that because it seemed complex, but I got something working. There's more code changes and it's a bit confusing, but it avoids modifying any of the internals of |
Although I will say, even though I'm catching the exception that's thrown when the process is stopped, this is still output from the logging:
|
This comment has been minimized.
This comment has been minimized.
One thing I believe should be considered is an option to keep current behaviour: now if the recv side disconnects, you can still send 'blind' TCP packets to it; I remember this was useful in a couple CTF challenges. |
@gsingh93 Do you remember what was keeping this in a draft state? I think a parameter on The |
I've rebased this on latest dev and tested a bit. from pwn import *
#io = process('/bin/sh')
l = listen()
l.spawn_process('/bin/sh')
io = remote('127.0.0.1', l.lport)
io.interactive()
pwntools/pwnlib/tubes/process.py Lines 825 to 829 in 61804b1
That message could be removed to avoid the spam. Maybe the old solution of doing short reads and checking if the receiving side disconnected should be reconsidered. You can only `select´ on sockets on Windows, so this isn't generally portable. I guess we can use select on posix and the sleeps on windows, but that would complicate the code further. |
This needs more testing and discussion, but I wanted to create a PR to at least see if this approach would work or whether this needs to be done in a completely different way.
This PR addresses #2106. I want
tubes.interactive()
to break out of its loop when it receives an EOF from the remote side. Currently if this happens, the send side will not break because it's blocked waiting for user input, and only after pressing enter does it try to send to the remote and see that it's disconnected.My solution is to:
go.set()
in the receiving thread so the sending side knows that the receiving side disconnected.0
and notNone
(which would have meant a timeout occured). If there's no EOF, the loop continues to iterate and poll for input every second.This works locally, and while it seems like there are some test cases I need to fix, I wanted to check if this general approach is OK before I put more time into it, or if there are any obvious problems with it that can't be easily fixed or if there's an overall better approach to this.