Beispiel #1
0
 def __init__(self, xor_key, is_valid):
     self.unknown1 = Int8(1)
     self.id = Int8(is_valid)
     self.xor_key = Bytes(xor_key)
     self.unknown2 = Int32(1)
     self.unknown3 = Int32(1)
     self.unknown4 = Int8(1)
Beispiel #2
0
 def parse(cls, data, client):
     client.xor_key = LoginXorKey(Int32.decode(data[-8:-4]))
     data = xor_decrypt_login(lambda packet_cls, data, client: data)(cls,
                                                                     data,
                                                                     client)
     data = data[1:]
     client.session_id = Int32.decode(data[0:4])
     client.protocol_version = Int32.decode(data[4:8])
     client.rsa_key = L2RsaKey.from_scrambled(bytes(ByteArray(data[8:136])))
     client.blowfish_key = BlowfishKey(bytes(ByteArray(data[152:168])))
     return cls(client)
Beispiel #3
0
    def _checksum(data: ByteArray):
        chksum = Int32(0)

        for i in range(0, len(data) - 4, 4):
            check = Int32(data[i]) & 0xff
            check |= Int32(data[i + 1]) << 8 & 0xff00
            check |= Int32(data[i + 2]) << 0x10 & 0xff0000
            check |= Int32(data[i + 3]) << 0x18 & 0xff000000

            chksum ^= check

        data[-4:] = chksum

        return data
Beispiel #4
0
 def encode(self, client):
     arr = ByteArray(self.type.encode())
     arr.append(Int8(len(self.servers)))
     arr.append(Int8(client.account.latest_server))
     for server in self.servers:
         arr.extend(Int8(server.id))
         arr.append(Int8(server.ip[0]))
         arr.append(Int8(server.ip[1]))
         arr.append(Int8(server.ip[2]))
         arr.append(Int8(server.ip[3]))
         arr.append(Int32(server.port))
         arr.append(Int8(server.age_limit))
         arr.append(Int8(server.is_pvp))
         arr.append(Int16(server.online))
         arr.append(Int16(server.max_online))
         arr.append(Int8(server.is_online))
         arr.append(Int32(server.server_type))
         arr.append(Int8(server.brackets))
     arr.append(Int8(0))
     return arr
Beispiel #5
0
 def __init__(self, protocol):
     self.protocol = protocol
     self.state = Connected()
     self.rsa_key = L2RsaKey.generate()
     self.blowfish_key = BlowfishKey.generate()
     self.session_id = Int32.random()
     self.session_key = SessionKey()
     self.xor_key = LoginXorKey()
     self.protocol_version = 50721
     self.blowfish_key.decode = True
     self.blowfish_enabled = True
     self.encryption_enabled = True
Beispiel #6
0
 def __init__(self, object_id,
              destination_x, destination_y, destination_z,
              current_x, current_y, current_z):
     self.object_id = Int32(object_id)
     self.destination_x = Int32(destination_x)
     self.destination_y = Int32(destination_y)
     self.destination_z = Int32(destination_z)
     self.current_x = Int32(current_x)
     self.current_y = Int32(current_y)
     self.current_z = Int32(current_z)
Beispiel #7
0
 def __init__(self, client):
     self.session_id = Int32(client.session_id)
     self.protocol_version = Int32(client.protocol_version)
     self.rsa_key = Bytes(client.rsa_key.scramble_mod())
     self.unknown1 = Int32(0x29DD954E)
     self.unknown2 = Int32(0x77C39CFC)
     self.unknown3 = Int32(0x97ADB620)
     self.unknown4 = Int32(0x07BDE0F7)
     self.blowfish_key = Bytes(client.blowfish_key.key)
     self.null_termination = Int8(0)
Beispiel #8
0
    def dexor(data, key):
        temp1 = Int32(0)
        for i in range(len(data)):
            temp2 = Int32(data[i]) & 0xff
            data[i] = Int8(temp2 ^ key[i & 15] ^ temp1)
            temp1 = temp2

        old = (Int32(key[8]) & 0xff)
        old |= (Int32(key[9]) << 0x08) & 0xff00
        old |= (Int32(key[10]) << 0x10) & 0xff0000
        old |= (Int32(key[11]) << 0x18) & 0xff000000

        old += Int32(len(data))

        key[8:12] = old
        return data
