Compare commits

...

7 Commits

Author SHA1 Message Date
a97d52bc59 update user agent
All checks were successful
Build and Push Docker Images / Build and Push Docker Images (push) Successful in 47s
2025-01-10 09:31:04 +05:00
80eb74c65c add jq to keep alive
All checks were successful
Build and Push Docker Images / Build and Push Docker Images (push) Successful in 1m20s
2025-01-10 08:24:12 +05:00
470df69c56 auto build
All checks were successful
Build and Push Docker Images / Build and Push Docker Images (push) Successful in 1m50s
2025-01-10 08:19:47 +05:00
c2ab2ea996 add the cookie server script to docker.... 2025-01-10 08:18:24 +05:00
37dfe7e261 update docs 2025-01-10 08:10:59 +05:00
a72f22b9a4 build cookie server 2025-01-10 07:59:41 +05:00
0e60f139ef added support for cookie server 2025-01-10 07:52:09 +05:00
12 changed files with 95 additions and 6 deletions

View File

@@ -9,3 +9,8 @@ services:
context: ../../ context: ../../
dockerfile: .build/prod/api.Dockerfile dockerfile: .build/prod/api.Dockerfile
image: git.shihaam.dev/shihaam/mib-payment-verify/api image: git.shihaam.dev/shihaam/mib-payment-verify/api
cookieserver:
build:
context: ../../
dockerfile: .build/prod/cookieserver.Dockerfile
image: git.shihaam.dev/shihaam/mib-payment-verify/cookieserver

View File

