Added Account locked, more detailed errors
This commit is contained in:
parent
d9f84b6808
commit
fd04529620
3
bml.sh
3
bml.sh
@ -5,6 +5,7 @@
|
|||||||
#Setting intial variables
|
#Setting intial variables
|
||||||
BML_URL='https://www.bankofmaldives.com.mv/internetbanking/api'
|
BML_URL='https://www.bankofmaldives.com.mv/internetbanking/api'
|
||||||
COOKIE=/tmp/bmlcookie
|
COOKIE=/tmp/bmlcookie
|
||||||
|
CREDENTIALS=.env
|
||||||
|
|
||||||
#Setting terminal output colors
|
#Setting terminal output colors
|
||||||
red=`tput setaf 1`
|
red=`tput setaf 1`
|
||||||
@ -12,4 +13,4 @@ green=`tput setaf 2`
|
|||||||
reset=`tput sgr0`
|
reset=`tput sgr0`
|
||||||
|
|
||||||
|
|
||||||
source password.sh
|
source readpass.sh
|
||||||
|
29
login.sh
29
login.sh
@ -1,28 +1,25 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
#login and generate cookie
|
#login and generate cookie
|
||||||
|
|
||||||
LOGIN=$(curl -s -c $COOKIE $BML_URL/login \
|
LOGIN=$(curl -s -c $COOKIE $BML_URL/login \
|
||||||
--data-raw username=$BML_USERNAME \
|
--data-raw username=$BML_USERNAME \
|
||||||
--data-raw password=${BML_PASSWORD} \
|
--data-raw password=${BML_PASSWORD} \
|
||||||
--compressed \
|
--compressed \
|
||||||
| jq -r .success)
|
| jq -r .code)
|
||||||
#check if login was success
|
#check if login was success
|
||||||
if [ "$LOGIN" = "true" ]
|
if [ "$LOGIN" = "0" ]
|
||||||
then
|
then
|
||||||
#Requesting for User profile after login and regex to grap the Full name
|
source savepass.sh
|
||||||
NAME=$(curl -s -b $COOKIE $BML_URL/profile \
|
elif [ "$LOGIN" = "20" ]
|
||||||
| awk -F 'fullname":"' '{print $2}' \
|
then
|
||||||
| cut -f1 -d '"')
|
echo "${red}Account Locked!${reset}"
|
||||||
#display a Welcome message with fullname
|
exit
|
||||||
echo ""
|
elif [ "$LOGIN" = "2" ]
|
||||||
echo ${green}Welcome ${reset}$NAME
|
then
|
||||||
# curl -s -b $COOKIE $BML_URL/userinfo
|
source readpass.sh
|
||||||
echo ""
|
|
||||||
source mainmenu.sh
|
|
||||||
else
|
else
|
||||||
#Display error if login was not succuessfull and delete cookie
|
echo "${red}Unknown Error${reset}" 1>&2
|
||||||
echo "${red}An error occured, Please check Username and Password" 1>&2
|
exit
|
||||||
rm $COOKIE 2> /dev/null
|
|
||||||
exit
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
29
readpass.sh
Normal file
29
readpass.sh
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
|
||||||
|
if [ -f $CREDENTIALS ]
|
||||||
|
then
|
||||||
|
source $CREDENTIALS
|
||||||
|
elif [ "$LOGIN" = "2" ]
|
||||||
|
then
|
||||||
|
if [ -f $CREDENTIALS ]
|
||||||
|
then
|
||||||
|
echo "${red}Saved Credentials has been changed${reset}"
|
||||||
|
rm $CREDENTIALS
|
||||||
|
else
|
||||||
|
echo "${red}Username or Password incorrect${reset}"
|
||||||
|
fi
|
||||||
|
read -p 'Username: ' BML_USERNAME
|
||||||
|
read -s -p 'Password: ' BML_PASSWORD
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
elif [ ! -f $CREDENTIALS ]
|
||||||
|
then
|
||||||
|
echo "${red}Password file not found in $CREDENTIALS${reset}"
|
||||||
|
read -p 'Username: ' BML_USERNAME
|
||||||
|
read -s -p 'Password: ' BML_PASSWORD
|
||||||
|
echo ""
|
||||||
|
else
|
||||||
|
:
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
source login.sh
|
27
savepass.sh
Normal file
27
savepass.sh
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
#echo "Do ${red}NOT${reset} save password if password contain '|' '^' '$' '&' ';' ':' '(' ')' "
|
||||||
|
|
||||||
|
if [ ! -f $CREDENTIALS ]
|
||||||
|
then
|
||||||
|
if [ "$LOGIN" = "0" ]
|
||||||
|
then
|
||||||
|
read -p 'Do you want to save login? [y/N] ' SAVE_LOGIN
|
||||||
|
if [ "$SAVE_LOGIN" = "Y" ]
|
||||||
|
then
|
||||||
|
echo BML_USERNAME=''${BML_USERNAME}'' > $CREDENTIALS
|
||||||
|
echo BML_PASSWORD=''${BML_PASSWORD}'' >> $CREDENTIALS
|
||||||
|
|
||||||
|
elif [ "$SAVE_LOGIN" = "y" ]
|
||||||
|
then
|
||||||
|
echo BML_USERNAME=''${BML_USERNAME}'' > $CREDENTIALS
|
||||||
|
echo BML_PASSWORD=''${BML_PASSWORD}'' >> $CREDENTIALS
|
||||||
|
else
|
||||||
|
:
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
source readpass.sh
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
:
|
||||||
|
fi
|
||||||
|
|
||||||
|
source welcome.sh
|
11
welcome.sh
Normal file
11
welcome.sh
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
#Requesting for User profile after login and regex to grap the Full name
|
||||||
|
NAME=$(curl -s -b $COOKIE $BML_URL/profile \
|
||||||
|
| awk -F 'fullname":"' '{print $2}' \
|
||||||
|
| cut -f1 -d '"')
|
||||||
|
|
||||||
|
#display a Welcome message with fullname
|
||||||
|
echo ""
|
||||||
|
echo ${green}Welcome ${reset}$NAME
|
||||||
|
#curl -s -b $COOKIE $BML_URL/userinfo
|
||||||
|
echo ""
|
||||||
|
source mainmenu.sh
|
Loading…
x
Reference in New Issue
Block a user