Beispiel #9
0
    def xor(data, key):
        temp = Int32(0)

        for i in range(len(data)):
            temp2 = Int32(data[i] & 0xff)
            data[i] = Int8(temp2 ^ key[i & 15] ^ temp)
            temp = data[i]

        old = Int32(key[8] & 0xff)
        old |= Int32(key[9] << 0x08) & 0xff00
        old |= Int32(key[10] << 0x10) & 0xff0000
        old |= Int32(key[11] << 0x18) & 0xff000000

        old += Int32(len(data))

        key[8:12] = old

        return data
Beispiel #10
0
def verify(data):
    if len(data) % 4 != 0:
        return False

    chksum = Int32(0)
    for i in range(0, len(data) - 4, 4):
        check = Int32(data[i]) & 0xff
        check |= Int32(data[i + 1]) << 8 & 0xff00
        check |= Int32(data[i + 2]) << 0x10 & 0xff0000
        check |= Int32(data[i + 3]) << 0x18 & 0xff000000

        chksum ^= check

    check = Int32(data[-4:])

    return check == chksum
Beispiel #11
0
 def parse(cls, data, client):
     version = Int32(data[1:5])
     return cls(version)
Beispiel #12
0
 def __init__(self, login_ok1, login_ok2):
     self.login_ok1 = Int32(login_ok1)
     self.login_ok2 = Int32(login_ok2)
     self.unknown = Bytes(b"\x00\x00\x00\x00" + b"\x00\x00\x00\x00" +
                          b"\xEA\x03\x00\x00" + b"\x00\x00\x00\x00" +
                          b"\x00\x00\x00\x00" + b"\x02\x00\x00\x00")
Beispiel #13
0
class ServerSocketClose(GameServerPacket):
    type = Int8(175)
    constant = Int32(0)
    arg_order = ["type", "constant"]
Beispiel #14
0
 def __init__(self, login_ok1, login_ok2):
     self.login_ok1 = Int32(login_ok1)
     self.login_ok2 = Int32(login_ok2)
Beispiel #15
0
 def __init__(self, play_ok1, play_ok2):
     self.play_ok1 = Int32(play_ok1)
     self.play_ok2 = Int32(play_ok2)
     self.unknown = Int8(1)
Beispiel #16
0
 def __init__(self, character_id, move_type):
     self.character_id = Int32(character_id)
     self.move_type = Int32(move_type)
     self.constant = Int32(0)
Beispiel #17
0
 def __init__(self, login, play_ok1, play_ok2, login_ok1, login_ok2):
     self.login = String(login)
     self.play_ok1 = Int32(play_ok1)
     self.play_ok2 = Int32(play_ok2)
     self.login_ok1 = Int32(login_ok1)
     self.login_ok2 = Int32(login_ok2)
Beispiel #18
0
 def __init__(self, character_id, wait_type, x, y, z):
     self.character_id = Int32(character_id)
     self.wait_type = Int32(wait_type)
     self.x = Int32(x)
     self.y = Int32(y)
     self.z = Int32(z)
Beispiel #19
0
 def __init__(self, login_ok1, login_ok2, server_id):
     self.login_ok1 = Int32(login_ok1)
     self.login_ok2 = Int32(login_ok2)
     self.server_id = Int8(server_id)
Beispiel #20
0
 def __init__(self, reply=1):
     self.reply = Int32(reply)
     self.zero1 = Int32(0)
     self.zero2 = Int32(0)
     self.zero3 = Int32(0)
     self.zero4 = Int32(0)
Beispiel #21
0
 def __init__(self, protocol_version):
     self.protocol_version = Int32(protocol_version)
Beispiel #22
0
 def __init__(self, reason_id):
     self.reason_id = Int32(reason_id)
Beispiel #23
0
 def encode(self, client):
     arr = ByteArray(self.type.encode())
     arr.append(Int32(len(self.characters)))
     for character in self.characters:
         pass
     return arr
Beispiel #24
0
 def __init__(self, key=None):
     self.key = Int32.random() if not key else Int32(key)
Beispiel #25
0
 def __init__(self, character_id, x, y, z):
     self.character_id = Int32(character_id)
     self.x = Int32(x)
     self.y = Int32(y)
     self.z = Int32(z)
Beispiel #26
0
 def __init__(self, login_ok1=None, login_ok2=None, play_ok1=None, play_ok2=None):
     self.login_ok1 = Int32.random() if login_ok1 is None else login_ok1
     self.login_ok2 = Int32.random() if login_ok2 is None else login_ok2
     self.play_ok1 = Int32.random() if play_ok1 is None else play_ok1
     self.play_ok2 = Int32.random() if play_ok2 is None else play_ok2
Beispiel #27
0
 def __init__(self, kick_reason_id):
     self.kick_reason = Int32(kick_reason_id)