This commit is contained in:
Shihaam Abdul Rahman 2021-05-17 00:31:44 +05:00
parent 82a7265e50
commit 9a6e24450a
17 changed files with 0 additions and 565 deletions

View File

@ -1,11 +0,0 @@
curl -s -b $COOKIE $BML_URL/dashboard \
| jq -r '.payload | .dashboard |.[] | (.alias, .account, .currency, .availableBalance)'
# | jq -r '["Account Number","Currency","Balance"], (.["payload"] | .["dashboard"] | .[0] | [.account | .currency | .availableBalance]) | @csv'
# ["==================================================================="], \
# (.["payload"] | .["dashboard"] | .["customer"] | .[0] | [.account | .currency | .availableBalance]) | @csv'
# | jq -r payload.dashboard[0].availableBalance
# | jq -r '(.["payload"] | .["dashboard"] | .["0"] | [.account | .currency | .availableBalance]) | @tsv'
source mainmenu.sh

View File

@ -1,47 +0,0 @@
printf 'Account Number: '
read -r ACCOUNT_NUMBER
VALID_NUMBER=$(curl -s -b $COOKIE $BML_URL/validate/account/$ACCOUNT_NUMBER \
| jq -r .success)
if [ "$VALID_NUMBER" = "true" ]
then
ACCOUNT_NAME=$(curl -s -b $COOKIE $BML_URL/validate/account/$ACCOUNT_NUMBER \
| jq -r '.["payload"] | .name')
CURRENCY=$(curl -s -b $COOKIE $BML_URL/validate/account/$ACCOUNT_NUMBER \
| jq -r '.["payload"] | .currency')
echo "Account Name: $ACCOUNT_NAME"
echo "Currency: $CURRENCY"
echo ""
printf 'Contact Name: '
read -r CONTACT_NAME
if [ "$CONTACT_NAME" = "" ]
then
CONTACT_NAME=$ACCOUNT_NAME
else
:
fi
CONTACT_NAME=`echo "$CONTACT_NAME" | sed "s/ /%20/"`
ADDCONTACT=$(curl -s -b $COOKIE $BML_URL/contacts \
--data-raw contact_type=IAT \
--data-raw account=$ACCOUNT_NUMBER \
--data-raw alias=$CONTACT_NAME \
--compressed \
| jq -r .success)
if [ "$ADDCONTACT" = "true" ]
then
echo "Contact added successfully"
else
echo "${red}There was an error${reset}"
source contactsmenu.sh
fi
else
echo "${red}Invalid Account${reset}" 1>&2
source contactsmenu.sh
fi
source contactsmenu.sh

View File

@ -1,40 +0,0 @@
echo ""
echo "Add Contact"
echo ""
echo "1 - BML"
echo "2 - Domestic"
echo "3 - International"
echo "4 - BillPay"
echo "5 - Go back"
echo "6 - Exit"
echo ""
printf 'Select contact type[1]: '
read -r CONTACT_TYPE
if [ "$CONTACT_TYPE" = "1" ] || [ "$CONTACT_TYPE" = "" ]
then
source addcontact-bml.sh
elif [ "$CONTATC_TYPE" = "2" ]
then
echo "${red}WORK IN PROGRESS${reset}"
source addcontact-menu.sh
elif [ "$CONTATC_TYPE" = "3" ]
then
echo "${red}WORK IN PROGRESS${reset}"
source addcontact-manu.sh
elif [ "$CONTATC_TYPE" = "4" ]
then
echo "${red}WORK IN PROGRESS${reset}"
source addcontact-manu.sh
elif [ "$CONTATC_TYPE" = "5" ]
then
source contactsmenu.sh
elif [ "$CONTATC_TYPE" = "6" ]
then
rm $COOKIE
exit
else
clear
echo "${red}There was an error${reset}" 1>&2
source contactsmenu.sh
fi

33
bml.sh
View File

@ -1,33 +0,0 @@
#!/bin/bash
#Making cookie and credentials dir
mkdir -p ~/.config/bml-cli/
mkdir -p ~/.cache/bml-cli/
#Setting intial variables
BML_URL='https://www.bankofmaldives.com.mv/internetbanking/api'
BML_RESETPASS='https://www.bankofmaldives.com.mv/internetbanking/forgot_password'
COOKIE=~/.cache/bml-cli/cookie
CREDENTIALS=~/.config/bml-cli/.env
cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1
#Setting terminal output colors
red=`tput setaf 1`
#errorred=`tput setaf 196`
#validgreen=`tput setaf 82`
green=`tput setaf 46`
brown=`tput setaf 3`
blue=`tput setaf 4`
pink=`tput setaf 5`
cyan=`tput setaf 39`
gray=`tput setaf 7`
darkgray=`tput setaf 8`
lightred=`tput setaf 9`
lightgreen=`tput setaf 10`
yellow=`tput setaf 11`
reset=`tput sgr0`
source osdetect.sh
source readpass.sh

