#!/bin/bash
####++ReadME++####
# 1.Input username and password to userlist.txt #
#
xxx@xxx.com password #
# 2.Run this script and see output in check_command.txt#
#
export PATH=/usr/sbin:/sbin:/usr/bin:/bin:/usr/local/bin
HOME=/home/golf/check_telnet
echo > ${HOME}/check_command.txt
#xxx=`( echo user ${usernamex}; sleep 1; echo pass ${passwordx}; sleep 1; echo quit)`
if [ -s ${HOME}/userlist.txt ]
then
xx=`less ${HOME}/userlist.txt | wc -l`
echo "All accounts = ${xx}"
while read usernamex passwordx
do
( echo user $usernamex; sleep 1; echo pass $passwordx; sleep 1; echo quit ) | telnet
localhost 110 >> ${HOME}/check_command.txt
echo "check $usernamex" >> ${HOME}/check_command.txt
echo "" >> ${HOME}/check_command.txt
echo "" >> ${HOME}/check_command.txt
done < ${HOME}/userlist.txt
echo /dev/null > ${HOME}/userlist.txt
else
exit
fi
#( echo $USER; sleep 1; echo $PASS; sleep 1; echo exit ) | telnet abc.com
zz=`less ${HOME}/check_command.txt | grep "+OK logged in." | wc -l`
yy=$xx-$zz
expr $yy
echo "==================================================="
echo "Wrong password = $yy accounts"
echo "==================================================="
echo "Run this command below"
echo "less ${HOME}/check_command.txt"