Closed mrqaidi closed 8 years ago
Add 'gamea.clashofclans.com' with your network IP address to the hosts file in your android device.
can i use or do you know proxycap method
Did you change the URL when you patched the APK?
no i did not change any url can you tell me where ?
In the config.json file. The URL must be exactly 22 characters long. If you don't use a local IP or hostname, you'll have to forward your ports. If you don't already know how to to do that, I suggest using the Hosts Editor method, which requires root.
i can see in config URL: gamea.clashofclans.com to where o i have to pint this in my hosts
gamea.clashofclans.com is the default URL. You can change that value in the config.json file to change it when you patch the APK.
If you keep it, use Hosts Editor (requires root) with that URL and your server's local IP address.
If you change it, the notes in my previous reply apply.
i put 127.0.0.1 but its not working i am getting unable to connect ot server
Bluestacks is a virtual machine, so you can't use 127.0.0.1. You'll have to use your machine's local IP address. The simplest way to find it would be to run ipconfig
.
from ipconfig i see these
Link-local IPv6 Address . . . . . : fe80::e9ae:50e2:9b10:a208%14(Preferred) IPv4 Address. . . . . . . . . . . : 192.168.0.11(Preferred) i used ipv4 still no luck
i forget to run coc-proxy while run game now i got this error
C:\Users\Ayman\Desktop\CoCSharp.Server\coc-proxy>python proxy.py
listening on 0.0.0.0:9339 ...
connection from 192.168.0.11:50951 ...
connected to 54.87.212.62:9339 ...
10100 Error: 'Message definition missing (10100).'
10100 2774000048000000000001000000070000000800000000000000d400000028363134316138393739333633316165326661356163653438366164316334333961353137616161620000000200000002
20100 Error: 'Message definition missing (20100).'
20100 4e8400001c0000000000188268e54240a335c5f411eb607c314c68ab4d7656805e36fb
Failed to decrypt the message (server, 10101).
connection from 192.168.0.11:50951 closed ...
connection to 54.87.212.62:9339 closed ...
fxed by putting messes files but now i got this
C:\Users\Ayman\Desktop\CoCSharp.Server\coc-proxy>python proxy.py
listening on 0.0.0.0:9339 ...
connection from 192.168.0.11:51332 ...
connected to 54.163.131.20:9339 ...
ClientHandshake: {
"unknown_0": 1,
"unknown_1": 7,
"majorVersion": 8,
"unknown_3": 0,
"minorVersion": 212,
"masterHash": "6141a89793631ae2fa5ace486ad1c439a517aaab",
"unknown_6": 2,
"unknown_7": 2
}
ServerHandshake: {
"sessionKey": "6c345acf65f4a783c9b76e9d1a2abfa1450caaf990a92dfe"
}
Failed to decrypt the message (server, 10101).
connection from 192.168.0.11:51332 closed ...
connection to 54.163.131.20:9339 closed ...
connection from 192.168.0.11:51357 ...
connected to 54.145.227.14:9339 ...
ClientHandshake: {
"unknown_0": 1,
"unknown_1": 7,
"majorVersion": 8,
"unknown_3": 0,
"minorVersion": 212,
"masterHash": "6141a89793631ae2fa5ace486ad1c439a517aaab",
"unknown_6": 2,
"unknown_7": 2
}
ServerHandshake: {
"sessionKey": "0c2004a0c07e17444384c94b8b66d7a717434767e855b795"
}
Failed to decrypt the message (server, 10101).
connection from 192.168.0.11:51357 closed ...
connection to 54.145.227.14:9339 closed ...
Public key isn't correct maybe. See crypto.py in client folder where the 32 bit public key is there. Is it the same for your version?
you mean key from config.json patcher script . its was not same and i changed but still same result :(
"key": "469b704e7f6009ba8fc72e9b5c864c8e9285a755c5190f03f5c74852f6d9f419" in config.josn
self._serverkey = PublicKey(bytes.fromhex("469b704e7f6009ba8fc72e9b5c864c8e9285a755c5190f03f5c74852f6d9f419"))
its same
The key in config.json shouldn't be changed unless you're using a different private key on the server side.
The issue is that the proxy has not been updated with the latest public key from here. Update it here, it and it should work. I have a patch incoming that will automatically check the version number and pull any missing keys from the wiki, but it will be a few days before it is ready.
i did not change any key in config.json . also the key there is same in here https://github.com/clugh/coc-proxy/wiki/Keys also on crypto.py is same key with config.json and still not working
To clarify, the key in config.json
should be:
72f1a4a4c48e44da0c42310f800e96624e6dc6a641a9d41c3b5039d8dfadc27e
The key in coc/client/crypto.py
should be:
469b704e7f6009ba8fc72e9b5c864c8e9285a755c5190f03f5c74852f6d9f419
The key in coc/server/crypto.py
should be:
1891d401fadb51d25d3a9174d472a9f691a45b974285d47729c45c6538070d85
Looking at your error ouput from before, it looks like it is having trouble decrypting 10101, so it is an issue between the client and proxy, so the issue is either in config.json
or coc/server/crypto.py
.
One other thing to check, make sure you are using a properly patched version of the game. You can verify by pulling your libg.so
file from your device with adb
:
adb pull /data/data/com.supercell.clashofclans/lib/libg.so
dd if=libg.so skip=[offset] bs=1 count=32 | xxd -p -c 32
Just replace [offset] with the appropriate one from here.
The path to libg.so
may vary by device and Android version. You can find adb
in the platform-tools
package of the Android SDK, and xxd
is provided by Git for Windows.
Edit: The output of the above commands should result in the key from config.json
.
issue fixed by not change key in config.json and now i can see messages in proxy only issue left now is i cant load my village on my account
can we change an value with proxy and send to server ?
can we change an value with proxy and send to server ?
Sure, it can be done, but I won't be doing the work to implement it. The basic steps would be to have decodePacket()
return a value here, update the object with your ID and token, encode it using CoCMessageEncoder
, then replace the payload.
:) cool but i see there still some msgid not decoded yet and what about login an load my village this make me crazy please help
thank you
I just pushed several definition updates. If you're experiencing any others, I'd be happy to review a patch.
Short of restoring your village with Google Play or changing the ID and token right in the proxy as we previously discussed, I can only think of two options:
Restore the stock APK, recover your village, make a backup with Titanium Backup, reinstall the patched APK, and restore the data only from your backup.
1b. This could also be done with adb
and Android Backup Extractor, instead of Titanium Backup, if you don't have root.
storage.xml
using cocdp.I won't be providing support for either method.
thank you very much for your help i update definitions . before i do test on my account i will do on current one . and this is first time i am working on python still learning how its working . only think i want is how to change an value example gold and send to server can you help me with that .
i printed payload in coc/server/protocol.py but i got encoded one like this INFO:root:b'\x00\x00\x00\x01\x00\x00\x00\x07\x00\x00\x00\x08\x00\x00\x00\x00\x00\x00\x00\xd4\x00\x00\x00(6141a89793631ae2fa5ace486ad1c439a517aaab\x00\x00\x00\x02\x00\x00\x00\x02'
my code
def packetDecrypted(self, messageid, unknown, payload):
if not self.client:
reactor.callLater(0.25, self.packetDecrypted, messageid, unknown, payload)
return
self.decodePacket(messageid, unknown, payload)
logging.info("send packet to server")
logging.info( payload)
self.client.sendPacket(messageid, unknown, payload)
only think i want is how to change an value example gold and send to server can you help me with that
I would suggest creating a thread or contacting Cerise on the Ultrapowa forums. He has already done the same thing and might be willing to help you.
i printed payload in coc/server/protocol.py but i got encoded one like this
The decodePacket()
function decodes the data. As I said above, you need to return it, update the object with your ID and token, (re)encode it using CoCMessageEncoder
, then replace the payload
Edit: I reread your comment, and you don't actually send any gold values to the server. You only send commands to the server that either collect or spend gold, and the server verifies if gold is available to be collected or spent.
can you write me line to use CoCMessageEncoder to encode payload .sorry i am nooob with python . i tried butt didn't work
Edit : I Dont know what i am doing i thought i am sending to server . do am i ?
What have you tried? I suggest taking a look at decodePacket()
to see how the decoder works, as the encoder works the exact same way.
i used decodePacket method but payload and my enocded payload not same and its get stuck when app restarted after some time game says login failed
def packetDecrypted(self, messageid, unknown, payload):
if not self.client:
reactor.callLater(0.25, self.packetDecrypted, messageid, unknown, payload)
return
decoded = self.decodePacket(messageid, unknown, payload)
logging.info("send packet to server")
logging.info(decoded)
self.decoder.dump(decoded)
if "OwnHomeData" in decoded["name"]:
logging.info("send packet to server")
logging.info(decoded["fields"])
data = decoded
encode = self.encoder.encode(messageid, unknown, decoded)
logging.info("1 encode packet")
logging.info(encode)
logging.info("2 encode packet")
logging.info(payload)
self.client.sendPacket(messageid, unknown, payload)
We've gotta keep the discussion in one place, rather than jumping back and forth between here and Ultrapowa. As this is unrelated to the development of the proxy, I'd suggest you post a thread in the forums over there.
To reiterate what I said over there:
I'd suggest only replacing the payload in the cases where you actually modify the data, that way your connection doesn't die if there's an issue encoding or decoding some random packet.
[...] your primary issue is with the return value of
CoCMessageEncoder.encode()
. It returns a complete packet, not just the payload. So you'll need to either look atCoCMessageReader
or slice the header off the beginning.
after apk patched and stuff installed for coc-proxy i cant see its getting any packets
just saying listening on 0.0.0.0:9339 ...