def serialize(self, stream): stream.write(c_int64(character_id)) stream.write(c_uint32(unknown1)) stream.write(character_name) stream.write(character_unapproved_name) stream.write(is_name_rejected) stream.write(free_to_play) stream.write(unknown2, allocated_length=10) stream.write(c_uint32(shirt_color)) stream.write(c_uint32(shirt_style)) stream.write(c_uint32(pants_color)) stream.write(c_uint32(hair_style)) stream.write(c_uint32(hair_color)) stream.write(c_uint32(lh)) stream.write(c_uint32(rh)) stream.write(c_uint32(eyebrows)) stream.write(c_uint32(eyes)) stream.write(c_uint32(mouth)) stream.write(c_uint32(unknown3)) stream.write(c_uint16(last_zone)) stream.write(c_uint16(last_instance)) stream.write(c_uint32(last_clone)) stream.write(c_uint64(last_login)) stream.write(c_uint16(len(items))) for item in items: stream.write(c_uint32(item))
def serialize(self, stream: bitstream.WriteStream) -> None: stream.write(bitstream.c_uint64(self.object_id)) stream.write(bitstream.c_uint32(0)) stream.write(self.current_name, allocated_length=33) stream.write(self.unapproved_name, allocated_length=33) stream.write(bitstream.c_bool(self.name_rejected)) stream.write(bitstream.c_bool(self.is_ftp)) stream.write(bitstream.c_uint32(self.head_color)) stream.write(bitstream.c_uint16(0)) stream.write(bitstream.c_uint32(self.head)) stream.write(bitstream.c_uint32(self.chest_color)) stream.write(bitstream.c_uint32(self.chest)) stream.write(bitstream.c_uint32(self.legs)) stream.write(bitstream.c_uint32(self.hair_style)) stream.write(bitstream.c_uint32(self.hair_color)) stream.write(bitstream.c_uint32(self.left_hand)) stream.write(bitstream.c_uint32(self.right_hand)) stream.write(bitstream.c_uint32(self.eyebrows_style)) stream.write(bitstream.c_uint32(self.eyes_style)) stream.write(bitstream.c_uint32(self.mouth_style)) stream.write(bitstream.c_uint32(0)) stream.write(bitstream.c_uint16(self.last_zone)) stream.write(bitstream.c_uint16(self.last_map_instance)) stream.write(bitstream.c_uint32(self.last_map_clone)) stream.write(bitstream.c_uint64(0)) stream.write(bitstream.c_uint16(len(self.equipped_items))) for item in self.equipped_items: stream.write(bitstream.c_uint32(item))
def serialize(self, stream: bitstream.WriteStream) -> None: stream.write(bitstream.c_uint16(self.zone_id)) stream.write(bitstream.c_uint16(self.map_instance)) stream.write(bitstream.c_uint32(self.map_clone)) stream.write(bitstream.c_uint32(self.map_checksum)) stream.write(bitstream.c_bool(self.editor_enabled)) stream.write(bitstream.c_uint8(self.editor_level)) stream.write(self.player_position) stream.write(bitstream.c_uint32(self.activity))
def construct_packet(self, packet): stream = ReadStream(packet) # TODO - figure out why we aren't receiving user credentials correctly? """ uname = stream.read(str, allocated_length=33) pword = stream.read(str, allocated_length=41) self.logger.debug('user with credentials {0}:{1} attempting to login'.format(uname, pword)) """ uname = 'dev' pword = 'dev' res = WriteStream() res.write(PacketHeaders.CLIENT_LOGIN_RES.value) for account in self.database.accounts: if account.username == uname and account.password == pword: self.logger.debug('found user {} in database'.format(uname)) res.write(c_uint8(0x01)) break elif account.banned: res.write(c_uint8(0x02)) break res.write(CString('Talk_Like_A_Pirate', allocated_length=33)) # unknown res.write(CString(allocated_length=33 * 7)) # unknown res.write(c_uint16(1)) # v. major res.write(c_uint16(10)) # v. current res.write(c_uint16(64)) # v. minor user_token = str(uuid.uuid4()) res.write(user_token[0:18], allocated_length=33) res.write(CString('127.0.0.1', allocated_length=33)) # world IP res.write(CString('127.0.0.1', allocated_length=33)) # chat IP res.write(c_uint16(2002)) # world port res.write(c_ushort(3003)) # chat port res.write(CString('0', allocated_length=33)) # unknown IP res.write( CString('00000000-0000-0000-0000-000000000000', allocated_length=37)) res.write(c_ulong(0)) res.write(CString('US', allocated_length=3)) # localization res.write(c_bool(False)) res.write(c_bool(False)) res.write(c_ulonglong(0)) res.write('error', length_type=c_uint16) # custom err msg res.write(c_uint16(0)) res.write(c_ulong(4)) return res
def serialize(self, stream: WriteStream): super().serialize(stream) stream.write(c_uint16(self.zone_id)) stream.write(c_uint16(self.instance)) stream.write(c_uint32(self.clone)) stream.write(c_uint32(self.checksum)) stream.write(c_uint16(0)) stream.write(c_float(self.position.x)) stream.write(c_float(self.position.y)) stream.write(c_float(self.position.z)) stream.write(c_uint32(4 if self.activity else 0))
def serialize(self, stream: bitstream.WriteStream) -> None: stream.write(bitstream.c_uint32(self.game_version)) stream.write(bitstream.c_uint32(self.unknown_0)) stream.write(bitstream.c_uint32(self.remote_connection_type)) stream.write(bitstream.c_uint32(self.process_id)) stream.write(bitstream.c_uint16(self.local_port)) stream.write("127.0.0.1", allocated_length=33)
def serialize(self, stream: WriteStream): super().serialize(stream) stream.write(c_uint32(self.game_version)) stream.write(c_uint32(0x93)) stream.write(c_uint32(self.remote_connection_type)) stream.write(c_uint32(self.pid)) stream.write(c_uint16(self.port)) stream.write(self.ip.encode('latin1'), allocated_length=33)
def serialize(self, stream): super().serialize(stream) stream.write(c_uint8(self.auth_status_code)) stream.write(CString(self.unknown, allocated_length=33)) stream.write(CString(self.unknown1, allocated_length=33*7)) stream.write(self.client_version) stream.write(self.auth_token, allocated_length=33) stream.write(CString(self.char_ip, allocated_length=33)) stream.write(CString(self.chat_ip, allocated_length=33)) stream.write(c_uint16(self.char_port)) stream.write(c_uint16(self.chat_port)) stream.write(CString(self.unknown2, allocated_length=33)) stream.write(CString(self.unknown3, allocated_length=37)) stream.write(c_uint32(self.unknown4)) stream.write(CString(self.localization, allocated_length=3)) stream.write(c_bool(self.new_subscriber)) stream.write(c_bool(self.is_ftp)) stream.write(c_uint64(self.unknown5)) stream.write(self.permission_error, length_type=c_uint16) # TODO: Implement stamps stream.write(c_uint32(4))
def serialize(self, stream: bitstream.WriteStream) -> None: stream.write(bitstream.c_uint8(self.login_return_code)) stream.write(CString("Talk_Like_A_Pirate", allocated_length=33)) stream.write(CString("", allocated_length=33 * 7)) stream.write(bitstream.c_uint16(self.client_version_major)) stream.write(bitstream.c_uint16(self.client_version_current)) stream.write(bitstream.c_uint16(self.client_version_minor)) stream.write(self.user_key, allocated_length=33) stream.write(CString(self.char_ip, allocated_length=33)) stream.write(CString(self.chat_ip, allocated_length=33)) stream.write(bitstream.c_uint16(self.char_port)) stream.write(bitstream.c_uint16(self.chat_port)) stream.write(CString('0', allocated_length=33)) stream.write( CString('00000000-0000-0000-0000-000000000000', allocated_length=37)) stream.write(bitstream.c_uint32(0)) stream.write(CString(self.localization, allocated_length=3)) # US Localization stream.write(bitstream.c_bool(self.display_first_time)) stream.write(bitstream.c_bool(self.is_ftp)) stream.write(bitstream.c_uint64(0)) stream.write(self.custom_error, length_type=bitstream.c_uint16) # Custom error message stream.write(bitstream.c_uint16(0)) stream.write(bitstream.c_uint32(4))
def serialize(self, stream: WriteStream): stream.write(c_uint8(0x53)) stream.write(c_uint16(0x05)) stream.write(c_uint32(0x00)) stream.write(c_uint8(0)) stream.write(c_uint8(self.login_code)) stream.write(b'Talk_Like_A_Pirate', allocated_length=33) for _ in range(7): stream.write(b'', allocated_length=33) stream.write(c_uint16(1)) stream.write(c_uint16(10)) stream.write(c_uint16(64)) stream.write(self.user_key, allocated_length=33) stream.write(self.char_ip.encode('latin1'), allocated_length=33) stream.write(self.chat_ip.encode('latin1'), allocated_length=33) stream.write(c_uint16(self.char_port)) stream.write(c_uint16(self.chat_port)) stream.write(self.ip.encode('latin1'), allocated_length=33) stream.write(b'00000000-0000-0000-0000-000000000000', allocated_length=37) stream.write(c_uint32(0)) stream.write(self.locale.encode('latin1'), allocated_length=3) stream.write(c_bool(self.first_login_sub)) stream.write(c_bool(self.free_to_play)) stream.write(c_uint64(0)) if self.error: stream.write(c_uint16(len(self.error))) stream.write(self.error, allocated_length=len(self.error)) else: stream.write(c_uint16(0)) stream.write(c_uint32(4))
def serialize(self, stream: WriteStream): stream.write(c_int64(self.object_id)) stream.write(c_int32(self.lot)) stream.write(c_bit(False)) stream.write(c_bit(self.amount is not None)) if self.amount is not None: stream.write(c_uint32(self.amount)) stream.write(c_bit(self.slot is not None)) if self.slot is not None: stream.write(c_uint16(self.slot)) stream.write(c_bit(True)) stream.write(c_uint32(4)) stream.write(c_bit(False)) # TODO: implement metadata stream.write(c_bit(False))
def serialize(self, stream: WriteStream): super().serialize(stream) stream.write(c_int64(self.object_id)) stream.write(c_uint16(self.message_id)) stream.write(self.data)
def serialize(self, stream: WriteStream): stream.write(c_uint8(0x53)) stream.write(c_uint16(self.connection_type.value)) stream.write(c_uint32(self.packet_id)) stream.write(c_uint8(0))
def serialize(self, stream): stream.write(c_uint16(self.major)) stream.write(c_uint16(self.current)) stream.write(c_uint16(self.minor))
def serialize(self, stream): stream.write(c_uint8(0x53)) stream.write(c_uint16(self.remote_conn_id)) stream.write(c_uint32(self.packet_id)) stream.write(c_uint8(0x00))
def serialize(self, stream: bitstream.WriteStream) -> None: stream.write(CString(self.redirect_ip, allocated_length=33)) stream.write(bitstream.c_uint16(self.redirect_port)) stream.write(bitstream.c_bool(self.is_mythran_dimension_shift))