Skip to content

Instantly share code, notes, and snippets.

@intech
Created September 23, 2019 03:51
Show Gist options
  • Select an option

  • Save intech/4216fa62f260d97443ae506105c2b498 to your computer and use it in GitHub Desktop.

Select an option

Save intech/4216fa62f260d97443ae506105c2b498 to your computer and use it in GitHub Desktop.
#!/bin/sh -e
if [ $# != 3 ]
then
echo "usage: $0 <src-port> <dst-host> <dst-port>"
exit 0
fi
TMP=`mktemp -d`
PIPE=$TMP/pipe
SENT=$TMP/pipe.sent
RCVD=$TMP/pipe.rcvd
trap 'rm -rf "$TMP"' EXIT
#mkfifo -m 0600 "$PIPE"
mkfifo -m 0600 "$PIPE" "$SENT" "$RCVD"
#TIMESTAMP=$(date "+%Y-%m-%d %H:%M:%S")
sed 's/^/=> /' <"$SENT" &
sed 's/^/<= /' <"$RCVD" &
nc -v -k -l -p "$1" <"$PIPE" | tee "$SENT" | nc "$2" "$3" | tee "$RCVD" >"$PIPE"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment