cytopia / pwncat

pwncat - netcat on steroids with Firewall, IDS/IPS evasion, bind and reverse shell, self-injecting shell and port forwarding magic - and its fully scriptable with Python (PSE)
https://pwncat.org
MIT License
1.78k stars 211 forks source link

when pasting in term I donot get full line echo #109

Closed drforbin closed 3 years ago

drforbin commented 3 years ago

When I paste in shell created with pwncat I donot get full line echo? Any idea what's wrong? great tool by the way

cytopia commented 3 years ago

Can you add some more info so that I can try to reprocude, e.g.: Remote binary/version and pwncat commands

drforbin commented 3 years ago

Sure! Thank you for answering. When I use pwncat in -l port mode or --self-inject (either way) and I get a shell, I upgrade (i.e. get a pty, change stty settings etc) after that everthing is fine except when I paste something in the shell window I donot get an echo of pasted items until after I hit return. Using nc or ncat everthing works fine. Also I do get character by character echo. Which is the say as I type the characters are echoed. Only when I paste does it NOT show until I hit a CR. Really hard to do pentesting without pasting ability.

cytopia commented 3 years ago

I was able to reproduce this behaviour. It might take some time to dig into the root of this issue. In the meantime what you could do in order to make your life a bit easier is to simply hit <space> after pasting (instead of <return>).

Good catch and thanks for reporting :+1:

Edit: As verbose logging of pwncat on local side reflects this behaviour I would already assume that it is missing a flush somewhere.

drforbin commented 3 years ago

Thank you for making such a great tool. Are you going to produce any binaries or will it alway be python? I think your tool can be as great as chisel. But chisel has windows and unix* bins which would help alot. As for the reason for bug. I seems to me to be a buffering issue. Try flushing.

Please me know when you find the cause, I'm curious.

cytopia commented 3 years ago

@drforbin can you give the branch release-0.1.2 a try: See PR here: https://github.com/cytopia/pwncat/pull/110

cytopia commented 3 years ago

@drforbin any chance you can try out the above posted branch and let me know if this fixes the issues on all the use-cases you were facing this?

drforbin commented 3 years ago

Hi..I'll do it tonight

drforbin commented 3 years ago

It seems to be working fine. I only did a quick ncat <-> pwncat check. What was wrong?

cytopia commented 3 years ago

The error was non trivial and I was doing a lot of trial&error to figure it out.

In the end I removed the non-blocking select call on stdin in terminal raw mode: https://github.com/cytopia/pwncat/pull/110/files#diff-70eb7791158dc5e238921ef7dc25ce6a6924dbb39ad728461816c8501b90da7fR3531

I made it blocking again (which doesn't really matter, as it runs in its own thread anyway).

Also not really 100% sure about the fix, but I guess the behaviour previously was as follows:

Without the non-blocking call, it now shows everything and does not just wait, until the select call sees new entries (which it only did after key presses)