Skip to main content

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")

Metadata

Release files for bcps 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bcps 0.0.2
File Size Uploaded Provenance
bcps-0.0.2.tar.gz 19.2 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for bcps 0.0.2
File Interpreter ABI Platform
bcps-0.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 37.1 kB

Release files / bcps-0.0.2.tar.gz

Download URL bcps-0.0.2.tar.gz
Size 19.2 kB
Tags Source
SHA-256 checksum
How to use checksums
0f50db2c1f1f44fa15df856eea7405fd1bdc778b0ed8a6819111b43be43a6cc0
BLAKE2b-256 checksum
How to use checksums
a37b5a3e6ea141d713ba23d103e8b4f0805cf5af622bb78065afb4bc3a4701c6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release files / bcps-0.0.2-py3-none-any.whl

Download URL bcps-0.0.2-py3-none-any.whl
Size 17.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
eed668834aa962c08bcfce2769cb56d7cbad718b8b9650e3b8524a18906d2ad5
BLAKE2b-256 checksum
How to use checksums
e04afb7d3a032894694b72ca008926564e3526e6246ac7080d2ddbf04fab358b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Security for bcps 0.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page