Esempio n. 1
0
def WarMode(warmode):
    p = PacketWriter(0x72)
    p.boolean(warmode)
    p.byte(0)
    p.byte(0)
    p.byte(0)
    return p.finish()
Esempio n. 2
0
def TalkAscii(text, type=0, hue=0x34, font=1):
    p = PacketWriter(0x03)
    p.byte(type)
    p.ushort(hue)
    p.ushort(font)
    p.cstring(text)
    return p.finish()
Esempio n. 3
0
def VendorSellReply(vendor_serial, item_serial, amount=1):
    p = PacketWriter(0x9f)
    p.uint(vendor_serial)
    p.ushort(1)
    p.uint(item_serial)
    p.ushort(amount)
    return p.finish()
Esempio n. 4
0
def WarMode(warmode):
    p = PacketWriter(0x72)
    p.boolean(warmode)
    p.byte(0)
    p.byte(0)
    p.byte(0)
    return p.finish()
Esempio n. 5
0
def TalkAscii(text, type=0, hue=0x34, font=1):
    p = PacketWriter(0x03)
    p.byte(type)
    p.ushort(hue)
    p.ushort(font)
    p.cstring(text)
    return p.finish()
Esempio n. 6
0
def VendorSellReply(vendor_serial, item_serial, amount=1):
    p = PacketWriter(0x9f)
    p.uint(vendor_serial)
    p.ushort(1)
    p.uint(item_serial)
    p.ushort(amount)
    return p.finish()
Esempio n. 7
0
    def to_data(self):
        packet = PacketWriter(0x8C, self.packet_length)
        packet.ipv4(self.relay.ip)
        packet.ushort(self.relay.port)
        packet.uint(self.relay.auth_id)

        return packet.finish()
Esempio n. 8
0
    def data_received(self, data: bytes):
        """Called when some data is received.

        :param data: is  a bytes object.
        """
        self.log.debug("Received {} bytes".format(len(data)))

        if self._packets_compression:
            # TODO Compression is not working at the moment
            original_data = data[:]
            compressed_data = data[:]
            uncompressed_data = self._compression.decompress(compressed_data)
            self._input += uncompressed_data
            new_compressed_data = self._compression.compress(uncompressed_data)

            self.log.debug("Uncompressed data is {} bytes".format(len(data)))

        else:
            self._input += data

        while True and not self._packets_compression:
            packet: PacketReader = self._packet_from_buffer()

            if packet is None:
                break

            if packet.cmd in self.auto_answer:
                self.log.debug('Auto answering packet {:#4x}'.format(packet.cmd))
                # answer = self.auto_answer[cmd](data=data)

            if packet.cmd in self.rewriters:
                self.log.debug('Rewriting packet {:#4x}'.format(packet.cmd))
                rewriter = self.rewriters[packet.cmd](packet=packet)
                packet_data = rewriter.to_data()
            else:
                new_packet = PacketWriter(packet.cmd, self.packet_table[packet.cmd])
                new_packet.data(packet.raw_data)
                packet_data = new_packet.finish()

            self.log.debug('UOClient data_received: packet {:#4X} len {}'.format(packet.cmd, len(packet_data)))

            # when we connect to the relay we turn decompression on
            if packet.cmd == 0x8C:
                self.loop.client_decompress = True

            # forward data to the client
            if not self._packets_compression:
                try:
                    self.server.transport.write(packet_data)
                    self.log.debug('UOClient serv transport write: packet {:#4X}'.format(packet.cmd))
                except Exception as e:
                    print("EXC {}".format(e))

        if self._packets_compression:
            try:
                self.server.transport.write(original_data)
                self.log.debug('UOClient serv transport write: compressed data')
            except Exception as e:
                print("EXC {}".format(e))
Esempio n. 9
0
def VendorBuyReply(vendor_serial, item_serial, amount=1):
    p = PacketWriter(0x3b)
    p.uint(vendor_serial)
    p.byte(2)  # flags
    p.byte(0)  # layer
    p.uint(item_serial)
    p.ushort(amount)
    return p.finish()
