diff --git a/docs/implementing-patches.-.md b/docs/implementing-patches.-.md new file mode 100644 index 0000000..fd613ca --- /dev/null +++ b/docs/implementing-patches.-.md @@ -0,0 +1,58 @@ +## Implementing patches +- patch template is implemented by @fukiame from this commit : aa4eb65992 so just need to follow their `TEMPLATE` +- they well documented it on the commit message : +``` +adding new patches is now trivial: + + cd patches + cp TEMPLATE patch_name_whatever.sh + # then just fill in patch name and ver clamp if desired + +this gets rid of the need for excessive if-elses and not-so-pleasing indents + +for logging, instead of using pure echo, 4 new "levels" can be utilized +- `info` : normal +- `good` : info but have green color? +- `warn` : warning +- `err` : error +``` + +- they even implemented the sed that patching libapp to one function, called `sed_libapp` so you just need to call them and define it a value + + example : +``` +sed_libapp 's|{old string}|{new string}|g' +``` +- note that the old string and new string MUST be at the same character length in order to not breaking `libapp.so` ELF header + +same thing with `AndroidManifest.xml` too, called `manifest_remove` +``` +manifest_remove "android.manifest.YouWantedToRemove" +``` +- `get_mb_ver` function is used to get MB app version by reading version code + +- but that is not actually enough, you have to do smth that is patching the app, like `rm`, `sed`, `mv` operation. below is the example. you can literally do anything you wanted to mess up in the patches file : +``` +#!/usr/bin/env bash +# PATCHNAME: Remove banners & MiniApp +# MAXVER: 67 +# MINVER: +# shellcheck disable=SC1091 +. "$DIRPATH"/common.sh + +sed_libapp 's|banner|remove|g' +sed_libapp 's|marketplacehome|removemarketapp|g' + +info 'Moving links...' +sed_libapp 's|https://miniappgw.mbbank.com.vn/homebox/webview/auth?|https://git.disroot.org/mbcp/info/wiki/MiniApp?ref=mb|g' +sed_libapp 's|https://miniappgw-uat.mbbank.com.vn/homebox-public/|https://git.disroot.org/mbcp/info/wiki/MiniApp?refs|g' + +info 'Removing related resources...' +rm -rf 'mbapk/mbapk_unpacked/root/assets/flutter_assets/packages' +rm -f 'mbapk/mbapk_unpacked/root/assets/flutter_assets/assets/images/dynamic/base/billing_img_defaultBanner.webp' +rm -f 'mbapk/mbapk_unpacked/root/assets/flutter_assets/assets/images/dynamic/base/billing_img_defaultBanner.private.webp' +rm -f 'mbapk/mbapk_unpacked/root/assets/flutter_assets/assets/images/dynamic/base/explore_img_defaultBanner.webp' +rm -f 'mbapk/mbapk_unpacked/root/assets/flutter_assets/assets/images/dynamic/base/coreBanking_img_successBanner.webp' +rm -f 'mbapk/mbapk_unpacked/root/assets/flutter_assets/assets/images/dynamic/base/homeLanding_img_defaultBanner.webp' +rm -f 'mbapk/mbapk_unpacked/root/assets/flutter_assets/assets/images/dynamic/base/homeLanding_img_defaultBanner.private.webp' +``` \ No newline at end of file diff --git a/docs/patcher-dependencies.-.md b/docs/patcher-dependencies.-.md new file mode 100644 index 0000000..37e47db --- /dev/null +++ b/docs/patcher-dependencies.-.md @@ -0,0 +1,12 @@ +## MBCPApp Patcher are using those dependencies : +- GNU `sed` : https://www.gnu.org/software/sed/ +- GNU `wget` : https://www.gnu.org/software/wget/ +- GNU `bash` : https://www.gnu.org/software/bash/ +- `figlet` : https://www.figlet.org/ +- `xmlstarlet` : https://xmlstar.sourceforge.net/ +- `openjdk` : https://openjdk.org/ +- `git` : https://git-scm.com/ +- `platform-tools` : https://developer.android.com/tools/releases/platform-tools + +## Project Development : +- `nvim` : https://github.com/neovim/neovim \ No newline at end of file diff --git a/docs/patcher-usage.-.md b/docs/patcher-usage.-.md new file mode 100644 index 0000000..5a0a9ad --- /dev/null +++ b/docs/patcher-usage.-.md @@ -0,0 +1,114 @@ +## Requirements +> [!warning] +> **AI-powered** forks are not suitable with this docs! USE ANOTHER FORK ! + +- Any actual Linux environment or macOS (Arch Linux based recommended) +- Little knowledge about terminal commands +- `android-tools` `wget` for Arch/Fedora based and `android-sdk-platform-tools` for Debian based +- `android-platform-tools` for macOS with brew +- `git` installed +- `java` or `jdk-openjdk` installed +- `figlet` for showing banner (optional) +- `xmlstarlet` for reformatting AndroidManifest after unpacking + + +## Install dependencies + +for Arch Linux / EndeavourOS / CachyOS / any Arch-based distributions (except Manjaro as it's usually break system packages) +``` +sudo pacman -Sy android-tools wget jdk-openjdk figlet xmlstarlet git +``` +for Debian / Mint / Ubuntu / any debian-based distributions +``` +sudo apt install android-sdk-platform-tools xmlstarlet figlet wget git default-jre +``` +for Fedora / any fedora-based distributions +``` +sudo dnf makecache --refresh +sudo dnf -y install wget xmlstarlet android-tools java-latest-openjdk.x86_64 +git clone https://github.com/M0Rf30/android-udev-rules.git +cd android-udev-rules +sudo bash install.sh +``` + +for macOS (brew) +``` +brew install xmlstarlet wget openjdk android-platform-tools figlet gnu-sed +sudo ln -sfn /opt/homebrew/opt/openjdk/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk.jdk +PATH="/usr/local/opt/gnu-sed/libexec/gnubin:$PATH" +``` + +## Clone repository +You can choose between 2 repository mirrors, one is the repository on Disroot, and the other one is the Selfhosted Forgejo instance, it has no difference as both are pushed at the same time. + +DIsroot +``` +cd ~ +git clone https://git.disroot.org/mbcp/mbbpatch.git +cd mbbpatch/MBCPApp +``` +Self-hosted Instance +``` +cd ~ +git clone http://cuynutt.ddns.net/mbcp/mbbpatch.git +cd mbbpatch/MBCPApp +``` + +## Run the Patcher +Ensure that you already in following folder to continue : `~/mbbpatch/MBCPApp` +``` +./mbcpapp.sh +``` +- Download tools with `14) Download tools` function first, it will download `apktool` and `apkeditor` to `tools` folder. This is required since `2) Unpack APK` function requires it. + +## Patch the app + +> [!IMPORTANT] +> If you are patching MB Bank with those version : +> +> MB Bank : v6.4.63 | v6.4.64 | v6.4.65 | v6.4.66 +> +> Ensure that you applied `Bypass GW934 checksum` patch after applied all other patches, so the app can works without GW934 error when logging in. + +- Grab MB Bank apks from [eMBee APKs](https://t.me/embeeapks) or [Lotus Chat](https://lotuschat.vn/w/+anSH1BbDbAYn54JC9nIC9A) (in case if you don't have access to Telegram) and copy it to `~/mbbpatch/MBCPApp/mbapk` +- Alternatively, if you don't have access to both Telegram & Lotus Chat, download from [Google Play](https://play.google.com/store/apps/details?id=com.mbmobile) then extract the MB Bank apks and copy it to `~/mbbpatch/MBCPApp/mbapk` or get it [from my instance](http://cuynutt.ddns.net/mbcp/mbmobile-apks) +- Convert apks to apk first using `3) Convert apks to apk` function +- Unpack apk with `2) Unpack apk` function +- Use `7) Patch App` function, it should show a list of patches, select the patch you wanted to and it will automatically patch the app at `mbapk/mbapk_original` +- Note that the patches list might different, depends on your current unpacked MB Bank app version, as there will be a patch that compatible with specific version, for example patch [Bypass accessibility & malicious apps check] is compatible with v6.4.54, but not with v6.4.55 or newer, so if you have v6.4.55 or newer, then that patch will be hidden from patches list. +- The patcher should show info to the log when use `7) Patch App` function if it found that the current unpacked app version is not compatible with one of implemented patches like this : +``` +[INFO] [parser] skipping [Patch A] as current version is higher than patch version clamp +[INFO] [parser] skipping [Patch B] as current version is lower than patch version clamp +``` +- View full patches list [here](/mbcp/mbbpatch#patches-list) for more info about compatible version, or view the `MAXVER` value and `MINVER` in patch files `~/mbbpatch/MBCPApp/patches/*.sh` + +## Repack the app +- So you have applied all the patches you wanted to ? +- Exit patch app function with the exit option in the last patch list +- Use `4) Repack APK` to repack patched app +- What's next? wait :) +- Patcher will repack the app, and then [restore signature]() to make sure that app can load, the example of nice repack process : +``` +00.000 I: [BUILD] Using: APKEditor version 1.4.5, ARSCLib version 1.3.8 + -t = sig + -dex-lib = internal + -sig = mbsig/signatures + -i = mbcpapp_apk/MBCP_Flutter_TMP.apk + -o = mbcpapp_apk/MBCP_Flutter_SelfPatched.apk + _______________________________________________________ +00.013 I: [BUILD] Restoring signatures ... +00.214 I: [BUILD] Writing apk... +00.217 I: [BUILD] Buffering compress changed files ... +00.226 I: [BUILD] Writing files: 3332 +00.453 I: [BUILD] Writing signature block ... +00.909 I: [BUILD] Saved to: mbcpapp_apk/MBCP_Flutter_SelfPatched.apk +[19:45:55:70] [INFO] Completed! Repacked APK are saved as [mbcpapp_apk/MBCP_Flutter_SelfPatched.apk] !!! +[19:45:55:70] [INFO] Install and trying to open it when ಠ‿ಠ +[19:45:55:70] [INFO] If you are facing issues, report it on Telegram [@mbbpatch_eng] or Disroot Forgejo : mbbpatch !! +``` +- Patched app will be `MBCP_Flutter_SelfPatched.apk` on `~/mbbpatch/MBCPApp/mbcpapp_apk/` +- As this is unsigned app, Android will refuse to install `MBCP_Flutter_SelfPatched.apk` by default. In order to install it, you MUST install [MBCP Helper](/mbcp/mbcp-helper/releases) or [CorePatch](https://github.com/LSPosed/CorePatch/releases) and enable the "Disable digest verify" option to bypass android package signature verification. +- If you don't know how to deal with MBCP Helper, follow this guide : [MBCP Installation](/mbcp/info_en/wiki/mbcpinstall) +- Copy this `MBCP_Flutter_SelfPatched.apk` then install to your device, or simply use `5) Install patched app` function, its will do the same thing with `adb` +- Profit :)