private static void ProcessPartyService(UdpClient udp, QPacket p, RMCPacket rmc, ClientInfo client) { RMCPacketReply reply; switch (rmc.methodID) { case 1: reply = new RMCPacketResponsePartyService_GetInviteeList(); SendReply(udp, p, rmc, client, reply); break; case 4: reply = new RMCPacketResponsePartyService_GetInviteList(); SendReply(udp, p, rmc, client, reply); break; case 7: case 8: case 9: case 0xB: case 0xC: case 0xD: reply = new RMCPacketResponseEmpty(); SendReply(udp, p, rmc, client, reply); break; default: WriteLog(1, "Error: Unknown Method 0x" + rmc.methodID.ToString("X")); break; } }
private static void ProcessChatService(UdpClient udp, QPacket p, RMCPacket rmc, ClientInfo client) { RMCPacketReply reply; switch (rmc.methodID) { case 0x5: reply = new RMCPacketResponseChatService_Method5(); SendReply(udp, p, rmc, client, reply); break; case 0x9: case 0xA: reply = new RMCPacketResponseEmpty(); SendReply(udp, p, rmc, client, reply); break; case 0xE: reply = new RMCPacketResponseChatService_GetPlayerStatuses(); SendReply(udp, p, rmc, client, reply); break; case 0x10: reply = new RMCPacketResponseChatService_Method10(); SendReply(udp, p, rmc, client, reply); break; default: WriteLog(1, "Error: Unknown Method 0x" + rmc.methodID.ToString("X")); break; } }
private static void ProcessAuthentication(UdpClient udp, QPacket p, RMCPacket rmc, ClientInfo client) { RMCPacketReply reply; switch (rmc.methodID) { case 2: RMCPacketRequestLoginCustomData h = (RMCPacketRequestLoginCustomData)rmc.header; switch (h.className) { case "UbiAuthenticationLoginCustomData": reply = new RMCPacketResponseLoginCustomData(client.PID); client.sessionKey = ((RMCPacketResponseLoginCustomData)reply).ticket.sessionKey; SendReply(udp, p, rmc, client, reply); break; default: WriteLog("Error: Unknown RMC Packet Authentication Custom Data class " + h.className); break; } break; case 3: reply = new RMCPacketResponseRequestTicket(client.PID); SendReply(udp, p, rmc, client, reply); break; default: WriteLog("Error: Unknown RMC Packet Authentication Method 0x" + rmc.methodID.ToString("X")); break; } }
private static void ProcessServerInfo(UdpClient udp, QPacket p, RMCPacket rmc, ClientInfo client) { RMCPacketReply reply; switch (rmc.methodID) { case 1: reply = new RMCPacketResponseServerInfo_Method1(); SendReply(udp, p, rmc, client, reply); break; case 2: reply = new RMCPacketResponseServerInfo_Method2(); SendReply(udp, p, rmc, client, reply); break; case 5: reply = new RMCPacketResponseServerInfo_GetServerTime(); SendReply(udp, p, rmc, client, reply); break; default: WriteLog(1, "Error: Unknown Method 0x" + rmc.methodID.ToString("X")); break; } }
private static void SendReplyPacket(UdpClient udp, QPacket p, RMCPacket rmc, ClientInfo client, RMCPacketReply reply, bool useCompression) { QPacket np = new QPacket(p.toBuffer()); np.flags = new List <QPacket.PACKETFLAG>() { QPacket.PACKETFLAG.FLAG_NEED_ACK }; np.m_oSourceVPort = p.m_oDestinationVPort; np.m_oDestinationVPort = p.m_oSourceVPort; np.m_uiSignature = client.IDsend; np.uiSeqId++; MemoryStream m = new MemoryStream(); Helper.WriteU8(m, (byte)rmc.proto); Helper.WriteU8(m, 0x1); Helper.WriteU32(m, rmc.callID); Helper.WriteU32(m, rmc.methodID | 0x8000); byte[] buff = reply.ToBuffer(); m.Write(buff, 0, buff.Length); buff = m.ToArray(); m = new MemoryStream(); Helper.WriteU32(m, (uint)buff.Length); m.Write(buff, 0, buff.Length); np.payload = m.ToArray(); np.payloadSize = (ushort)np.payload.Length; WriteLog("send response packet"); Send(udp, np, client); WriteLog("Response Data Content : \n" + reply.ToString()); }
public static void HandlePacket(UdpClient udp, QPacket p) { ClientInfo client = Global.GetClientByIDrecv(p.m_uiSignature); if (client == null) { return; } if (p.flags.Contains(QPacket.PACKETFLAG.FLAG_ACK)) { return; } WriteLog("Handling packet..."); RMCPacket rmc = new RMCPacket(p); WriteLog("Received packet :\n" + rmc); switch (rmc.proto) { case RMCPacket.PROTOCOL.Authentication: ProcessAuthentication(udp, p, rmc, client); break; case RMCPacket.PROTOCOL.Secure: ProcessSecure(udp, p, rmc, client); break; default: WriteLog("No handler implemented for packet protocol " + rmc.proto); break; } }
public static void ProcessPacket(byte[] data, IPEndPoint ep) { StringBuilder sb = new StringBuilder(); foreach (byte b in data) { sb.Append(b.ToString("X2") + " "); } Log.WriteLine("[UDP] received : " + sb.ToString()); QPacket p = new QPacket(data); Log.WriteLine("[UDP] received : " + p); switch (p.type) { case QPacket.PACKETTYPE.SYN: ProcessSYN(p, ep); break; case QPacket.PACKETTYPE.CONNECT: ProcessCONNECT(p); break; case QPacket.PACKETTYPE.DATA: ProcessDATA(p); break; case QPacket.PACKETTYPE.DISCONNECT: ProcessDISCONNECT(p); break; case QPacket.PACKETTYPE.PING: ProcessPING(p); break; } }
private static void ProcessSecure(UdpClient udp, QPacket p, RMCPacket rmc, ClientInfo client) { RMCPacketReply reply; switch (rmc.methodID) { case 4: RMCPacketRequestRegisterEx h = (RMCPacketRequestRegisterEx)rmc.header; switch (h.className) { case "UbiAuthenticationLoginCustomData": reply = new RMCPacketResponseRegisterEx(client.PID); SendReply(udp, p, rmc, client, reply); break; default: WriteLog(1, "Error: Unknown RMC Packet Secure Custom Data class " + h.className); break; } break; default: WriteLog(1, "Error: Unknown RMC Packet Secure Method 0x" + rmc.methodID.ToString("X")); break; } }
public static void ProcessSYN(QPacket p, IPEndPoint ep) { ClientInfo client = GetClientByEndPoint(ep); if (client == null) { client = new ClientInfo(); client.ep = ep; client.IDrecv = idCounter++; clients.Add(client); } QPacket reply = new QPacket(); 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.SYN; reply.m_bySessionID = p.m_bySessionID; reply.m_uiSignature = p.m_uiSignature; reply.uiSeqId = p.uiSeqId; reply.m_uiConnectionSignature = client.IDrecv; reply.payload = new byte[0]; Send(reply, client); }
public static void ProcessPING(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; } QPacket reply = new QPacket(); 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.PING; 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); }
private static void ProcessLeaderboardService(UdpClient udp, QPacket p, RMCPacket rmc, ClientInfo client) { RMCPacketReply reply; switch (rmc.methodID) { case 1: reply = new RMCPacketResponseLeaderboardService_GetLeaderboards(); SendReply(udp, p, rmc, client, reply); break; case 2: reply = new RMCPacketResponseLeaderboardService_Method2(); SendReply(udp, p, rmc, client, reply); break; case 3: reply = new RMCPacketResponseLeaderboardService_Method2(); SendReply(udp, p, rmc, client, reply); break; case 4: reply = new RMCPacketResponseLeaderboardService_Method4(); SendReply(udp, p, rmc, client, reply); break; default: WriteLog(1, "Error: Unknown Method 0x" + rmc.methodID.ToString("X")); break; } }
public static QPacket ProcessSYN(QPacket p, IPEndPoint ep, out ClientInfo client) { client = Global.GetClientByEndPoint(ep); if (client == null) { Log.WriteLine("Creating new client data..."); client = new ClientInfo(); client.ep = ep; client.IDrecv = Global.idCounter++; client.PID = Global.pidCounter++; Global.clients.Add(client); } QPacket reply = new QPacket(); 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.SYN; reply.m_bySessionID = p.m_bySessionID; reply.m_uiSignature = p.m_uiSignature; reply.uiSeqId = p.uiSeqId; reply.m_uiConnectionSignature = client.IDrecv; reply.payload = new byte[0]; return(reply); }
public static QPacket ProcessCONNECT(ClientInfo client, QPacket p) { client.IDsend = p.m_uiConnectionSignature; QPacket reply = new QPacket(); 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; if (p.payload != null && p.payload.Length > 0) { reply.payload = MakeConnectPayload(client, p); } else { reply.payload = new byte[0]; } return(reply); }
private static void ProcessSkillsService(UdpClient udp, QPacket p, RMCPacket rmc, ClientInfo client) { RMCPacketReply reply; switch (rmc.methodID) { case 1: reply = new RMCPacketResponseSkillsService_GetGameClass(); SendReply(udp, p, rmc, client, reply); break; case 2: reply = new RMCPacketResponseSkillsService_GetSkills(); SendReply(udp, p, rmc, client, reply); break; case 4: reply = new RMCPacketResponseSkillsService_Method4(); SendReply(udp, p, rmc, client, reply); break; case 5: reply = new RMCPacketResponseSkillsService_GetModifiers(); SendReply(udp, p, rmc, client, reply); break; default: WriteLog("Error: Unknown Method 0x" + rmc.methodID.ToString("X")); break; } }
private void toolStripButton1_Click(object sender, EventArgs e) { MemoryStream m = new MemoryStream(); for (long i = 0; i < hb1.ByteProvider.Length; i++) { m.WriteByte(hb1.ByteProvider.ReadByte(i)); } byte[] payload = m.ToArray(); foreach (ClientInfo client in Global.clients) { QPacket q = new QPacket(); q.m_oSourceVPort = new QPacket.VPort(0x31); q.m_oDestinationVPort = new QPacket.VPort(0x3f); q.type = QPacket.PACKETTYPE.DATA; q.flags = new List <QPacket.PACKETFLAG>(); q.payload = new byte[0]; q.uiSeqId = (ushort)(++client.seqCounter); q.m_bySessionID = client.sessionID; RMCP rmc = new RMCP(); rmc.proto = (RMCP.PROTOCOL)protoIDs[toolStripComboBox1.SelectedIndex]; rmc.methodID = Convert.ToUInt32(toolStripTextBox1.Text); rmc.callID = ++client.callCounterRMC; RMCPCustom reply = new RMCPCustom(); reply.buffer = payload; RMC.SendRequestPacket(client.udp, q, rmc, client, reply, true, 0); } }
private static void ProcessPlayerProfileService(UdpClient udp, QPacket p, RMCPacket rmc, ClientInfo client) { RMCPacketReply reply; switch (rmc.methodID) { case 0xF: reply = new RMCPacketResponsePlayerProfileService_MethodF(); SendReply(udp, p, rmc, client, reply); break; case 0x10: reply = new RMCPacketResponseEmpty(); SendReply(udp, p, rmc, client, reply); break; case 0x11: reply = new RMCPacketResponsePlayerProfileService_Method11(); SendReply(udp, p, rmc, client, reply); break; case 0x12: reply = new RMCPacketResponsePlayerProfileService_LoadCharacterProfiles(); List <GR5_Character> list = DBHelper.GetUserCharacters(client.PID); ((RMCPacketResponsePlayerProfileService_LoadCharacterProfiles)reply).Characters.AddRange(list); ((RMCPacketResponsePlayerProfileService_LoadCharacterProfiles)reply).PersonaID = client.PID; ((RMCPacketResponsePlayerProfileService_LoadCharacterProfiles)reply).Name = client.name; SendReply(udp, p, rmc, client, reply); break; default: WriteLog(1, "Error: Unknown Method 0x" + rmc.methodID.ToString("X")); break; } }
private static void ProcessInventoryService(UdpClient udp, QPacket p, RMCPacket rmc, ClientInfo client) { RMCPacketReply reply; switch (rmc.methodID) { case 1: reply = new RMCPacketResponseInventoryService_GetTemplateItems(); SendReply(udp, p, rmc, client, reply); break; case 2: reply = new RMCPacketResponseInventoryService_Method2(); SendReply(udp, p, rmc, client, reply); break; case 4: reply = new RMCPacketResponseInventoryService_GetAllApplyItems(); SendReply(udp, p, rmc, client, reply); break; case 16: reply = new RMCPacketResponseInventoryService_GetAllDefaultLoadoutKits(); SendReply(udp, p, rmc, client, reply); break; default: WriteLog("Error: Unknown Method 0x" + rmc.methodID.ToString("X")); break; } }
private void toolStripButton1_Click(object sender, EventArgs e) { try { MessageBox.Show(QPacket.MakeChecksum(makeArray(toolStripTextBox1.Text.Trim().Replace(" ", ""))).ToString("X2")); } catch { } }
public static void ProcessPacket(byte[] data, IPEndPoint ep) { StringBuilder sb = new StringBuilder(); foreach (byte b in data) { sb.Append(b.ToString("X2") + " "); } QPacket p = new QPacket(data); WriteLog(5, "received : " + p.ToStringShort()); WriteLog(10, "received : " + sb.ToString()); WriteLog(10, "received : " + p.ToStringDetailed()); QPacket reply = null; ClientInfo client = null; if (p.type != QPacket.PACKETTYPE.SYN) { client = Global.GetClientByIDrecv(p.m_uiSignature); } switch (p.type) { case QPacket.PACKETTYPE.SYN: reply = QPacketHandler.ProcessSYN(p, ep, out client); break; case QPacket.PACKETTYPE.CONNECT: if (client != null) { reply = QPacketHandler.ProcessCONNECT(client, p); } break; case QPacket.PACKETTYPE.DATA: RMC.HandlePacket(listener, p); break; case QPacket.PACKETTYPE.DISCONNECT: if (client != null) { reply = QPacketHandler.ProcessDISCONNECT(client, p); } break; case QPacket.PACKETTYPE.PING: if (client != null) { reply = QPacketHandler.ProcessPING(client, p); } break; } if (reply != null && client != null) { Send(reply, client); } }
private static void SendReply(UdpClient udp, QPacket p, RMCPacket rmc, ClientInfo client, RMCPacketReply reply, bool useCompression = true, uint error = 0) { WriteLog(2, "Response : " + reply.ToString()); string payload = reply.PayloadToString(); if (payload != "") { WriteLog(5, "Response Data Content : \n" + payload); } SendACK(udp, p, client); SendReplyPacket(udp, p, rmc, client, reply, useCompression, error); }
public static void Send(QPacket p, ClientInfo client) { byte[] data = p.toBuffer(); StringBuilder sb = new StringBuilder(); foreach (byte b in data) { sb.Append(b.ToString("X2") + " "); } Log.WriteLine("[UDP] send : " + sb.ToString()); Log.WriteLine("[UDP] send : " + p); listener.Send(data, data.Length, client.ep); }
public static void Send(QPacket p, ClientInfo client) { byte[] data = p.toBuffer(); StringBuilder sb = new StringBuilder(); foreach (byte b in data) { sb.Append(b.ToString("X2") + " "); } WriteLog("send : " + sb.ToString(), !Global.useDetailedLog); WriteLog("send : " + p.ToStringDetailed(), !Global.useDetailedLog); WriteLog("send : " + p.ToStringShort(), Global.useDetailedLog); listener.Send(data, data.Length, client.ep); }
public static void Send(UdpClient udp, QPacket p, ClientInfo client) { byte[] data = p.toBuffer(); StringBuilder sb = new StringBuilder(); foreach (byte b in data) { sb.Append(b.ToString("X2") + " "); } WriteLog(5, "send : " + p.ToStringShort()); WriteLog(10, "send : " + sb.ToString()); WriteLog(10, "send : " + p.ToStringDetailed()); udp.Send(data, data.Length, client.ep); }
private static void ProcessAuthentication(UdpClient udp, QPacket p, RMCPacket rmc, ClientInfo client) { RMCPacketReply reply; switch (rmc.methodID) { case 2: RMCPacketRequestLoginCustomData h = (RMCPacketRequestLoginCustomData)rmc.header; switch (h.className) { case "UbiAuthenticationLoginCustomData": reply = new RMCPacketResponseEmpty(); ClientInfo user = DBHelper.GetUserByName(h.username); if (user != null) { if (user.pass == h.password) { reply = new RMCPacketResponseLoginCustomData(client.PID); client.name = h.username; client.pass = h.password; client.sessionKey = ((RMCPacketResponseLoginCustomData)reply).ticket.sessionKey; SendReply(udp, p, rmc, client, reply); } else { SendReply(udp, p, rmc, client, reply, true, 0x80030065); } } else { SendReply(udp, p, rmc, client, reply, true, 0x80030064); } break; default: WriteLog(1, "Error: Unknown RMC Packet Authentication Custom Data class " + h.className); break; } break; case 3: reply = new RMCPacketResponseRequestTicket(client.PID); SendReply(udp, p, rmc, client, reply); break; default: WriteLog(1, "Error: Unknown RMC Packet Authentication Method 0x" + rmc.methodID.ToString("X")); break; } }
private static void SendACK(UdpClient udp, QPacket p, ClientInfo client) { QPacket np = new QPacket(p.toBuffer()); np.flags = new List <QPacket.PACKETFLAG>() { QPacket.PACKETFLAG.FLAG_ACK }; np.m_oSourceVPort = p.m_oDestinationVPort; np.m_oDestinationVPort = p.m_oSourceVPort; np.m_uiSignature = client.IDsend; np.payload = new byte[0]; np.payloadSize = 0; WriteLog(10, "send ACK packet"); Send(udp, np, client); }
private static void ProcessUnlockService(UdpClient udp, QPacket p, RMCPacket rmc, ClientInfo client) { RMCPacketReply reply; switch (rmc.methodID) { case 1: reply = new RMCPacketResponseUnlockService_GetCurrentUserUnlock(); SendReply(udp, p, rmc, client, reply); break; default: WriteLog("Error: Unknown Method 0x" + rmc.methodID.ToString("X")); break; } }
private static void ProcessAbilityService(UdpClient udp, QPacket p, RMCPacket rmc, ClientInfo client) { RMCPacketReply reply; switch (rmc.methodID) { case 1: reply = new RMCPacketResponseAbilityService_GetPersonaAbilityUpgrades(); SendReply(udp, p, rmc, client, reply); break; default: WriteLog("Error: Unknown Method 0x" + rmc.methodID.ToString("X")); break; } }
private static void ProcessProfanityFilterService(UdpClient udp, QPacket p, RMCPacket rmc, ClientInfo client) { RMCPacketReply reply; switch (rmc.methodID) { case 1: reply = new RMCPacketResponseProfanityFilterService_GetAllProfaneWords(); SendReply(udp, p, rmc, client, reply); break; default: WriteLog(1, "Error: Unknown Method 0x" + rmc.methodID.ToString("X")); break; } }
private static void DBGTelemetry(UdpClient udp, QPacket p, RMCPacket rmc, ClientInfo client) { RMCPacketReply reply; switch (rmc.methodID) { case 1: reply = new RMCPacketResponseDBGTelemetry_DBGAMMClientInfo(); SendReply(udp, p, rmc, client, reply); break; default: WriteLog(1, "Error: Unknown Method 0x" + rmc.methodID.ToString("X")); break; } }
private static void ProcessFriendsService(UdpClient udp, QPacket p, RMCPacket rmc, ClientInfo client) { RMCPacketReply reply; switch (rmc.methodID) { case 5: reply = new RMCPacketResponseFriendsService_Method5(); SendReply(udp, p, rmc, client, reply); break; default: WriteLog(1, "Error: Unknown Method 0x" + rmc.methodID.ToString("X")); break; } }