Esempio n. 10
0
def Drop(serial, x, y, z, dest_serial):
    p = PacketWriter(0x08)
    p.uint(serial)
    p.ushort(x)
    p.ushort(y)
    p.sbyte(z)
    p.uint(dest_serial)
    return p.finish()
Esempio n. 11
0
def VendorBuyReply(vendor_serial, item_serial, amount=1):
    p = PacketWriter(0x3b)
    p.uint(vendor_serial)
    p.byte(2) # flags
    p.byte(0) # layer
    p.uint(item_serial)
    p.ushort(amount)
    return p.finish()
Esempio n. 12
0
def Drop(serial, x, y, z, dest_serial):
    p = PacketWriter(0x08)
    p.uint(serial)
    p.ushort(x)
    p.ushort(y)
    p.sbyte(z)
    p.uint(dest_serial)
    return p.finish()
Esempio n. 13
0
def MenuResponse(serial, index):
    p = PacketWriter(0x7d)
    p.uint(serial)
    p.ushort(0) # menu id
    p.ushort(index)
    p.ushort(0) # item id
    p.ushort(0) # hue
    return p.finish()
Esempio n. 14
0
def MenuResponse(serial, index):
    p = PacketWriter(0x7d)
    p.uint(serial)
    p.ushort(0)  # menu id
    p.ushort(index)
    p.ushort(0)  # item id
    p.ushort(0)  # hue
    return p.finish()
Esempio n. 15
0
def PlayCharacter(slot):
    p = PacketWriter(0x5d)
    p.uint(0)
    p.fixstring("", 30)
    p.ushort(0)
    p.uint(0)
    p.fixstring("", 24)
    p.uint(slot)
    p.uint(0xdeadbeef)
    return p.finish()
Esempio n. 16
0
def PlayCharacter(slot):
    p = PacketWriter(0x5d)
    p.uint(0)
    p.fixstring("", 30)
    p.ushort(0)
    p.uint(0)
    p.fixstring("", 24)
    p.uint(slot)
    p.uint(0xdeadbeef)
    return p.finish()
Esempio n. 17
0
def GumpResponse(serial, gump_id, button_id=1, switches=[]):
    p = PacketWriter(0xb1)
    p.uint(serial)
    p.uint(gump_id)
    p.uint(button_id)
    p.uint(len(switches))
    for x in switches:
        p.uint(x)
    p.uint(0)  # number of text responses
    return p.finish()
Esempio n. 18
0
    def __init__(self, data: bytes, transport: asyncio.WriteTransport, packet_length: int):
        self.data: bytes = data[:]
        self.p: uo.packets.UOPacket = uo.packets.UOPacket(self.data, packet_length)
        self.packet_length = packet_length
        self.razor_features = uo.packets.RazorFeatures(self.p.from_buffer())

        if self.razor_features.features == 0xFE:
            packet = PacketWriter(0xF0, packet_length)
            packet.ushort(0x0004)
            packet.byte(0xFF)
            transport.write(packet.finish())
Esempio n. 19
0
def TargetResponse(type, target_id, flags, serial, x, y, z, graphic):
    p = PacketWriter(0x6c)
    p.byte(type)
    p.uint(target_id)
    p.byte(flags)
    p.uint(serial)
    p.ushort(x)
    p.ushort(y)
    p.sshort(z)
    p.ushort(graphic)
    return p.finish()
Esempio n. 20
0
def TalkUnicode(text, keyword, type=0xc0, hue=0x34, font=1):
    p = PacketWriter(0xad)
    p.byte(type)
    p.ushort(hue)
    p.ushort(font)
    p.fixstring('Eng', 4)
    p.byte(0x00)
    p.byte(0x10)
    p.byte(keyword)
    p.cstring(text)
    return p.finish()
Esempio n. 21
0
def TargetResponse(type, target_id, flags, serial, x, y, z, graphic):
    p = PacketWriter(0x6c)
    p.byte(type)
    p.uint(target_id)
    p.byte(flags)
    p.uint(serial)
    p.ushort(x)
    p.ushort(y)
    p.sshort(z)
    p.ushort(graphic)
    return p.finish()
Esempio n. 22
0
def TalkUnicode(text, keyword, type=0xc0, hue=0x34, font=1):
    p = PacketWriter(0xad)
    p.byte(type)
    p.ushort(hue)
    p.ushort(font)
    p.fixstring('Eng', 4)
    p.byte(0x00)
    p.byte(0x10)
    p.byte(keyword)
    p.cstring(text)
    return p.finish()
Esempio n. 23
0
    def to_data(self):
        packet = PacketWriter(0xA8, self.packet_length)
        packet.byte(self.server_list.sys_info_flag)
        packet.ushort(self.server_list.count)

        for server in self.server_list.servers:
            packet.ushort(server.index)
            packet.fixstring(server.name, 32)
            packet.byte(server.percent_full)
            packet.byte(server.timezone)
            packet.ipv4(server.ip, True)

        return packet.finish()
Esempio n. 24
0
def TalkUnicode(text, keyword=None, type=0, hue=0x34, font=1):
    assert (type & 0xc0) == 0

    if keyword is not None:
        type |= 0xc0

    p = PacketWriter(0xad)
    p.byte(type)
    p.ushort(hue)
    p.ushort(font)
    p.fixstring('Eng', 4)

    if keyword is not None:
        p.byte(0x00)
        p.byte(0x10 | (keyword >> 8))
        p.byte(keyword)

    p.ucstring(text)
    return p.finish()
Esempio n. 25
0
def CreateCharacter(name):
    p = PacketWriter(0x00)
    p.uint(0xedededed)
    p.uint(0xffffffff)
    p.byte(0x00)
    p.fixstring(name, 30)
    p.ushort(0x0000)
    p.uint(0x0000003f)  # flags
    p.uint(0x00000001)
    p.uint(0x0000000f)
    p.byte(0x00)  # profession
    p.byte(0x00)
    p.byte(0x00)
    p.byte(0x00)
    p.uint(0x00000000)
    p.uint(0x00000000)
    p.byte(0x02)  # male?
    p.byte(0x3c)  # str
    p.byte(0x0a)  # dex
    p.byte(0x0a)  # int
    p.byte(0x19)  # is1
    p.byte(0x27)  # vs1
    p.byte(0x2c)  # is2
    p.byte(0x0b)  # vs2
    p.byte(0x0b)  # is3
    p.byte(0x32)  # vs3
    p.ushort(0x03ea)  # hue
    p.ushort(0x2047)  # hair
    p.ushort(0x044e)  # hair hue
    p.ushort(0x204b)  # facial hair
    p.ushort(0x044e)  # facial hair hue
    p.byte(0x00)
    p.byte(0x00)  # city
    p.uint(0x00000000)  # char slot
    p.uint(0xdeadbeef)  # client ip
    p.ushort(0x00e0)  # shirt hue
    p.ushort(0x01a1)  # pants hue
    return p.finish()
Esempio n. 26
0
def Resync():
    p = PacketWriter(0x22)
    p.byte(0)
    p.byte(0)
    return p.finish()
Esempio n. 27
0
def PlayServer(index):
    p = PacketWriter(0xa0)
    p.ushort(index)
    return p.finish()
Esempio n. 28
0
def GameLogin(username, password, auth_id):
    p = PacketWriter(0x91)
    p.uint(auth_id)
    p.fixstring(username, 30)
    p.fixstring(password, 30)
    return p.finish()
Esempio n. 29
0
def CheckSecureTrade(serial):
    p = PacketWriter(0x6f)
    p.byte(0x02)
    p.uint(serial)
    p.uint(1)
    return p.finish()
Esempio n. 30
0
def GameLogin(username, password, auth_id):
    p = PacketWriter(0x91)
    p.uint(auth_id)
    p.fixstring(username, 30)
    p.fixstring(password, 30)
    return p.finish()
Esempio n. 31
0
def EquipRequest(item_serial, layer, target_serial):
    p = PacketWriter(0x13)
    p.uint(item_serial)
    p.byte(layer)
    p.uint(target_serial)
    return p.finish()
