#!/bin/bash # Script: http://hacktracking.blogspot.de/2013/09/chatroom-encrypted-conversations-using.html basename=`which basename` cat=`which cat` nc=`which ncat` tput=`which tput` function client { $nc --ssl $ip $port > >(while read line; do prompt=`echo $line | awk '{print $1}'` message=`echo $line | sed "s/$prompt//"` if [ "$prompt" == "" ] || [ "$prompt" == "" ]; then echo -e "\e[35m\e[0m\e[90m$message\e[0m" else echo -e "\e[32m$prompt\e[0m\e[36m$message\e[0m" fi $tput setaf 3 done) echo -e "\e[35m\e[0m \e[90moperator closes the chatroom.\e[0m" reset } function reset { $tput sgr0; } function server { $nc --listen --chat --ssl $ip $port } function usage { $cat << eof Usage: `$basename $0` [-h] {-m c|s} {-i ip} {-p port} Options: -m: Mode c: Client s: Server -i: IP -p: Port eof } conns='' ip='' port='' while getopts "hm:i:p:" option; do case $option in h) usage && exit ;; m) mode=$OPTARG ;; i) ip=$OPTARG ;; p) port=$OPTARG ;; esac done if [ -z $ip ] || [ -z $port ] ; then usage && exit fi trap reset SIGINT case $mode in c) client ;; s) server ;; *) usage && exit esac