clanner / cocdp

Clash of Clans Documentation Project
218 stars 64 forks source link

How to use cocdecoder.py? #17

Open TheHolyLoli opened 8 years ago

TheHolyLoli commented 8 years ago

Hello,This project is well documented but there is no demo or simple script to show how to decrypt packets. im using client version 7.65 and i wanted to use cocdecoder.py to decode packets but all functions required some information like data,name,decoder or ... but my problem is that i dont know what to do with the Encrypted packet i get directly from client... before calling functions i have to do some proccessing on the packet but i dont know what to do? i would be happy if someone gives me a simple demonstration of usage of this project

clugh commented 8 years ago

To recap our discussion from here:

There was a formatting error on the Protocol wiki page, as it should be len(basekey+"nonce") bytes skipped initially. So the steps would be:

  1. Initialize an RC4 stream with basekey+ "nonce" using the RC4() function provided in rc4.py.
  2. Skip len(basekey+"nonce") bytes in your key stream (see xorstream.py for an example of this).
  3. The critical bit (that seems to be missing from the wiki) is to XOR your payload against the key stream (see the old scramble() function from cocutils.py for an example of how to do it).

cocdecoder.py is used to read the bytes from the decrypted payload into an object.

Note: All of this is obsolete as of the Dec 2015 update.