Skip to main content

A private server for The Battle Cats

Project description

Battle Cats Private Server

A private server for the mobile game The Battle Cats built with Flask, tbcml, and Frida.

Note that if you just want to have a custom mailbox, I suggest that you use mailboxhack instead as it doesn't need a private server.

ko-fi

Installation

  1. Clone the repository

    git clone https://codeberg.org/fieryhenry/bcps.git
    cd bcps
    

    To pull the latest changes from the repository you can run the following command. Make sure you are in the bcps directory.

    git pull
    
  2. Install with pip

    If pip is in your PATH:

    pip install -e .
    

    If pip is not in your PATH:

    Windows:

    py -m pip install -e .
    

    Everything else:

    python -m pip install -e .
    

Setting up the APK

  1. Install tbcml including the scripting dependencies.

  2. Run the setup script. Use the --help flag for more information about the available options. Such as country code, game version, and adb.

python scripts/setup_script.py --help

You need to specify the url to the server in the --url option. The url needs to be https otherwise the game will not send the request. A way to get around this is to use a reverse proxy such as ngrok, or serveo to handle this for you. I have used serveo as you can set a custom subdomain and it seems to work well.

ssh -R custom_subdomain:80:localhost:5000 serveo.net

This gives you a url like https://custom_subdomain.serveo.net. You can then use this url in the --url option.

python scripts/setup_script.py --url https://custom_subdomain.serveo.net

You can also specify the country code and game version. The country code is en by default and the game version is 13.1.1 by default. You can specify the country code and game version with the --cc and --gv options respectively.

python scripts/setup_script.py --url https://custom_subdomain.serveo.net --cc "en" --gv "13.1.1"

The setup script does auto-download the apk for you, but if you already have an apk you can specify the path to the apk with the --apk option.

python scripts/setup_script.py --url https://custom_subdomain.serveo.net --apk "path/to/apk"

If you have adb setup and want to install the apk to your device automatically you can use the --adb option, and optionally the --adb_run_game flag to start the game after the apk is installed.

python scripts/setup_script.py --url https://custom_subdomain.serveo.net --adb --adb_run_game

You can change the package name and app name with the --package_name and --app_name options respectively. The default package name is jp.co.ponos.battlecatsen and the default app name is The Battle Cats for en.

python scripts/setup_script.py --url https://custom_subdomain.serveo.net --package_name "jp.co.ponos.battlecatsen" --app_name "The Battle Cats" 

The game will log the url it is sending requests to. If you want to see this run adb logcat with the tag tbcml if you have adb setup.

adb logcat -s tbcml

Running the server

  1. Run the server
python -m bcps

You should pass in --regexes, which is a list to specify which urls should be redirected to the private server. The default is .* which is all urls.

python -m bcps --regexes "presents" "events"

You can pass in a specific host and port with the --host and --port options respectively. The defaults are shown below.

python -m bcps --host 0.0.0.0 --port 5000

To run in debug mode you can use the --debug flag.

python -m bcps --debug

Adding your own endpoints

The server comes with a mailbox example blueprint in src/bcps/blueprints/presents. You should read the Flask documentation to understand how to create your own endpoints.

Note that the frida script also forces the verification of the nyanko signture, so as long as the Nyanko-Signature header is present, the server will accept the request. (see present.py for an example of how to do this.)

Note that any url that is redirected to the private server always starts with a prefix of /api.

You should place your blueprints in the src/bcps/blueprints directory. You can then add the blueprint to the app in the src/bcps/blueprints/__init__.py file.

You can access the domain the game sent the original request to with the domain query parameter.

from flask import request
# ...
domain = request.args.get("domain")

You can also get the package name and version of the game with the package_name and package_version query parameters.

from flask import request
# ...
package_name = request.args.get("package_name")
package_version = request.args.get("package_version")

You can also get the game's request handle with the req_handle query parameter. This is used by the game to determine what function should be run after the request is completed. This probably isn't useful for most people, but it is there if you need it.

from flask import request
# ...
req_handle = request.args.get("req_handle")

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bcps-0.0.2.tar.gz (19.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bcps-0.0.2-py3-none-any.whl (17.9 kB view details)

Uploaded Python 3

File details

Details for the file bcps-0.0.2.tar.gz.

File metadata

  • Download URL: bcps-0.0.2.tar.gz
  • Upload date:
  • Size: 19.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for bcps-0.0.2.tar.gz
Algorithm Hash digest
SHA256 0f50db2c1f1f44fa15df856eea7405fd1bdc778b0ed8a6819111b43be43a6cc0
MD5 f85cbcf98786b1d3a08073ba95b575a6
BLAKE2b-256 a37b5a3e6ea141d713ba23d103e8b4f0805cf5af622bb78065afb4bc3a4701c6

See more details on using hashes here.

File details

Details for the file bcps-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: bcps-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 17.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for bcps-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 eed668834aa962c08bcfce2769cb56d7cbad718b8b9650e3b8524a18906d2ad5
MD5 62ed90f691d0930c652d69d8f2238a99
BLAKE2b-256 e04afb7d3a032894694b72ca008926564e3526e6246ac7080d2ddbf04fab358b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page