View File

@ -1,90 +0,0 @@
read -s -p 'Enter Current Password: ' OLD_PASSWORD
echo ""
echo ""
while true; do
read -s -p 'Enter New Password: ' NEW_PASSWORD
echo ""
read -s -p 'Repeat New Password: ' REPEAT_NEWPASSWORD
echo ""
if [ "$NEW_PASSWORD" = "$REPEAT_NEWPASSWORD" ]
then
sleep 0.2
echo ""
break
else
echo "${red}Password do not match${reset}"
echo "Try again"
echo ""
fi
done
while true; do
echo "Select OTP Method:"
echo "1 - Mobile"
echo "2 - Email"
echo ""
read -p "Please input: " OTPCHANNEL
if [ "$OTPCHANNEL" = "1" ] || [ "$OTPCHANNEL" = "mobile" ]
then
OTPCHANNEL=mobile
break
elif [ "$OTPCHANNEL" = "2" ] || [ "$OTPCHANNEL" = "email" ]
then
OTPCHANNEL=email
break
else
echo "${red}Invalid Input${reset}"
echo ""
fi
done
OLDPASSCHECHECK=$(curl -s -b $COOKIE $BML_URL/user/changepassword \
--data-raw currentPassword=$OLD_PASSWORD \
--data-raw newPassword=$NEW_PASSWORD \
--data-raw newPasswordConfirmation=$REPEAT_NEWPASSWORD \
--data-raw channel=$OTPCHANNEL \
--compressed \
| jq -r .success)
if [ "$OLDPASSCHECHECK" != "true" ]
then
source changepassword.sh
else
:
fi
if [ "$OTPCHANNEL" = "mobile" ]
then
ECHOOTPCHANNEL=$PHONE
elif [ "$OTPCHANNEL" = "email" ]
then
ECHOOTPCHANNEL=$EMAIL
fi
echo ""
echo "${lightgreen}OTP sent to ${yellow}${ECHOOTPCHANNEL}${reset}"
read -p 'Enter OTP: ' OTP
echo ""
PASSCHANGED=$(curl -s -b $COOKIE $BML_URL/user/changepassword \
--data-raw currentPassword=$OLD_PASSWORD \
--data-raw newPassword=$NEW_PASSWORD \
--data-raw newPasswordConfirmation=$REPEAT_NEWPASSWORD \
--data-raw channel=$OTPCHANNEL \
--data-raw otp=$OTP \
--compressed \
| jq -r .success)
OLD_PASSWORD=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 5)
NEW_PASSWORD=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 5)
REPEAT_NEWPASSWORD=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 5)
if [ "$PASSCHANGED" != "true" ]
then
echo "${red}Failed to change password${reset}"
else
echo "${lightgreen}Password changed succesfully ${reset}"
rm $CREDENTIALS
source readpass.sh
fi

View File

@ -1,39 +0,0 @@
echo ""
echo "Contacts"
echo ""
echo "1 - List Contacts"
echo "2 - Add Contact"
echo "3 - Delete Contact"
echo "4 - Go back"
echo ""
printf 'Please Input: '
read -r CONTACTS
if [ "$CONTACTS" = "1" ]
then
source listcontacts.sh
elif [ "$CONTACTS" = "2" ]
then
source addcontact-menu.sh
elif [ "$CONTACTS" = "3" ]
then
source deletecontact.sh
elif [ "$CONTACTS" = "4" ] || [ "$CONTACTS" = "back" ]
then
sleep 0.2
source mainmenu.sh
elif [ "$CONTACTS" = "clear" ]
then
sleep 0.2
clear
source contactsmenu.sh
elif [ "$CONTACTS" = "exit" ]
then
echo "Cleaning up.."
rm $COOKIE
sleep 0.2
exit
else
echo ${red}Invalid input:${yellow} $CONTACTS ${reset} 1>&2
source contactsmenu.sh
fi

View File

@ -1,17 +0,0 @@
printf "Enter Contact ID: "
read -r CONATACT_ID
DELETESUCCESS=$(curl -s -b $COOKIE $BML_URL/contacts/$CONATACT_ID \
--data-raw _method=delete \
--compressed \
| jq -r .code)
if [ "$DELETESUCCESS" = "0" ]
then
echo Contact Deleted
source contactsmenu.sh
else
echo "${red}There was an error${reset}"
source contactsmenu.sh
fi

View File

