calebstewart / pwncat

Fancy reverse and bind shell handler
https://pwncat.readthedocs.io
MIT License
2.61k stars 256 forks source link

Use tmux for managing multiple connections #258

Open axman6 opened 2 years ago

axman6 commented 2 years ago

Is the feature related to a problem? Please describe.

Session management is good but limits concurrency with only the ability to interact with one session/pwncat command line at a time. Handling long running processed on the remote host can lead to time out errors from pwncat.

Feature Description

68 mentioned briefly that a user could use something like tmux to manage multiple instances of pwncat. I would love to see pwncat run inside tmux by default, and manage multiple panes at once to avoid switching between the pwncat cli and the various open sessions. By default the pwncat cli would be open in a pane inside tmux. Once a remote connection is made, initialising that connection would crate a new tmux pane, while keeping the pwncat pane open (my idea would be to keep the pwncat pane at the bottom of the window, and add new session panes above horizontally, but of course a user could configure this using tmux.

The main benefit of this is being able to run commands concurrently in different sessions and keep track of their progress - currently this can be quite problematic; running, say, nmap on the remote system can lead to pwncat timing out when trying to use ^d to switch back to the pwncat cli.

As far as I understand, the current implementation will run enumeration etc. in the same shell you are connected to, which might make implementing this more difficult, but potentially run could take an argument to specify which session to run with (and disable the use of that session pane while it's executing).

I haven't looked too deeply into whether it would be feasible to use, but tmuxp appears to offer python bindings for managing tmux sessions from the command line - hopefully it can also be used programmatically as apython library inside pwncat - https://tmuxp.git-pull.com/api.html seems to suggest it can be, though I can't see how to open a new pane with a pty that has been crated by pwncat.

Alternatives

It would be possible to implement this without tmux using something like ncurses, but that feels llike far more trouble than its worth. This also adds an external dependency on tmux, so may not be ideal, but if the old interface is retained, using tmux may be accessivle through a pwncat command line flag.

Additional Context

-