Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def ParsePacket(self, packet_data, sender, action):
- packet = Packet()
- if self.reconstruct and not self.oldpacket == None and self.oldpacket.send == sender:
- new = packet_data
- packet.RecvPacket(self.oldpacket.fullpacket + new, sender, action)
- self.reconstruct = False
- self.oldpacket = None
- else:
- packet.RecvPacket(packet_data, sender, action)
- if self.oldpacket != None and self.oldpacket.send != sender:
- self.reconstruct = False
- self.oldpacket = None
- while packet.len < len(packet.data):
- extracted_data = packet.fullpacket[0 : packet.len + packet.size_len + 2 + (4 if sender else 0)]
- goodPacket = Packet()
- goodPacket.RecvPacket(extracted_data, sender, action)
- goodPacket.Deserialize(Reader(goodPacket.data))
- nextdata = packet.fullpacket[packet.len + packet.size_len + 2 + (4 if sender else 0):]
- packet = Packet()
- if packet.RecvPacket(nextdata, sender, action) == False:
- self.oldpacket = packet
- self.reconstruct = True
- return
- if packet.len == 0:
- packet.Deserialize(Reader(b""))
- data = packet.fullpacket[2 + (4 if sender else 0):]
- if len(data) > 0:
- packet = Packet()
- packet.RecvPacket(data, sender, action)
- else:
- return
- if len(packet.data) > packet.len:
- print("[-] ERROR")
- elif len(packet.data) == packet.len:
- packet.action = action
- packet.Deserialize(Reader(packet.data))
- else:
- self.oldpacket = packet
- self.reconstruct = True
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement