public void CreatureQuery(WoWGuid guid, UInt32 entry) { PacketOut packet = new PacketOut(WorldServerOpCode.CMSG_CREATURE_QUERY); packet.Write(entry); packet.Write(guid.GetNewGuid()); Send(packet); }
void HandleAccountDataUpdate(PacketIn inpacket) { PacketOut packet = new PacketOut(WorldServerOpCode.CMSG_UPDATE_ACCOUNT_DATA); packet.Write(0x00000002); packet.Write((UInt32)0); Send(packet); }
public void SendEmote(EmoteType EmoteType) { PacketOut packet = new PacketOut(WorldServerOpCode.CMSG_TEXT_EMOTE); packet.Write((UInt32)EmoteType); packet.Write((UInt32)0x00); packet.Write((UInt64)0x00); Send(packet); }
public void CastSpell(Object target, UInt32 SpellId) { SpellTargetFlags flags = 0; if (target == objectMgr.getPlayerObject()) flags = SpellTargetFlags.Self; else { flags = SpellTargetFlags.Unit; //Target(target as Unit); } PacketOut packet = new PacketOut(WorldServerOpCode.CMSG_CAST_SPELL); packet.Write(SpellId); packet.Write((byte)0); // unk flags in WCell packet.Write((UInt32)flags); // 0x18A02 if (flags.Has(SpellTargetFlags.SpellTargetFlag_Dynamic_0x10000 | SpellTargetFlags.Corpse | SpellTargetFlags.Object | SpellTargetFlags.PvPCorpse | SpellTargetFlags.Unit)) { packet.Write(target.Guid.GetNewGuid()); } // 0x1010 if (flags.Has(SpellTargetFlags.TradeItem | SpellTargetFlags.Item)) { packet.Write(target.Guid.GetNewGuid()); } // 0x20 if (flags.Has(SpellTargetFlags.SourceLocation)) { packet.Write(objectMgr.getPlayerObject().Position.X); packet.Write(objectMgr.getPlayerObject().Position.Y); packet.Write(objectMgr.getPlayerObject().Position.Z); } // 0x40 if (flags.Has(SpellTargetFlags.DestinationLocation)) { packet.Write(target.Guid.GetNewGuid()); packet.Write(target.Position.X); packet.Write(target.Position.Y); packet.Write(target.Position.Z); } Send(packet); }
void Heartbeat(object source, ElapsedEventArgs e) { if (objectMgr.getPlayerObject().Position == null) return; PacketOut packet = new PacketOut(WorldServerOpCode.MSG_MOVE_HEARTBEAT); packet.Write(movementMgr.Flag.MoveFlags); packet.Write((byte)0); packet.Write((UInt32)MM_GetTime()); packet.Write((float)objectMgr.getPlayerObject().Position.X); packet.Write((float)objectMgr.getPlayerObject().Position.Y); packet.Write((float)objectMgr.getPlayerObject().Position.Z); packet.Write((float)objectMgr.getPlayerObject().Position.O); packet.Write((UInt32)0); Send(packet); }
public void Attack(Object target) { PacketOut packet = new PacketOut(WorldServerOpCode.CMSG_SET_SELECTION); if (objectMgr.getPlayerObject() != null) { packet.Write(target.Guid.GetNewGuid()); } Send(packet); packet = new PacketOut(WorldServerOpCode.CMSG_ATTACKSWING); if (objectMgr.getPlayerObject() != null) { packet.Write(target.Guid.GetNewGuid()); } Send(packet); }
public void RequestRealmlist() { PacketOut packet = new PacketOut(LogonServerOpCode.REALM_LIST); packet.Write(0x00); Send(packet); // Most tricky code ever. It's so because retail server sends a lot of data in this packet... byte[] temp = pLoop.OnReceive(3); PacketIn p1 = new PacketIn(temp, true); byte[] temp2 = pLoop.OnReceive(p1.ReadUInt16()); byte[] temp3 = new byte[temp.Length + temp2.Length]; temp.CopyTo(temp3, 0); temp2.CopyTo(temp3, temp.Length); p1 = new PacketIn(temp3, false); HandlePacket(p1); }
void Ping(object source, ElapsedEventArgs e) { while(!mSocket.Connected) { aTimer.Enabled = false; aTimer.Stop(); return; } Ping_Req_Time = MM_GetTime(); PacketOut ping = new PacketOut(WorldServerOpCode.CMSG_PING); ping.Write(Ping_Seq); ping.Write(Latency); Send(ping); }
public void Send(PacketOut packet) { try { if (!Connected) return; Log.WriteLine(LogType.Network, "Sending packet: {0}", packet.packetId); if (!Connected) return; Byte[] Data = packet.ToArray(); int Length = Data.Length; byte[] Packet = new byte[2 + Length]; Packet[0] = (byte)(Length >> 8); Packet[1] = (byte)(Length & 0xff); Data.CopyTo(Packet, 2); mCrypt.Encrypt(Packet, 0, 6); //While writing this part of code I had a strange feeling of Deja-Vu or whatever it's called :> Log.WriteLine(LogType.Packet,"{0}", packet.ToHex()); mSocket.Send(Packet); } catch (Exception ex) { Log.WriteLine(LogType.Error, "Exception Occured"); Log.WriteLine(LogType.Error, "Message: {0}", ex.Message); Log.WriteLine(LogType.Error, "Stacktrace: {0}", ex.StackTrace); } }
public void QueryName(UInt64 guid) { PacketOut packet = new PacketOut(WorldServerOpCode.CMSG_NAME_QUERY); packet.Write(guid); Send(packet); }
public void QueryName(WoWGuid guid) { PacketOut packet = new PacketOut(WorldServerOpCode.CMSG_NAME_QUERY); packet.Write(guid.GetNewGuid()); Send(packet); }
public void ObjectQuery(WoWGuid guid, UInt32 entry) { PacketOut packet = new PacketOut(WorldServerOpCode.CMSG_Object_QUERY); packet.Write(entry); packet.Write(guid.GetNewGuid()); Send(packet); }
public void SendEmoteMsg(ChatMsg Type, Languages Language, string Message, string To) { PacketOut packet = new PacketOut(WorldServerOpCode.CMSG_TEXT_EMOTE); packet.Write((UInt32)Type); packet.Write((UInt32)Language); packet.Write(Message); Send(packet); }
public void SendChatMsg(ChatMsg Type, Languages Language, string Message, string To) { PacketOut packet = new PacketOut(WorldServerOpCode.CMSG_MESSAGECHAT); packet.Write((UInt32)Type); packet.Write((UInt32)Language); if ((Type == ChatMsg.Whisper || Type == ChatMsg.Channel) && To != "") packet.Write(To); packet.Write(Message); Send(packet); }
public void HandleAuthResponse(PacketIn packet) { LoginErrorCode error = (LoginErrorCode)packet.ReadByte(); if (error == LoginErrorCode.AUTH_OK) { PacketOut outpacket = new PacketOut(WorldServerOpCode.CMSG_CHAR_ENUM); Send(outpacket); } else { Log.WriteLine(LogType.Error, "M values doesn't match, please try again."); Disconnect(); } }
public void Authenticate() { PacketOut packet = new PacketOut(LogonServerOpCode.AUTH_LOGON_CHALLENGE); packet.Write((byte)3); packet.Write((UInt16)(30 + mUsername.Length)); packet.Write((byte)'W'); packet.Write((byte)'o'); packet.Write((byte)'W'); packet.Write((byte)'\0'); // WoW packet.Write((byte)Config.Version.major); packet.Write((byte)Config.Version.minor); packet.Write((byte)Config.Version.update); packet.Write((UInt16)Config.Version.build); packet.Write((byte)'6'); packet.Write((byte)'8'); packet.Write((byte)'x'); packet.Write((byte)'\0'); // 68x packet.Write((byte)'n'); packet.Write((byte)'i'); packet.Write((byte)'W'); packet.Write((byte)'\0'); // niW packet.Write((byte)'B'); packet.Write((byte)'G'); packet.Write((byte)'n'); packet.Write((byte)'e'); // SUne packet.Write(1); packet.Write((byte)127); packet.Write((byte)0); packet.Write((byte)0); packet.Write((byte)1); // Interestingly, mac sends IPs in reverse order. packet.Write((byte)mUsername.Length); packet.Write(Encoding.Default.GetBytes(mUsername)); // Name - NOT null terminated Send(packet); pLoop.Start(); }
public void AuthChallangeRequest(PacketIn packetIn) { packetIn.ReadByte(); byte error = packetIn.ReadByte(); if (error != 0x00) { Log.WriteLine(LogType.Error, "Authentication error: {0}", (AccountStatus)error); Disconnect(); return; } B = new BigInteger(packetIn.ReadBytes(32)); // Varies byte glen = packetIn.ReadByte(); // Length = 1 g = packetIn.ReadBytes(glen); // g = 7 byte Nlen = packetIn.ReadByte(); // Length = 32 N = packetIn.ReadBytes(Nlen); // N = B79B3E2A87823CAB8F5EBFBF8EB10108535006298B5BADBD5B53E1895E644B89 Salt = new BigInteger(packetIn.ReadBytes(32)); // Salt = 3516482AC96291B3C84B4FC204E65B623EFC2563C8B4E42AA454D93FCD1B56BA crcsalt = packetIn.ReadBytes(16); // Varies BigInteger S; srp = new Srp6(new BigInteger(N), new BigInteger(g)); do { a = BigInteger.Random(19 * 8); A = srp.GetA(a); I = Srp6.GetLogonHash(mUsername, mPassword); BigInteger x = Srp6.Getx(Salt, I); BigInteger u = Srp6.Getu(A, B); S = srp.ClientGetS(a, B, x, u); } while (S < 0); mKey = Srp6.ShaInterleave(S); M = srp.GetM(mUsername, Salt, A, B, new BigInteger(mKey)); packetIn.ReadByte(); Sha1Hash sha; byte[] files_crc; // Generate CRC/hashes of the Game Files if (Config.Retail) files_crc = GenerateCrc(crcsalt); else files_crc = new byte[20]; // get crc_hash from files_crc sha = new Sha1Hash(); sha.Update(A); sha.Update(files_crc); byte[] crc_hash = sha.Final(); PacketOut packet = new PacketOut(LogonServerOpCode.AUTH_LOGON_PROOF); packet.Write(A); // 32 bytes packet.Write(M); // 20 bytes packet.Write(crc_hash); // 20 bytes packet.Write((byte)0); // number of keys packet.Write((byte)0); // unk (1.11.x) Send(packet); }
public void DoAuthSession() { try { PacketOut packet = new PacketOut(WorldServerOpCode.CMSG_AUTH_SESSION); Sha1Hash sha = new Sha1Hash(); sha.Update(mUsername); sha.Update(new byte[4]); // t sha.Update(ClientSeed); sha.Update(ServerSeed); sha.Update(mKey); byte[] Digest = sha.Final(); packet.Write((UInt32)Config.Version.build); packet.Write((UInt32)0); packet.Write(mUsername); packet.Write((UInt32)0); packet.Write(ClientSeed); packet.Write((UInt64)0); packet.Write(Digest); bool WantToCrash = false; if (WantToCrash) { byte[] addons = { (byte)0x00 }; byte[] buffer2 = mClient.Shared.Compression.Compress(addons); UInt32 Size = (UInt32)addons.Length; packet.Write(Size); packet.Write(buffer2); } else { byte[] addon_data = { 0x56, 0x01, 0x00, 0x00, 0x78, 0x9c, 0x75, 0xcc, 0xbd, 0x0e, 0xc2, 0x30, 0x0c, 0x04, 0xe0, 0xf2, 0x1e, 0xbc, 0x0c, 0x61, 0x40, 0x95, 0xc8, 0x42, 0xc3, 0x8c, 0x4c, 0xe2, 0x22, 0x0b, 0xc7, 0xa9, 0x8c, 0xcb, 0x4f, 0x9f, 0x1e, 0x16, 0x24, 0x06, 0x73, 0xeb, 0x77, 0x77, 0x81, 0x69, 0x59, 0x40, 0xcb, 0x69, 0x33, 0x67, 0xa3, 0x26, 0xc7, 0xbe, 0x5b, 0xd5, 0xc7, 0x7a, 0xdf, 0x7d, 0x12, 0xbe, 0x16, 0xc0, 0x8c, 0x71, 0x24, 0xe4, 0x12, 0x49, 0xa8, 0xc2, 0xe4, 0x95, 0x48, 0x0a, 0xc9, 0xc5, 0x3d, 0xd8, 0xb6, 0x7a, 0x06, 0x4b, 0xf8, 0x34, 0x0f, 0x15, 0x46, 0x73, 0x67, 0xbb, 0x38, 0xcc, 0x7a, 0xc7, 0x97, 0x8b, 0xbd, 0xdc, 0x26, 0xcc, 0xfe, 0x30, 0x42, 0xd6, 0xe6, 0xca, 0x01, 0xa8, 0xb8, 0x90, 0x80, 0x51, 0xfc, 0xb7, 0xa4, 0x50, 0x70, 0xb8, 0x12, 0xf3, 0x3f, 0x26, 0x41, 0xfd, 0xb5, 0x37, 0x90, 0x19, 0x66, 0x8f }; packet.Write(addon_data); } Send(packet); mCrypt = new PacketCrypt(mKey); mCrypt.Init(); } catch (Exception e) { Log.WriteLine(LogType.Error, e.StackTrace); } }
public void LoginPlayer(Character chr) { PacketOut outpacket = new PacketOut(WorldServerOpCode.CMSG_PLAYER_LOGIN); outpacket.Write(chr.GUID); Send(outpacket); outpacket = new PacketOut(WorldServerOpCode.CMSG_UPDATE_ACCOUNT_DATA); outpacket.Write((UInt32)7); outpacket.Write((UInt32)5144); outpacket.Write(account_data); Send(outpacket); objectMgr.MapID = chr.MapID; objectMgr.playerGuid = new WoWGuid(chr.GUID); objectMgr.getPlayerObject().SetPlayer(chr); StartHeartbeat(); movementMgr.Start(); combatMgr.Start(); terrainMgr.ChangeMap(chr.MapID); Log.WriteLine(LogType.Success, "Logged into world as {0}.", chr.Name); }
public void Send(PacketOut packet) { if (Connected) { Log.WriteLine(LogType.Network, "Sending packet {0}. Length: {1}", packet.packetId.ToString(), packet.Lenght()); Log.WriteLine(LogType.Packet, "{0}", packet.ToHex()); Byte[] Data = packet.ToArray(); mSocket.Send(Data); } }
public void JoinChannel(string channel, string password) { PacketOut packet = new PacketOut(WorldServerOpCode.CMSG_JOIN_CHANNEL); packet.Write((UInt32)0); packet.Write((UInt16)0); packet.Write(channel); packet.Write(""); Send(packet); }