@ -1,10 +0,0 @@
#!/bin/bash
cd /tmp/
git clone https://github.com/shihaamabr/bml-cli.git
mkdir -p /opt/sar/bml-cli/
mv bml-cli/* /opt/sar/bml-cli/
echo "#!/bin/bash" > /usr/bin/bml-cli
echo "source /opt/sar/bml-cli/bml.sh" >> /usr/bin/bml-cli
chmod 755 /usr/bin/bml-cli
rm -rf bml-cli/
echo "Installation Complete"

View File

@ -1,3 +0,0 @@
curl -s -b $COOKIE $BML_URL/contacts \
| jq -r '["ID","Account Number","Currency","Account Name","Contact Name"], ["==================================================================="], (.["payload"] | .[] | [.id, .account, .currency, .name, .alias]) | @tsv'
source contactsmenu.sh

View File

@ -1,43 +0,0 @@
#!/bin/bash
#login and generate cookie
LOGIN=$(curl -s -c $COOKIE $BML_URL/login \
--data-raw username=$BML_USERNAME \
--data-raw password=${BML_PASSWORD} \
--compressed \
| jq -r .code)
#check if login was success
if [ "$LOGIN" = "0" ]
then
source savepass.sh
elif [ "$LOGIN" = "20" ]
then
echo "${red}Account Locked!${reset}"
echo "${lightred}Please reset password and login again.${reset}"
echo ""
if [ "$OS" = "macos" ]
then
open $BML_RESETPASS
elif [ "$OS" = "windows" ]
then
cmd.exe /C START $BML_RESETPASS
elif [ "$OS" = "android" ]
then
am start -a android.intent.action.VIEW -d $BML_RESETPASS
else
xdg-open $BML_RESETPASS
fi
source readpass.sh
elif [ "$LOGIN" = "2" ]
then
source readpass.sh
elif [ "$LOGIN" = "37" ]
then
echo "${red}Down for Maintenance${reset}" 1>&2
echo "Try again later"
exit
else
echo "${red}Unknown Error${reset}" 1>&2
exit
fi

View File

@ -1,5 +0,0 @@
rm $CREDENTIALS
rm $COOKIE
echo "Cleaning up.."
sleep 0.4
exit

View File

@ -1,57 +0,0 @@
echo "Main Menu"
echo ""
echo "1 - Accounts"
echo "2 - Transfer"
echo "3 - Contacts"
echo "4 - Activities"
echo "5 - Services"
echo "6 - Settings"
echo ""
printf 'Please Input: '
read -r MENU
if [ "$MENU" = "1" ]
then
echo "WIP"
sleep 2
#source mainmenu.sh
source accounts.sh
elif [ "$MENU" = "2" ]
then
echo "WIP"
sleep 2
source mainmenu.sh
#source transfer.sh
elif [ "$MENU" = "3" ]
then
source contactsmenu.sh
elif [ "$MENU" = "4" ]
then
echo "WIP"
sleep 2
source mainmenu.sh
source activities.sh
elif [ "$MENU" = "5" ]
then
echo "WIP"
sleep 2
source mainmenu.sh
source services.sh
elif [ "$MENU" = "6" ]
then
source settings-menu.sh
elif [ "$MENU" = "clear" ]
then
clear
sleep 0.2
source mainmenu.sh
elif [ "$MENU" = "exit" ]
then
echo "cleaning up..."
rm $COOKIE
sleep 0.2
exit
else
echo ${red}Invalid input:${yellow} $MENU ${reset} 1>&2
source mainmenu.sh
fi

View File

@ -1,26 +0,0 @@
#!/bin/bash
WSL1=$(uname -r | grep -oE Microsoft)
WSL2=$(uname -r | grep -oE microsoft)
MAC=$(uname -a | grep -oE Darwin | tail -n1)
ANDROID=$(uname -a | grep -oE Android)
if [ "$WSL1" = "Microsoft" ] || [ "$WSL2" = "microsoft" ]
then
OS=windows
#echo ${red}WSL Not Supported!${reset} 1>&2
#exit
elif [ "$MAC" = "Darwin" ]
then
OS=macos
export PATH="/usr/local/opt/openssl@1.1/bin:$PATH"
#echo ${red}MacOS Not Supported!${reset} 1>&2
#exit
elif [ "$ANDROID" = "Android" ]
then
OS=android
else
:
fi
source readpass.sh

View File

@ -1,32 +0,0 @@
if [ -f $CREDENTIALS ]
then
source $CREDENTIALS
# echo "Attempting to login with saved credentials"
read -s -p 'Enter Pin: ' PIN
echo ""
BML_USERNAME=$(echo ${BML_USERNAME} |openssl enc -d -des3 -base64 -pass pass:${PIN} -pbkdf2)
BML_PASSWORD=$(echo ${BML_PASSWORD} |openssl enc -d -des3 -base64 -pass pass:${PIN} -pbkdf2)
if [ "$LOGIN" = "2" ]
then
echo "${red}Login Required${reset}"
rm $CREDENTIALS 2> /dev/null
read -p 'Username: ' BML_USERNAME
read -s -p 'Password: ' BML_PASSWORD
echo ""
else
:
fi
elif [ ! -f $CREDENTIALS ]
then
echo "${red}Login Required${reset}"
read -p 'Username: ' BML_USERNAME
read -s -p 'Password: ' BML_PASSWORD
echo ""
else
:
fi
source login.sh

View File

@ -1,37 +0,0 @@
if [ ! -f $CREDENTIALS ]
then
if [ "$LOGIN" = "0" ]
then
read -p 'Do you want to save login? [y/N] ' SAVE_LOGIN
if [ "$SAVE_LOGIN" = "Y" ] || [ "$SAVE_LOGIN" = "y" ]
then
read -s -p 'Enter Pin: ' PIN
echo ""
read -s -p 'Repeat Pin: ' REPEAT_PIN
if [ "$PIN" = "$REPEAT_PIN" ]
then
echo ""
echo "Your credentials are ${lightgreen}encrypted${reset} and saved in $CREDENTIALS"
BML_USERNAME=$(echo "${BML_USERNAME}" | openssl enc -e -des3 -base64 -pass pass:${PIN} -pbkdf2)
BML_PASSWORD=$(echo "${BML_PASSWORD}" | openssl enc -e -des3 -base64 -pass pass:${PIN} -pbkdf2)
echo "BML_USERNAME='${BML_USERNAME}'" > $CREDENTIALS
echo "BML_PASSWORD='${BML_PASSWORD}'" >> $CREDENTIALS
else
echo ""
echo "${red}Pin do not match${reset}"
source savepass.sh
fi
else
:
fi
else
source readpass.sh
fi
else
:
fi
BML_USERNAME=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 5)
BML_PASSWORD=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 5)
source welcome.sh

View File

@ -1,34 +0,0 @@
echo ""
echo "Settings"
echo ""
echo "1 - Logout and Delete saved credentials"
echo "2 - Change Password"
echo "3 - Go Back"
echo ""
printf 'Please Input: '
read -r SETTINGS
if [ "$SETTINGS" = "1" ]
then
source logout.sh
elif [ "$SETTINGS" = "2" ]
then
source changepassword.sh
elif [ "$SETTINGS" = "3" ] || [ "$SETTINGS" = "back" ]
then
source mainmenu.sh
elif [ "$SETTINGS" = "clear" ]
then
sleep 0.2
clear
source settings-menu.sh
elif [ "$SETTINGS" = "exit" ]
then
echo "Cleaning up.."
rm $COOKIE
sleep 0.2
exit
else
echo ${red}Invalid input:${yellow} $SETTINGS ${reset} 1>&2
source settings-menu.sh
fi

View File

@ -1,41 +0,0 @@
#Requesting for User profile after login and regex to grap the Full name
REQPRO=$(curl -s -b $COOKIE $BML_URL/profile)
PERSONALPROFILE=$(echo $REQPRO \
| jq -r '.payload | .profile | .[] | .profile' \
| head -n 1)
curl -s -b $COOKIE $BML_URL/profile \
--data-raw profile=$PERSONALPROFILE \
--compressed > /dev/null
USERINFO=$(curl -s -b $COOKIE $BML_URL/userinfo \
| jq -r '.["payload"] | .["user"]')
NAME=$(echo $USERINFO \
| jq -r .fullname)
PHONE=$(echo $USERINFO \
| jq -r .mobile_phone)
EMAIL=$(echo $USERINFO \
| jq -r .email)
DOB=$(echo $USERINFO \
| jq -r .birthdate \
| cut -d 'T' -f 1)
IDCARD=$(echo $USERINFO \
| jq -r .idcard)
#display a Welcome message with fullname
echo "${red}"
echo "██████╗░███╗░░░███╗██╗░░░░░  ░█████╗░██╗░░░░░██╗"
echo "██╔══██╗████╗░████║██║░░░░░  ██╔══██╗██║░░░░░██║"
echo "██████╦╝██╔████╔██║██║░░░░░  ██║░░╚═╝██║░░░░░██║"
echo "██╔══██╗██║╚██╔╝██║██║░░░░░  ██║░░██╗██║░░░░░██║"
echo "██████╦╝██║░╚═╝░██║███████╗  ╚█████╔╝███████╗██║"
echo "╚═════╝░╚═╝░░░░░╚═╝╚══════╝  ░╚════╝░╚══════╝╚═╝"
echo "${reset}"
echo ${green}Welcome ${reset}$NAME
echo ""
echo ${cyan}Phone${reset}: $PHONE
echo ${cyan}Email${reset}: $EMAIL
echo ${cyan}Birthday${reset}: $DOB
echo ${cyan}ID Card${reset}: $IDCARD
echo ""
source mainmenu.sh