source code for my "sms.sh" with some bells and whistles ... ;-)
#!/bin/bash db='/home/babil/scripts/sms.db' ### input password echo read -s -p "[*] enter password: " pass echo ### ### input recipient echo recp_no='' while [ -z "$recp_no" ] do read -p "[*] enter recipient: " recp_in if [ $((recp_in+1)) -eq 1 ] then s='' s=`cat $db | grep -w $recp_in` if [ ! -z "$s" ] then recp_name=`cat $db | grep -w $recp_in | awk '{print $1}'` recp_no=`cat $db | grep -w $recp_in | awk '{print $2}'` echo "[*] recipient number found : $recp_no" else recp_no='' fi else recp_no=$recp_in s='' s=`cat $db | grep -w $recp_in` if [ -z "$s" ] then read -p "[*] give recipient a name : " recp_name echo "$recp_name $recp_no" >> $db else recp_no=`cat $db | grep -w $recp_in | awk '{print $2}'` recp_name=`cat $db | grep -w $recp_in | awk '{print $1}'` fi fi done ### ### input sender echo sender_in='' read -p "[*] enter sender: " sender_in if [ $((sender_in+1)) -eq 1 ] then s='' s=`cat $db | grep -w $sender_in 2>/dev/null` if [ ! -z "$s" ] then sender_no=`cat $db | grep -w $sender_in | awk '{print $2}'` sender_name=`cat $db | grep -w $sender_in | awk '{print $1}'` echo "[*] sender number found : $sender_no" else sender_no='' fi fi if [ -z "$sender_no" ] then echo "[*] using default sender : 614XXXXXXXX" sender_name='default' sender_no='614XXXXXXXX' fi ### ### input message rem=0 while [ $rem -le 0 ] do echo read -p "[*] enter message: " msg msg=`echo $msg | sed -e 's/ /\+/g'` len=${#msg} rem=$((157-len)) if [ $len -ge 157 ] then echo -n "[$len/$rem]" fi done ### ### print info echo echo "[>] recipient : $recp_name $recp_no" echo "[>] sender : $sender_name $sender_no" echo "[>] message : $msg" echo "[>] length : $len / $rem" echo ### ### confirm with user read -n1 -p '[?] are you happy with the setting : [y/n] ' yn echo if [ "$yn" != "y" ] || [ ! "$yn" != "Y" ] then exit 1 fi ### ### send message echo echo '[*] Trying to send ...' echo curl -c cookie.txt -d "username=6128XXXXXXX&password=$pass" "https://www.pennytel.com/m/login.jsp" -L 2>&1 1> /dev/null m=`curl -b cookie.txt -d "trans=SendSMS&pagecaller=SMS&smstype=Premium&recipient=$recp_no&smscount=1&message=$msg&counter=$rem&mobilenumber=%2B$sender_no&credit=%24+4.31&freesms=0&walalang=FREE" "https://www.pennytel.com/sms_sent.jsp" -L -A='Mozilla/5.0' -e='http://www.pennytel.com/m/index.jsp?error=Invalid%20Entry' -# 2>/dev/null | grep "Please enter your username and password"` echo if [ -z $m ] then echo '[*] SUCCESS.' else echo '[*] FAILED.' fi rm cookie.txt 2>/dev/null echo ###
0 comments:
Post a Comment