Esempio n. 32
0
def MobileQuery(type, serial):
    p = PacketWriter(0x34)
    p.uint(0xedededed)
    p.byte(type)
    p.uint(serial)
    return p.finish()
Esempio n. 33
0
def WalkRequest(direction, seq):
    p = PacketWriter(0x02)
    p.byte(direction)
    p.byte(seq)
    p.uint(0)
    return p.finish()
Esempio n. 34
0
def RazorHandshakeResponse():
    p = PacketWriter(0xf0)
    p.byte(0xff)
    return p.finish()
Esempio n. 35
0
def StatLock(stat, lock):
    p = PacketWriter(0xbf)
    p.ushort(0x001a)
    p.byte(stat)
    p.byte(lock)
    return p.finish()
Esempio n. 36
0
def SkillLock(skill, lock):
    p = PacketWriter(0x3a)
    p.ushort(skill)
    p.byte(lock)
    return p.finish()
Esempio n. 37
0
def ClientVersion(version):
    p = PacketWriter(0xbd)
    p.ucstring(version)
    return p.finish()
Esempio n. 38
0
def MobileQuery(type, serial):
    p = PacketWriter(0x34)
    p.uint(0xedededed)
    p.byte(type)
    p.uint(serial)
    return p.finish()
Esempio n. 39
0
def Use(serial):
    p = PacketWriter(0x06)
    p.uint(serial)
    return p.finish()
Esempio n. 40
0
def SkillLock(skill, lock):
    p = PacketWriter(0x3a)
    p.ushort(skill)
    p.byte(lock)
    return p.finish()
Esempio n. 41
0
def LiftRequest(serial, amount=0xffff):
    p = PacketWriter(0x07)
    p.uint(serial)
    p.ushort(amount)
    return p.finish()
Esempio n. 42
0
def TextCommand(type, command):
    p = PacketWriter(0x12)
    p.byte(type)
    p.cstring(command)
    return p.finish()
Esempio n. 43
0
def Resync():
    p = PacketWriter(0x22)
    p.byte(0)
    p.byte(0)
    return p.finish()
Esempio n. 44
0
def CancelSecureTrade(serial):
    p = PacketWriter(0x6f)
    p.byte(0x01)
    p.uint(serial)
    return p.finish()
Esempio n. 45
0
def PlayServer(index):
    p = PacketWriter(0xa0)
    p.ushort(index)
    return p.finish()
Esempio n. 46
0
def Click(serial):
    p = PacketWriter(0x09)
    p.uint(serial)
    return p.finish()
Esempio n. 47
0
def AccountLogin(username, password):
    p = PacketWriter(0x80)
    p.fixstring(username, 30)
    p.fixstring(password, 30)
    p.byte(0)
    return p.finish()
Esempio n. 48
0
def AccountLogin(username, password):
    p = PacketWriter(0x80)
    p.fixstring(username, 30)
    p.fixstring(password, 30)
    p.byte(0)
    return p.finish()
Esempio n. 49
0
def EquipRequest(item_serial, layer, target_serial):
    p = PacketWriter(0x13)
    p.uint(item_serial)
    p.byte(layer)
    p.uint(target_serial)
    return p.finish()
Esempio n. 50
0
def Click(serial):
    p = PacketWriter(0x09)
    p.uint(serial)
    return p.finish()
Esempio n. 51
0
def CancelSecureTrade(serial):
    p = PacketWriter(0x6f)
    p.byte(0x01)
    p.uint(serial)
    return p.finish()
Esempio n. 52
0
def TextCommand(type, command):
    p = PacketWriter(0x12)
    p.byte(type)
    p.cstring(command)
    return p.finish()
Esempio n. 53
0
def CheckSecureTrade(serial):
    p = PacketWriter(0x6f)
    p.byte(0x02)
    p.uint(serial)
    p.uint(1)
    return p.finish()
Esempio n. 54
0
def StatLock(stat, lock):
    p = PacketWriter(0xbf)
    p.ushort(0x001a)
    p.byte(stat)
    p.byte(lock)
    return p.finish()
Esempio n. 55
0
def ClientVersion(version):
    p = PacketWriter(0xbd)
    p.cstring(version)
    return p.finish()