private ClientInformation(PacketIn packet) { try { ProtocolVersion = packet.ReadByte(); var claimedRemainingLength = packet.ReadUInt16(); if (packet.RemainingLength != claimedRemainingLength) { Log.Warn(WCell_Core.Auth_Logon_with_invalid_length, claimedRemainingLength, packet.RemainingLength); } var clientInstallationType = packet.ReadFourCC(); _clientInstallationType = ClientTypeUtility.Lookup(clientInstallationType); Version = new ClientVersion(packet.ReadBytes(5)); Architecture = packet.ReadFourCC().TrimEnd('\0'); OS = packet.ReadFourCC().TrimEnd('\0'); var locale = packet.ReadFourCC(); _locale = ClientLocaleUtility.Lookup(locale); TimeZone = BitConverter.ToUInt32(packet.ReadBytes(4), 0); IPAddress = new XmlIPAddress(packet.ReadBytes(4)); Log.Info(WCell_Core.ClientInformationFourCCs, ProtocolVersion, ClientInstallationType, Version, Architecture, OS, Locale, TimeZone, IPAddress); } catch { } }
public static byte[] GetBytes(PacketIn updatePacket) { var bytes = updatePacket.ReadBytes(updatePacket.Length - updatePacket.HeaderSize); if (updatePacket.PacketId.RawId == (uint)RealmServerOpCode.SMSG_COMPRESSED_UPDATE_OBJECT) { bytes = UpdateFieldsUtil.Decompress(bytes); } else if (updatePacket.PacketId.RawId != (uint)RealmServerOpCode.SMSG_UPDATE_OBJECT) { throw new Exception("Given Packet " + updatePacket + " is not an Update Packet!"); } return bytes; }
public PacketParser(PacketIn packet, PacketSender sender, PacketDefinition def) { if (packet.PacketId == RealmServerOpCode.SMSG_COMPRESSED_MOVES) { var packet2 = ParseCompressedMove(packet); if (packet2 != null) { packet = packet2; } } Packet = packet; Sender = sender; Definition = def; Timestamp = DateTime.Now; }
public void AddRealmSMSG(PacketIn packet) { if (PacketUtil.GetUpdatePackets && (packet.PacketId == RealmServerOpCode.SMSG_UPDATE_OBJECT || packet.PacketId == RealmServerOpCode.SMSG_COMPRESSED_UPDATE_OBJECT)) { var parsedPacket = new ParsedUpdatePacket(packet); // check if all bytes were read - if not, the submitted update-count was too small //Assert.AreEqual(0, parsedPacket.RemainingLength, "Count in UpdatePacket does not match with actual packet-size"); UpdatePackets.Add(parsedPacket); } else { AddRealmPacket(SMSGPackets, PacketSender.Server, packet, this); } }
/// <summary> /// Checks if the client's proof matches our proof. /// </summary> /// <param name="packet">the packet to read from</param> /// <returns>true if the client proof matches; false otherwise</returns> public bool IsClientProofValid(PacketIn packet) { m_srp.PublicEphemeralValueA = packet.ReadBigInteger(32); BigInteger proof = packet.ReadBigInteger(20); // SHA1 of PublicEphemeralValueA and the 16 random bytes sent in // AUTH_LOGON_CHALLENGE from the server byte[] arr = packet.ReadBytes(20); byte keyCount = packet.ReadByte(); for (int i = 0; i < keyCount; i++) { ushort keyUnk1 = packet.ReadUInt16(); uint keyUnk2 = packet.ReadUInt32(); byte[] keyUnkArray = packet.ReadBytes(4); // sha of the SRP's PublicEphemeralValueA, PublicEphemeralValueB, // and 20 unknown bytes byte[] keyUnkSha = packet.ReadBytes(20); } byte securityFlags = packet.ReadByte(); if ((securityFlags & 1) != 0) { // PIN byte[] pinRandom = packet.ReadBytes(16); byte[] pinSha = packet.ReadBytes(20); } if ((securityFlags & 2) != 0) { byte[] security2Buf = packet.ReadBytes(20); } if ((securityFlags & 4) != 0) { byte arrLen = packet.ReadByte(); byte[] security4Buf = packet.ReadBytes(arrLen); } return m_srp.IsClientProofValid(proof); }
private ClientInformation(PacketIn packet) { packet.SkipBytes(1); // 0 try { Version = new ClientVersion(packet.ReadBytes(5)); Architecture = packet.ReadReversedString(); OS = packet.ReadReversedString(); var localeStr = packet.ReadReversedPascalString(4); if (!ClientLocales.Lookup(localeStr, out m_Locale)) { m_Locale = WCellConstants.DefaultLocale; } TimeZone = BitConverter.ToUInt32(packet.ReadBytes(4), 0); IPAddress = new XmlIPAddress(packet.ReadBytes(4)); } catch { } }
public static void RealmListRequest(IAuthClient client, PacketIn packet) { SendRealmList(client); }
/// <summary> /// Generates a system information objet from the given packet. /// </summary> /// <param name="inPacket">contains the system information in a raw, serialized format</param> public static SystemInformation ReadFromPacket(PacketIn inPacket) { SystemInformation info = new SystemInformation(); inPacket.SkipBytes(1); // 0 try { info.Version = new ClientVersion(inPacket.ReadBytes(5)); info.Architecture = inPacket.ReadReversedString(); info.OS = inPacket.ReadReversedString(); info.Locale = inPacket.ReadReversedPascalString(4); info.TimeZone = BitConverter.ToUInt32(inPacket.ReadBytes(4), 0); info.IPAddress = new XmlIPAddress(inPacket.ReadBytes(4)); } catch { } return info; }
public bool IsReconnectProofValid(PacketIn packet, AuthenticationInfo authInfo) { //md5 hash of account name and secure random byte[] md5Hash = packet.ReadBytes(16); //byte[20] sha1 hash of accountname, md5 from above, reconnectProof, byte[40] sessionkey byte[] shaHash1 = packet.ReadBytes(20); //byte[20] sha1 hash of md5 from above and byte[20] (all zero) byte[] shaHash2 = packet.ReadBytes(20); byte[] username = Encoding.ASCII.GetBytes(m_srp.Username); var sha = new SHA1Managed(); sha.TransformBlock(username, 0, username.Length, username, 0); sha.TransformBlock(md5Hash, 0, md5Hash.Length, md5Hash, 0); sha.TransformBlock(ReconnectProof, 0, ReconnectProof.Length, ReconnectProof, 0); sha.TransformBlock(authInfo.SessionKey, 0, authInfo.SessionKey.Length, authInfo.SessionKey, 0); byte[] hash = sha.TransformFinalBlock(new byte[0], 0, 0); for (int i = 0; i < 20; i++) { if (shaHash1[i] != hash[i]) return false; } return true; }
private static void ReadUnknownDataFromPacket(PacketIn packet, byte unkFlags) { if ((unkFlags & 2) != 0) { packet.ReadFloat(); packet.ReadFloat(); packet.ReadByte(); // here the client appends a MSG_MOVE_STOP movement packet } }
public ParsedUpdatePacket(PacketIn packet) : this(GetBytes(packet), false) { }
public void AddRealmCMSG(PacketIn packet) { AddRealmPacket(CMSGPackets, PacketSender.Client, packet, this); }
/// <summary> /// Generates a system information objet from the given packet. /// </summary> /// <param name="inPacket">contains the system information in a raw, serialized format</param> public static ClientInformation ReadFromPacket(PacketIn packet) { var info = new ClientInformation(packet); return info; }
public PacketParser(PacketIn packet, PacketSender sender) : this(packet, sender, PacketAnalyzer.GetDefinition(packet.PacketId, sender)) { }
public static DisposableRealmPacketIn ParseCompressedMove(PacketIn packet) { // special treatment for the compressed move packet var uncompressedLength = packet.ReadInt32(); var segment = BufferManager.GetSegment(uncompressedLength); var arr = segment.Buffer.Array; try { Compression.DecompressZLib(packet.ReadBytes(packet.RemainingLength), arr); ushort length = arr[0]; RealmServerOpCode opCode = (RealmServerOpCode) (arr[1] | arr[2] << 8); return new DisposableRealmPacketIn(segment, 1, length, length - 3, opCode); } catch (Exception e) { LogUtil.ErrorException(e, "Unable to parse packet: " + packet); } return null; }
public static ParsedSegment Parse(PacketIn packet, PacketSender sender, PacketDefinition def) { var parser = new PacketParser(packet, sender, def); parser.Parse(); return parser.ParsedPacket; }
public static ParsedSegment Parse(PacketIn packet, PacketSender sender) { var parser = new PacketParser(packet, sender); parser.Parse(); return parser.ParsedPacket; }
public ParsablePacketInfo(PacketIn packet, PacketSender sender, DateTime timestamp) { Packet = packet; Sender = sender; Timestamp = timestamp; }
static void AddRealmPacket(IDictionary<RealmServerOpCode, LockfreeQueue<RealmReceiveInfo>> packets, PacketSender sender, PacketIn packet, TestFakeClient client) { var opCode = (RealmServerOpCode)packet.PacketId.RawId; LockfreeQueue<RealmReceiveInfo> queue; if (!packets.TryGetValue(opCode, out queue)) { packets.Add(opCode, queue = new LockfreeQueue<RealmReceiveInfo>()); } var def = PacketAnalyzer.GetDefinition(packet.PacketId, sender); if (def != null) { if (packet is RealmPacketIn) { packet = ((DisposableRealmPacketIn) packet).Copy(); } var parser = new PacketParser(packet, sender); parser.Parse(); queue.Enqueue(new RealmReceiveInfo { Parser = parser, Client = client }); //packet.IncrementUsage(); } }