I want to use socat to fork multiple screeen/tmux sessions which accept reverse shell from nc. Let’s say socat listens on 4444.
I used many approaches, one of them:
#!/bin/bash
# Use socat to listen on port 5555 and handle connections
socat TCP-LISTEN:5555,reuseaddr,fork EXEC:"/bin/bash -c 'screen -dmS socat_session_$SOCAT_PEERADDR bash -i'"
When connecting with nc.traditional localhost 4444
, it disconnects immidiately.