added support for multiple profile

This commit is contained in:
Shihaam Abdul Rahman 2021-05-12 06:35:36 +05:00
parent 0c4cb4cb07
commit 03a17feb6e
6 changed files with 18 additions and 114 deletions

View File

@ -1,93 +0,0 @@
#!/bin/bash
source .env
BML_URL='https://www.bankofmaldives.com.mv/internetbanking/api'
COOKIE=/tmp/bmlcookie
red=`tput setaf 1`
green=`tput setaf 2`
reset=`tput sgr0`
LOGIN=$(curl -s -c $COOKIE $BML_URL/login \
--data-raw username=$BML_USERNAME \
--data-raw password=$BML_PASSWORD \
--compressed \
| jq -r .success)
if [ "$LOGIN" = "true" ]
then
NAME=$(curl -s -b $COOKIE $BML_URL/profile \
| awk -F 'fullname":"' '{print $2}' \
| cut -f1 -d '"')
echo ""
echo ${green}Welcome ${reset}$NAME
# curl -s -b $COOKIE $BML_URL/userinfo
echo ""
else
echo "${red}An error occured, Please check Username and Password" 1>&2
rm $COOKIE 2> /dev/null
exit
fi
echo "Menu"
echo ""
echo "1 - Accounts"
echo "2 - Contacts"
echo "3 - Activities"
echo "4 - Services"
echo "5 - Settings"
echo ""
printf 'Please Input: '
read -r MENU
if [ "$MENU" = "1" ]
then
curl -s -b $COOKIE $BML_URL/dashboard | jq
elif [ "$MENU" = "2" ]
then
echo ""
echo "Contacts"
echo ""
echo "1 - Transfer"
echo "2 - Add Contact"
echo "3 - Delete Conact"
echo ""
printf 'Please Input: '
read -r CONTACS
if [ "$CONTACS" = "1" ]
then
curl -s -b $COOKIE $BML_URL/contacts | jq -r '["Account Number","Currency","Account Name","Contact Name"], ["==================================================================="], (.["payload"] | .[] | [.account, .currency, .name, .alias]) | @tsv'
elif [ "$CONTACS" = "2" ]
then
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
printf 'Name: '
read -r ACCOUNT_NAME
curl -s -b $COOKIE $BML_URL | jq
else
echo "${red}Invalid Account" 1>&2
fi
elif [ "$CONTACS" = "3" ]
then
echo ""
else
exit
fi
elif [ "$MENU" = "3" ]
then
curl -s -b $COOKIE $BML_URL/activities | jq
elif [ "$MENU" = "4" ]
then
curl -s -b $COOKIE $BML_URL/services/applications/context | jq
elif [ "$MENU" = "5" ]
then
curl -s -b $COOKIE $BML_URL/settings | jq
else
echo "${red}There was an error"
fi

View File

@ -1,13 +0,0 @@
#!/bin/bash
source .env
BML_URL='https://www.bankofmaldives.com.mv/internetbanking/api'
COOKIE=/tmp/bmlcookie
curl -s -c $COOKIE $BML_URL/login \
--data-raw username=$BML_USERNAME \
--data-raw password=$BML_PASSWORD \
--compressed > /dev/null
curl -s -b $COOKIE $BML_URL/profile > /dev/null
#curl -s -b $COOKIE $BML_URL/contacts
curl -s -b $COOKIE $BML_URL/validate/account/7704265806101

View File

@ -10,19 +10,17 @@ TG_BOTAPI='https://api.telegram.org/bot'
BML_URL='https://www.bankofmaldives.com.mv/internetbanking/api'
mkdir -p ~/.cache/bml-cli/
COOKIE=~/.cache/bml-cli/cookie
LOGIN=$(curl -s -c $COOKIE $BML_URL/login \
--data-raw username=$BML_USERNAME \
--data-raw password=${BML_PASSWORD} \
--compressed \
| jq -r .code)
LOGIN=$(curl -s -c $COOKIE $BML_URL/login --data-raw username=$BML_USERNAME --data-raw password=${BML_PASSWORD} | jq -r .code)
if [ "$LOGIN" = "0" ]
then
:
PROFILE=$(curl -s -b $COOKIE $BML_URL/profile | jq -r '.payload | .profile | .[] | .profile' | head -n 1)
curl -s -b $COOKIE $BML_URL/profile --data-raw profile=$PROFILE > /dev/null
else
echo Something went wrong
exit
fi
curl -s -b $COOKIE $BML_URL/profile > /dev/null
while true; do
CHECKDIFF1=$(echo $HISTORY | wc -c)
HISTORY=$(curl -s -b $COOKIE $BML_URL/account/$BML_ACCOUNTID/history/today | jq -r '.payload | .history | .[]')

View File

@ -31,7 +31,7 @@ else
fi
#Set DHIRAAGU_IP, login with generated cookie and some regex to extract Dhiraagu IP address
DHRAAGU_IP=$(curl -s -b /tmp/dcookies \
DIHRAAGU_IP=$(curl -s -b /tmp/dcookies \
$DHIRAAGU_HOME_URL \
| grep 'IP Address' -A1 \
| tail -n1 \

View File

@ -0,0 +1 @@

View File

@ -0,0 +1,11 @@
read -p 'Username: ' BML_USERNAME
read -s -p 'Enter Pin: ' PIN
read -s -p 'Repeat Pin: ' REPEAT_PIN
if [ "$PIN" = "$REPEAT_PIN" ]
then
echo $BML_USERNAME | PASS=$(openssl aes-256-cbc -a -salt -pass pass:$PIN)
echo $PASS > bruh
else
echo "Pin do not match"
fi