public QPacket(byte[] data) { MemoryStream m = new MemoryStream(data); m_oSourceVPort = new VPort(Helper.ReadU8(m)); m_oDestinationVPort = new VPort(Helper.ReadU8(m)); m_byPacketTypeFlags = Helper.ReadU8(m); type = (PACKETTYPE)(m_byPacketTypeFlags & 0x7); flags = new List <PACKETFLAG>(); ExtractFlags(); m_bySessionID = Helper.ReadU8(m); m_uiSignature = Helper.ReadU32(m); uiSeqId = Helper.ReadU16(m); if (type == PACKETTYPE.SYN || type == PACKETTYPE.CONNECT) { m_uiConnectionSignature = Helper.ReadU32(m); } if (type == PACKETTYPE.DATA) { m_byPartNumber = Helper.ReadU8(m); } if (flags.Contains(PACKETFLAG.FLAG_HAS_SIZE)) { payloadSize = Helper.ReadU16(m); } MemoryStream pl = new MemoryStream(); for (int i = (int)m.Position; i < m.Length - 1; i++) { pl.WriteByte(Helper.ReadU8(m)); } payload = pl.ToArray(); payloadSize = (ushort)payload.Length; if (payload != null && payload.Length > 0) { payload = Helper.Decrypt(Global.keyDATA, payload); usesCompression = payload[0] != 0; if (usesCompression) { MemoryStream m2 = new MemoryStream(); m2.Write(payload, 1, payload.Length - 1); payload = Helper.Decompress(m2.ToArray()); } else { MemoryStream m2 = new MemoryStream(); m2.Write(payload, 1, payload.Length - 1); payload = m2.ToArray(); } payloadSize = (ushort)payload.Length; } checkSum = Helper.ReadU8(m); }
public RMCPacket(QPacket p) { MemoryStream m = new MemoryStream(p.payload); Helper.ReadU32(m); ushort b = Helper.ReadU8(m); isRequest = (b >> 7) == 1; try { if ((b & 0x7F) != 0x7F) { proto = (PROTOCOL)(b & 0x7F); } else { b = Helper.ReadU16(m); proto = (PROTOCOL)(b); } } catch { callID = Helper.ReadU32(m); methodID = Helper.ReadU32(m); WriteLog("Error: Unknown RMC packet protocol 0x" + b.ToString("X2")); return; } callID = Helper.ReadU32(m); methodID = Helper.ReadU32(m); switch (proto) { case PROTOCOL.Authentication: HandleAuthenticationMethods(m); break; case PROTOCOL.Secure: HandleSecureMethods(m); break; default: WriteLog("Error: No reader implemented for packet protocol " + proto); break; } }
public RMCPacket(QPacket p) { MemoryStream m = new MemoryStream(p.payload); Helper.ReadU32(m); ushort b = Helper.ReadU8(m); isRequest = (b >> 7) == 1; try { if ((b & 0x7F) != 0x7F) { proto = (PROTOCOL)(b & 0x7F); } else { b = Helper.ReadU16(m); proto = (PROTOCOL)(b); } } catch { callID = Helper.ReadU32(m); methodID = Helper.ReadU32(m); WriteLog(1, "Error: Unknown RMC packet protocol 0x" + b.ToString("X2")); return; } callID = Helper.ReadU32(m); methodID = Helper.ReadU32(m); switch (proto) { case PROTOCOL.Authentication: HandleAuthenticationMethods(m); break; case PROTOCOL.Secure: HandleSecureMethods(m); break; case PROTOCOL.Telemetry: HandleTelemetryMethods(m); break; case PROTOCOL.AMMGameClient: case PROTOCOL.PlayerProfileService: case PROTOCOL.ArmorService: case PROTOCOL.InventoryService: case PROTOCOL.LootService: case PROTOCOL.WeaponService: case PROTOCOL.FriendsService: case PROTOCOL.ChatService: case PROTOCOL.MissionService: case PROTOCOL.PartyService: case PROTOCOL.StatisticsService: case PROTOCOL.AchievementsService: case PROTOCOL.ProgressionService: case PROTOCOL.DBGTelemetry: case PROTOCOL.RewardService: case PROTOCOL.StoreService: case PROTOCOL.AdvertisementsService: case PROTOCOL.SkillsService: case PROTOCOL.Loadout: case PROTOCOL.UnlockService: case PROTOCOL.AvatarService: case PROTOCOL.WeaponProficiencyService: case PROTOCOL.OpsProtocolService: case PROTOCOL.ServerInfo: case PROTOCOL.LeaderboardService: case PROTOCOL.PveArchetypeService: case PROTOCOL.InboxMessageService: case PROTOCOL.ProfanityFilterService: case PROTOCOL.AbilityService: case PROTOCOL.SurveyService: case PROTOCOL.OverlordNewsProtocol: break; default: WriteLog(1, "Error: No reader implemented for packet protocol " + proto); break; } }
public static void ProcessCONNECT(QPacket p) { ClientInfo client = GetClientByIDrecv(p.m_uiSignature); if (client == null) { Log.WriteLine("[UDP] Cand find client for id : 0x" + p.m_uiSignature.ToString("X8")); return; } client.IDsend = p.m_uiConnectionSignature; QPacket reply = new QPacket(); if (p.payload != null && p.payload.Length > 1) { using (var mem = new MemoryStream(p.payload)) { var ticketLen = Helper.ReadU32(mem); var ticket = new byte[ticketLen]; for (int i = 0; i < ticketLen; i++) { ticket[i] = Helper.ReadU8(mem); } var requestDataLen = Helper.ReadU32(mem); var requestData = new byte[requestDataLen]; for (int i = 0; i < requestDataLen; i++) { requestData[i] = Helper.ReadU8(mem); } var sessionKey = new byte[] { 0x9C, 0xB0, 0x1D, 0x7A, 0x2C, 0x5A, 0x6C, 0x5B, 0xED, 0x12, 0x68, 0x45, 0x69, 0xAE, 0x09, 0x0D }; var decryptedRequestData = Helper.Decrypt(sessionKey, requestData); StringBuilder sb = new StringBuilder(); foreach (byte b in decryptedRequestData) { sb.Append(b.ToString("X2")); } uint rcv; using (var d = new MemoryStream(decryptedRequestData)) { var uPid = Helper.ReadU32(d); var cid = Helper.ReadU32(d); rcv = Helper.ReadU32(d); } using (var r = new MemoryStream()) { reply.m_oSourceVPort = p.m_oDestinationVPort; reply.m_oDestinationVPort = p.m_oSourceVPort; reply.flags = new List <QPacket.PACKETFLAG>() { QPacket.PACKETFLAG.FLAG_ACK, QPacket.PACKETFLAG.FLAG_HAS_SIZE }; reply.type = QPacket.PACKETTYPE.CONNECT; reply.m_bySessionID = p.m_bySessionID; reply.m_uiSignature = client.IDsend; reply.uiSeqId = p.uiSeqId; reply.m_uiConnectionSignature = client.IDrecv; Helper.WriteU32(r, 4); Helper.WriteU32(r, rcv + 1); reply.payload = r.ToArray(); } } } else { reply.m_oSourceVPort = p.m_oDestinationVPort; reply.m_oDestinationVPort = p.m_oSourceVPort; reply.flags = new List <QPacket.PACKETFLAG>() { QPacket.PACKETFLAG.FLAG_ACK }; reply.type = QPacket.PACKETTYPE.CONNECT; reply.m_bySessionID = p.m_bySessionID; reply.m_uiSignature = client.IDsend; reply.uiSeqId = p.uiSeqId; reply.m_uiConnectionSignature = client.IDrecv; reply.payload = new byte[0]; } Send(reply, client); }