@@ -0,0 +1,10 @@
FROM python:3.9.20-slim-bookworm
RUN pip install beautifulsoup4 pyotp Flask python-dotenv requests
RUN apt-get update && apt-get install -y curl jq && apt-get clean && rm -rf /var/lib/apt/lists/*
WORKDIR /app
COPY getcookie.py .
CMD python getcookie.py

View File

@@ -1,6 +1,6 @@
FROM debian:bullseye-slim FROM debian:bullseye-slim
RUN apt-get update && apt-get install -y curl && apt-get clean && rm -rf /var/lib/apt/lists/* RUN apt-get update && apt-get install -y curl jq && apt-get clean && rm -rf /var/lib/apt/lists/*
WORKDIR /app WORKDIR /app
COPY keepalive.sh . COPY keepalive.sh .

View File

@@ -6,6 +6,8 @@ PROFILE_ID=
PROFILE_TYPE= PROFILE_TYPE=
ACCOUNT_NUMBER= ACCOUNT_NUMBER=
COOKIE_SERVER=http://cookieserver:5000
APP_DEBUG=true APP_DEBUG=true
## This valu is for time difference between request json and actual time of the transacation (+ or -) in mins, 5 or 10 is probably a good value ## This valu is for time difference between request json and actual time of the transacation (+ or -) in mins, 5 or 10 is probably a good value

View File

@@ -0,0 +1,37 @@
name: Build and Push Docker Images
on:
push:
branches:
- main
- master
pull_request:
branches:
- main
- master
jobs:
docker:
name: Build and Push Docker Images
runs-on: builder
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Build Docker images
working-directory: .build/prod
run: docker compose build
- name: Login to Docker Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
registry: ${{ vars.DOCKER_REGISTRY_URL }}
username: ${{ vars.DOCKER_REGISTRY_USER }}
password: ${{ secrets.DOCKER_REGISTRY_PASSWORD }}
- name: Push Docker images
if: github.event_name != 'pull_request'
working-directory: .build/prod
run: docker compose push

View File

@@ -8,15 +8,20 @@
## How to deploy/get started (with docker/podman) ## How to deploy/get started (with docker/podman)
1. Login to MIB web [https://faisanet.mib.com.mv/](https://faisanet.mib.com.mv/) and get the cookie: 1. Login to MIB web [https://faisanet.mib.com.mv/](https://faisanet.mib.com.mv/) and get the your profile id and type:
![get_cookie_env.jpg](get_cookie_env.jpg) ![select_profile.jpg](select_profile.jpg)
2. copy .env.example to .env and fill `QL_0` and `IBSID` with contents from step 1, Make sure to fill `ACCOUNT_NUMBER` with your account number. 2. copy .env.example to .env and fill your MIB Username, Password and TOTP Seed, `PROFILE_ID` and `PROFILE_TYPE` needs to be filled with contents from step 1, Make sure to fill `ACCOUNT_NUMBER` with your account number.
3. Create `compose.yml` with the follwing contents: 3. Create `compose.yml` with the follwing contents:
```yaml ```yaml
services: services:
keepalive: keepalive:
env_file: .env env_file: .env
image: git.shihaam.dev/shihaam/mib-payment-verify/keepalive image: git.shihaam.dev/shihaam/mib-payment-verify/keepalive
cookieserver:
env_file: .env
image: git.shihaam.dev/shihaam/mib-payment-verify/cookieserver
api: api:
env_file: .env env_file: .env
image: git.shihaam.dev/shihaam/mib-payment-verify/api image: git.shihaam.dev/shihaam/mib-payment-verify/api
@@ -24,7 +29,7 @@ services:
- 5000:5000 - 5000:5000
``` ```
3. Run `docker compose up -d` and that is all. 4. Run `docker compose up -d` and that is all.
## Using the API with curl examples: ## Using the API with curl examples:

View File

@@ -2,6 +2,9 @@ services:
keepalive: keepalive:
env_file: .env env_file: .env
image: git.shihaam.dev/shihaam/mib-payment-verify/keepalive image: git.shihaam.dev/shihaam/mib-payment-verify/keepalive
cookieserver:
env_file: .env
image: git.shihaam.dev/shihaam/mib-payment-verify/cookieserver
api: api:
env_file: .env env_file: .env
image: git.shihaam.dev/shihaam/mib-payment-verify/api image: git.shihaam.dev/shihaam/mib-payment-verify/api

View File

@@ -4,6 +4,10 @@ source .env 2> /dev/null
accountNo=$1 accountNo=$1
COOKIE=$(curl -s $COOKIE_SERVER/getcookie)
IBSID=$(echo $COOKIE | jq -r .IBSID)
QL_0=$(echo $COOKIE | jq -r .ql_0)
curl -s 'https://faisanet.mib.com.mv/ajaxBeneficiary/getAccountName' \ curl -s 'https://faisanet.mib.com.mv/ajaxBeneficiary/getAccountName' \
-H "cookie: ql_0=${QL_0}; IBSID=${IBSID}" \ -H "cookie: ql_0=${QL_0}; IBSID=${IBSID}" \
--data-raw "accountNo=${accountNo}" --data-raw "accountNo=${accountNo}"

View File

@@ -11,7 +11,7 @@ class MIBLogin:
def __init__(self): def __init__(self):
self.base_url = "https://faisanet.mib.com.mv" self.base_url = "https://faisanet.mib.com.mv"
self.headers = { self.headers = {
"User-Agent": "Mozilla/5.0 (give-api) ismath-owes-me-real-api/give-real-api AppleWebKit/537.36 (KHTML, like Gecko) Safari/537.36", "User-Agent": "Mozilla/5.0 (ismath-said-will) give-real-api/so-i-wont-have-to-do-this AppleWebKit/537.36 (KHTML, like Gecko) Safari/537.36",
"Accept": "*/*" "Accept": "*/*"
} }
self.last_cookie = None self.last_cookie = None

View File

@@ -1,15 +1,34 @@
#!/bin/bash #!/bin/bash
request_new_cookie(){
curl -s $COOKIE_SERVER/newcookie > /dev/null
}
while true; do while true; do
source .env 2> /dev/null source .env 2> /dev/null
# Get current date and time # Get current date and time
CURRENT_TIME=$(date -u '+%Y-%m-%dT%H:%M:%S.%3NZ') CURRENT_TIME=$(date -u '+%Y-%m-%dT%H:%M:%S.%3NZ')
COOKIE=$(curl -s $COOKIE_SERVER/getcookie)
IBSID=$(echo $COOKIE | jq -r .IBSID)
QL_0=$(echo $COOKIE | jq -r .ql_0)
# Make the keep-alive request # Make the keep-alive request
KEEP_ALIVE=$(curl -s 'https://faisanet.mib.com.mv/aProfile/keepAlive' \ KEEP_ALIVE=$(curl -s 'https://faisanet.mib.com.mv/aProfile/keepAlive' \
-X 'POST' \ -X 'POST' \
-H "cookie: ql_0=${QL_0}; IBSID=${IBSID}") -H "cookie: ql_0=${QL_0}; IBSID=${IBSID}")
# Check for session expiration
SUCCESS=$(echo "$KEEP_ALIVE" | jq -r .success)
RESPONSE_CODE=$(echo "$KEEP_ALIVE" | jq -r .responseCode)
if [[ "$SUCCESS" == "false" && "$RESPONSE_CODE" == "3" ]]; then
echo "Session expired. Requesting new cookie..."
request_new_cookie
continue # Restart the loop
fi
# Remove the last closing brace from KEEP_ALIVE # Remove the last closing brace from KEEP_ALIVE
KEEP_ALIVE_MODIFIED=${KEEP_ALIVE%?} KEEP_ALIVE_MODIFIED=${KEEP_ALIVE%?}

BIN
select_profile.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 67 KiB

4
tx.sh
View File

@@ -2,6 +2,10 @@
source .env 2> /dev/null source .env 2> /dev/null
COOKIE=$(curl -s $COOKIE_SERVER/getcookie)
IBSID=$(echo $COOKIE | jq -r .IBSID)
QL_0=$(echo $COOKIE | jq -r .ql_0)
curl 'https://faisanet.mib.com.mv/ajaxAccounts/trxHistory' \ curl 'https://faisanet.mib.com.mv/ajaxAccounts/trxHistory' \
-H "cookie: ql_0=${QL_0}; IBSID=${IBSID}" \ -H "cookie: ql_0=${QL_0}; IBSID=${IBSID}" \
--data-raw "accountNo=${ACCOUNT_NUMBER}&trxNo=&trxType=0&sortTrx=date&sortDir=desc&fromDate=&toDate=&start=1&end=20&includeCount=1" -s \ --data-raw "accountNo=${ACCOUNT_NUMBER}&trxNo=&trxType=0&sortTrx=date&sortDir=desc&fromDate=&toDate=&start=1&end=20&includeCount=1" -s \