Created
December 18, 2020 19:28
-
-
Save nimatrueway/968f1a37ca15ac6aef9bcf9be1b8aea5 to your computer and use it in GitHub Desktop.
Easy Tunnel
This file contains hidden or 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
#!/usr/local/bin/expect | |
log_user 0 | |
spawn nc localhost 2000 | |
stty raw -echo | |
interact -o -nobuffer |
This file contains hidden or 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
#!/usr/local/bin/expect | |
log_user 0 | |
proc username {} { return "my_user_name" } | |
proc first_ssh {} { return "ssh server1" } | |
proc second_ssh {} { return "ssh server2" } | |
proc third_nc {} { return "nc db_host db_port" } | |
spawn "[first_ssh]" | |
expect { | |
"*[username]@host-*:~$ " { | |
send "[second_ssh]; exit\n" | |
expect { | |
"*Last login:*(*:* *app-*:*~*) " { | |
send "[third_nc]; exit\n" | |
interact | |
} | |
} | |
} | |
} |
This file contains hidden or 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
# terminal 1 | |
nc -l 2000 | |
# terminal 2 | |
socat tcp-l:200 system:'./nc-test.exp' | |
# terminal 3 | |
nc localhost 200 | |
# when I write something and hit enter, it echoes back; this is what I see | |
# 1 | |
# 1 | |
# hello | |
# hello |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment