-
Member
Need help to fix client connection
This is my python wow server emulator for 2.4.3. Currently client stucks on 'Connected' after SMSG_AUTH_RESPONSE.
Help me please with debugging the problem.
As I can see from wireshark client sends nothing after SMSG_AUTH_RESPONSE, but I wish it should send CMSG_CHAR_ENUM.
Last edited by /dev/not/null; 11-21-2018 at 06:02 PM.
Reason: typo
-
Member
-
Post Thanks / Like - 1 Thanks
/dev/not/null (1 members gave Thanks to drolean for this useful post)
-
Member
Originally Posted by
drolean
Unfortunately, even when encryption is set before SMSG_AUTH_RESPONSE, this not help. Client still stucks on 'Connected'.
When I connecting, this output from wow client console:
GRUNT: state: LOGIN_STATE_CONNECTING result: LOGIN_OK
GRUNT: state: LOGIN_STATE_CONNECTED result: LOGIN_OK 127.0.0.1:3724
GRUNT: state: LOGIN_STATE_AUTHENTICATING result: LOGIN_OK
GRUNT: state: LOGIN_STATE_CHECKSUM result: LOGIN_OK
GRUNT: state: LOGIN_STATE_HANDSHAKING result: LOGIN_OK
GRUNT: state: LOGIN_STATE_AUTHENTICATED result: LOGIN_OK
ClientConnection Initiating: COP_CONNECT code=CSTATUS_CONNECTING
ClientConnection Completed: COP_CONNECT code=RESPONSE_CONNECTED result=TRUE
ClientConnection Initiating: COP_AUTHENTICATE code=CSTATUS_AUTHENTICATING
GRUNT: state: LOGIN_STATE_DISCONNECTED result: LOGIN_OK
Client returns GRUNT: state: LOGIN_STATE_DISCONNECTED result: LOGIN_OK because LoginServer close connection after returning Realmlist.
When I leave connection alive, wow client console returns next output:
GRUNT: state: LOGIN_STATE_CONNECTING result: LOGIN_OK
GRUNT: state: LOGIN_STATE_CONNECTED result: LOGIN_OK 127.0.0.1:3724
GRUNT: state: LOGIN_STATE_AUTHENTICATING result: LOGIN_OK
GRUNT: state: LOGIN_STATE_CHECKSUM result: LOGIN_OK
GRUNT: state: LOGIN_STATE_HANDSHAKING result: LOGIN_OK
GRUNT: state: LOGIN_STATE_AUTHENTICATED result: LOGIN_OK
ClientConnection Initiating: COP_CONNECT code=CSTATUS_CONNECTING
ClientConnection Completed: COP_CONNECT code=RESPONSE_CONNECTED result=TRUE
ClientConnection Initiating: COP_AUTHENTICATE code=CSTATUS_AUTHENTICATING
After that client hangs on 'Connected' too, but with another console output.
Last edited by /dev/not/null; 11-23-2018 at 05:24 PM.
-
Member
Well, after thinking and debugging I know what the reason now. Client stucks on 'Connected' because of my encryption alg is not correct. Python byte value should be in range of (0, 256), so my encryption code had to take this limitation. My code below:
Code:
class HeaderCrypt(object):
ENCRYPT_HEADER_SIZE = 4
DECRYPT_HEADER_SIZE = 6
def __init__(self, session_key):
self.session_key = session_key
self.send_i = 0
self.send_j = 0
self.recv_i = 0
self.recv_j = 0
def encrypt(self, data):
assert len(data) >= HeaderCrypt.ENCRYPT_HEADER_SIZE
encrypted_header = [0] * HeaderCrypt.ENCRYPT_HEADER_SIZE
for index in range(HeaderCrypt.ENCRYPT_HEADER_SIZE):
enc = (data[index] ^ self.session_key[self.send_i]) + self.send_j
enc %= 0x100
encrypted_header[index] = self.send_j = enc
self.send_i = (self.send_i + 1) % len(self.session_key)
return bytes(encrypted_header) + data[HeaderCrypt.ENCRYPT_HEADER_SIZE:]
def decrypt(self, data):
assert len(data) >= HeaderCrypt.DECRYPT_HEADER_SIZE
decrypted_header = [0] * HeaderCrypt.DECRYPT_HEADER_SIZE
for index in range(self.DECRYPT_HEADER_SIZE):
dec = (data[index] - self.recv_j) ^ self.session_key[self.recv_i]
dec %= 0x100
decrypted_header[index] = dec
self.recv_j = data[index]
self.recv_i = (self.recv_i + 1) % len(self.session_key)
return bytes(decrypted_header) + data[HeaderCrypt.DECRYPT_HEADER_SIZE:]
Now I'm trying to understand how to fix my alg. Any help would be appreciated.
Last edited by /dev/not/null; 12-05-2018 at 01:06 PM.
-
Member
Solved this! All I need (according to Mangos source code) is adding key generating:
Code:
def _generate_key(self, session_key):
seed = b'8\xa7\x83\x15\xf8\x92%0q\x98g\xb1\x8c\x04\xe2\xaa'
hashed = hmac.new(seed, session_key, sha1)
return hashed.digest()
This is the key for HeaderCrypt.
Last edited by /dev/not/null; 12-11-2018 at 02:03 PM.