Git Product home page Git Product logo

cr-patcher's Introduction

Warning: In April 2016, Supercell has started banning accounts for the use of third party software. We are unsure what, if any, checks are in place that might reveal the use of this tool, so continue at your own risk. See here for more info.

cr-patcher

This tool patches the Clash Royale APK. Once applied, your game will connect with the official servers through cr-proxy instead of directly. This allows you to see every message that is sent to and from the server, decrypted and decoded.

Running

Read the installation section before

First, you need an .apk of the game. You can download an official one for example here. Put it to this folder (the one where patcher.py is). The name should match the following format:

<package>-<version>.apk

If you use the official APK, the package is com.supercell.clashroyale, with a file name of com.supercell.clashroyale-1.8.1.apk

Run the script with:

python3.5 patcher.py [--json] version-number

For example:

python3.5 patcher.py 1.8.1

By default, cr-patcher will retrieve the keys, MD5s, and key/URL offsets from the cr-proxy wiki. To provide these values for a new or unknown APK version, enter them in config.json and use the --json flag.

If you need to, enter them with this layout (click to expand)

"versions": {
  "8.212.9": {
    "key": "469b704e7f6009ba8fc72e9b5c864c8e9285a755c5190f03f5c74852f6d9f419",
    "arm": {
      "md5": "769e2e9e1258b75d15cb7e04b2e49de3",
      "key-offset": "4280344",
      "url-offset": "3534513"
    },
    "x86": {
      "md5": "29ca23e48a5e419e83f2a7988c842d3e",
      "key-offset": "6189080",
      "url-offset": "4768816"
    }
  }
}

Config explained

  • debug (true/false) - when set to true, you can use external tools to debug the app while it's running. If you only want to run the proxy, you probably won't need this, but most likely you also won't have any reason to disable this.
  • package - if you somehow changed the package in game files before, change it here also (remember to change the name of .apk). The main reason for changing it is to make it possible to install both the original Clash Royale and your modified version at the same time. This tool doesn't change the package automatically.
  • key - you shouldn't have any reason to change this. The default key guarantees that after patching the game will be able to connect to cr-proxy. If for some reasons you change the key, make sure the proxy is also setup with the same key.
  • url - the address of server which the game will connect to. The default one, game.clashroyaleapp.com, is 23 characters long. Yours also needs to be 23 characters. If you have a domain, you can add a subdomain and redirect it to the proxy. The official server of Clash Royale is running on port 9339, so is the proxy. The game will always look for a server at this port, that's why there is no port field in this config. Also, don't try to add the port like the.ip.here:1337.
  • keystore - if the key used to sign the app changes, you won't be able to update it without uninstalling the previous version before. You can learn more about signing Android apps for example here. Also note, the keypass and dname fields are only required to create a new keystore. See here for how to fill out the dname fields (if you really want to, but that isn't important).
  • paths - paths of executables of different dependencies.
  • versions - if you need to change something here - experiment, ask around, or wait for someone else to do it for you, when a new version is out

Installation

  1. Download the dependencies and install if needed.
  2. Copy the config.json.example file to config.json (so you can do it again when you break something) and fill it in. The changes that you have to make are:
  • in paths, set apktool to the path of your Apktool wrapper script. If you followed the instructions on their website, the path is C:\\Windows\\apktool.bat on Windows and /usr/local/bin/apktool on Linux and Mac.
  • in paths, set zipalign to the path of that program (look at dependencies) Note: On Windows, use either / to separate folders in path, or use double \ -> \\, because of how json works.
  1. You may want to change a few more things in the config
  2. Read the running section

Dependencies

  • Python 3.5 to run this script

  • Apktool - home page - download & install instructions

  • keytool and jarsigner from the Java JDK, on Windows most likely can be found in C:\Program Files\Java\<version>\bin\

  • zipalign from the Android SDK

    If you haven't already, install Android Studio. Open it and download SDK for any version of Android (the one that will be chosen by default, lastest stable, should be fine). Then, you can find zipalign in <sdk-folder>/build-tools/<version>/zipalign(.exe on Windows).

    For example, on Linux, I found it in ~/Android/Sdk/build-tools/25.0.2/zipalign, and on Windows in C:\Program Files (x86)\Android\android-sdk\build-tools\22.0.1\zipalign.exe (remember to double the \ or use / instead)

    If you don't want to download the entire Android Studio, you can scroll the download page down to Get just the command line tools. Download the version for your OS, unzip it, run sdkmanager(.exe) (this program has a gui), download one version of SDK, just like you would do in Android Studio. Rest works like above ^

  • dd - is built in Linux/MAC. For Windows, you can download it here

  • requests and requests-cache

    Note: requests and requests-cache can be installed with:

      python3.5 -m pip install requests requests-cache
    

    To install it this way, you need pip. Check if you have it with pip --version, if you don't, on Ubuntu you can get it with

      apt-get -y install python-pip
    

cr-patcher's People

Contributors

akirarat avatar asdamp avatar clugh avatar nicofisi avatar srabouin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cr-patcher's Issues

Building APK fails

What might the problem be if rebuilding of the .apk fails ??

Patching keys ...
Patching URLs ...
Verifying keys ...
Verifying URLs ...
Backing up original APK ...
Rewriting android manifest /home/pi/python_games/cor_proxy/cr-patcher/com.supercell.clashroyale-1.8.1/AndroidManifest.xml
Building APK ...
ERROR: Failed to build com.supercell.clashroyale-1.8.1 (W: /tmp/brut_util_Jar_1820504874564873883.tmp: 1: /tmp/brut_util_Jar_1820504874564873883.tmp: Syntax error: word unexpected (expecting ")")

and my 2nd question.
Why at all is patching the APK neccessary?
If I modify the Hosts and redirect game.clashroyale to my proxy IP - isn`t this enougth?
So is patching only to change the URL - or is it manditory to get the proxy working?

It wont work for me.

C:\Users\no\Desktop\cr-patcher-master>"C:\Users\Omrtha\AppData\Local\Programs\Python\Python36-32\python.exe" patcher.py --json 1.9.2
Getting config ...
Checking environment ...
client.keystore does not exist. Would you like to create it? (y/n): y
Traceback (most recent call last):
File "patcher.py", line 137, in
result = subprocess.run([config['paths']['keytool'], '-genkey', '-keystore', KEYSTORE_PATH, '-storepass', config['keystore']['storepass'], '-alias', config['keystore']['key']['alias'], '-keypass', config['keystore']['key']['keypass'], '-dname', dname, '-keyalg', 'RSA', '-keysize', '2048', '-validity', '10000'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
File "C:\Users\no\AppData\Local\Programs\Python\Python36-32\lib\subprocess.py", line 403, in run
with Popen(*popenargs, **kwargs) as process:
File "C:\Users\no\AppData\Local\Programs\Python\Python36-32\lib\subprocess.py", line 707, in init
restore_signals, start_new_session)
File "C:\Users\no\AppData\Local\Programs\Python\Python36-32\lib\subprocess.py", line 990, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified

Help me out,
thanks

Too many DEPENDENCIES

That has WAY too many dependencies, please at least make some packages of it with the Java tools included

Can't obtain zipalign

I've downloaded the Android SDK (SDK only, without the IDE and such), but there is no file called zipalign. Also the folder hierarchy used in the readme to show where the file should be doesn't match what I have.

Can I just download it without the suite somehow? Or do I need to download an older version or something?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.