Last active
March 27, 2018 20:18
-
-
Save jasonlai/e03b635f28441b9a5069d0c73e898a75 to your computer and use it in GitHub Desktop.
Poor man's telnet server in Bash
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Session 3 | |
sudo setsid bash -l < /var/run/my-telnet > /var/run/my-telnet 2>&1 # Bash expects itself as a session leader |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Client - Session 2 | |
nc $HOST_OF_SESSION1 1234 # After the connection is established the pty link is created on the host of the socat process |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Server - Session 1 | |
# Use `socat(1)` to listen on a TCP port, connecting its output to the input end of a PTY slave and input to the output end of the PTY slave | |
sudo socat TCP-LISTEN:1234,reuseaddr PTY,link=/var/run/my-telnet,user="$(id -un)",group="$(id -gn)",waitslave |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment