Created
September 29, 2010 14:54
-
-
Save melissaboiko/602883 to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
# a telnet-like command to debug text protocols over SSL (https, smtps...). | |
# usage: | |
# telnets example.com https | |
# telnets example.com:https | |
# telnets https://example.com | |
if echo "$1" | grep -q "^[a-z]*://"; then | |
host="$(echo $1 | sed -e "s,^\([a-z]*\)://\(.*\),\2,")" | |
port="$(echo $1 | sed -e "s,^\([a-z]*\)://\(.*\),\1,")" | |
elif echo "$1" | grep -q :; then | |
host="$(echo $1 | sed -e "s,\([^:]*\):\(.*\),\1,")" | |
port="$(echo $1 | sed -e "s,\([^:]*\):\(.*\),\2,")" | |
else | |
host="$1" | |
port="$2" | |
fi | |
openssl s_client -quiet -connect "$host":"$port" |
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
function telnets() | |
{ | |
# a telnet-like command to debug text protocols over SSL (https, smtps...). | |
# implemented as function cause I put it in my .bashrc . | |
# usage: | |
# telnets example.com https | |
# telnets example.com:https | |
# telnets https://example.com | |
local host port | |
if echo "$1" | grep -q "^[a-z]*://"; then | |
host="$(echo $1 | sed -e "s,^\([a-z]*\)://\(.*\),\2,")" | |
port="$(echo $1 | sed -e "s,^\([a-z]*\)://\(.*\),\1,")" | |
elif echo "$1" | grep -q :; then | |
host="$(echo $1 | sed -e "s,\([^:]*\):\(.*\),\1,")" | |
port="$(echo $1 | sed -e "s,\([^:]*\):\(.*\),\2,")" | |
else | |
host="$1" | |
port="$2" | |
fi | |
openssl s_client -quiet -connect "$host":"$port" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment