public void SendPacket(Packet pPacket) { if (Connector.connected) { Connector.SendPacket(pPacket); } }
public override void OnPacketInbound(Packet pPacket) { if (pPacket.Length == 0) return; pPacket.Reset(0); AC_OnPacketInbound(pPacket); }
public override void handlePackets(Packet packet) { //Logger.WriteLine("Got packet: {0}", packet.ToString()); switch (packet.ReadShort()) { case 0x06: handleWorld(packet); break; // 0x0A case 0x0F: sendPong(); break; } }
public override void OnHandshakeInbound(Packet pPacket) { base.PrintPacket(pPacket, " SERVER HANDSHAKE -> BYPASS", true); Console.WriteLine("HANDSHAKE IN"); try { ClientSession.Instance.SendHandshake(base.MapleVersion, base.MaplePatchLocation, base.MapleLocale); } catch { } }
public override void handlePackets(Packet packet) { packet.KoreanText = true; //Logger.WriteLine("Got packet: {0}", packet.ToString()); switch (packet.ReadShort()) { case 0x03: handleWorld(packet); break; // 0x0A case 0x0C: sendPong(); break; // 0x11 //default: Logger.WriteLine("Unknown packet: {0}", packet.ToString()); break; } }
public override void OnPacketInbound(Packet pPacket) { Console.WriteLine("Got packet from client -> Server: " + pPacket.ToString()); base.PrintPacket(pPacket, " CLIENT -> BYPASS", true); //string header = pPacket.ToString().Substring(0, 2); // NOTE: Do not use this. It'll slow down the connection a whole lot. Just read the first ushort and use it. if (Program.ServerSession != null) { ushort header = pPacket.ReadUShort(); Program.ServerSession.SendPacket(pPacket); switch (header) { case 0x0036: SendLoginData(Form1.Username, Form1.Password); break; case 0x002F: HandleIntAuth(pPacket); break; } } }
public override void OnPacketInbound(Packet pPacket) { // Console.WriteLine("Got packet from server -> client: " + pPacket.ToString()); base.PrintPacket(pPacket, " SERVER -> BYPASS", true); ushort header = pPacket.ReadUShort(); if ((ClientSession.Instance != null) && !ClientSession.Instance.Disconnected) { if (header == 0x000B) ConnectToChannelServer(pPacket); else if (header == 0x0011) //old:0x010 ChangeChannel(pPacket); else { ClientSession.Instance.SendPacket(pPacket); } } }
private void ChangeChannel(Packet pPacket) { byte status = pPacket.ReadByte(); string ip = string.Format("{0}.{1}.{2}.{3}", pPacket.ReadByte(), pPacket.ReadByte(), pPacket.ReadByte(), pPacket.ReadByte()); // Ignore IP ushort port = pPacket.ReadUShort(); byte[] leftover = pPacket.ReadLeftoverBytes(); CCing = true; NextPort = port; Packet packet = new Packet(); packet.WriteUShort(0x0011); packet.WriteByte(1); packet.WriteBytes(Constants.MapleStory_LoginIP_Bytes); packet.WriteUShort(8484); packet.WriteBytes(leftover); ClientSession.Instance.SendPacket(packet); Console.WriteLine("1 Status "+status+": Change Channel: " + packet.ToString()); }
public void sendHSInit() { var packet = new Packet(); packet.WriteShort(0x25); packet.WriteByte(1); packet.WriteLong(0); SendCheckedPacket(packet); }
public override void sendClientReady() { sendHSInit(); Packet packet = new Packet(); packet.WriteShort(0x32); packet.WriteByte(_locale); packet.WriteShort(version); packet.WriteShort(subversion); SendCheckedPacket(packet); }
public virtual void SendPacket(Packet pPacket) { SendData(pPacket.ToArray()); }
public override void sendWorldListReRequest() { Packet packet = new Packet(); packet.WriteShort(0x19); SendCheckedPacket(packet); }
private void SendLoginData(string username, string password) { Packet writer = new Packet(); writer.WriteShort(0x01); writer.WriteMapleString(password); writer.WriteMapleString(username); Program.ServerSession.SendPacket(writer); }
private void HandleIntAuth(Packet pPacket) { //int x; Packet writer = new Packet(); // lol = new Tools.LookupTable(Application.StartupPath + @"\data.txt"); //lol.Parse(); // 30 00 XX XX 00 00 // Skipping header.. // XX XX 00 00 //pPacket.Skip(2); int request = pPacket.ReadInt(); writer.WriteShort(0x14); writer.WriteInt(Test(request)); Console.WriteLine("Response: " + writer.ToString()); this.SendPacket(writer); }
public override void SendPacket(Packet pPacket) { base.PrintPacket(pPacket, " BYPASS -> CLIENT", true); base.SendPacket(pPacket); }
public abstract void handlePackets(Packet packet);
public override void OnHandshakeInbound(Packet pPacket) { Logger.WriteLine("Received HandShake packet"); Program.UpdateDate(); short version = (short)MapleVersion; string patchLocation = MaplePatchLocation; byte locale = MapleLocale; if (oldPatchLocation == "XD" || (oldVersion == version && oldPatchLocation == patchLocation && oldLocale == locale)) { TwitterClient.Instance.SendMessage("Connected with the {0} server. Version: V{1}.{2}", GetMapleStoryLocale(locale), version, patchLocation); } else { TwitterClient.Instance.SendMessage("Connected with the {0} server, and it seems to be updated! From V{1}.{2} to V{3}.{4} #MapleStory", GetMapleStoryLocale(locale), oldVersion, oldPatchLocation, version, patchLocation); } oldVersion = version; oldPatchLocation = patchLocation; oldLocale = locale; Logger.WriteLine("Version: {0}; Patch location: '{1}'; Locale: {2}", oldVersion, oldPatchLocation, oldLocale); switch (locale) { case 1: MapleClient = new MapleKorea(this, version, short.Parse(patchLocation)); break; case 7: MapleClient = new MapleSEA(this, version, short.Parse(patchLocation)); break; case 8: GMSKeys.Initialize(); MapleClient = new MapleGlobal(this, version, short.Parse(patchLocation)); break; } State = MapleState.WorldSelect; Logger.WriteLine("MapleClient: {0}", MapleClient.ToString()); MapleClient.HandlingVersion = version; MapleClient.sendClientReady(); Logger.WriteLine("Done"); MapleClient.sendWorldListReRequest(); connected = true; if (lostConnection && lastDisconnect != DateTime.MinValue && (DateTime.Now - lastDisconnect).TotalMinutes > 5) { TwitterClient.Instance.SendMessage("{0} downtime: {1} minutes", GetMapleStoryLocale(locale), (DateTime.Now - lastDisconnect).TotalMinutes); } lastDisconnect = DateTime.MinValue; lostConnection = false; }
public void sendHSKey(int pValue) { var packet = new Packet(); packet.WriteShort(0x25); packet.WriteByte(0); packet.WriteInt(pValue); packet.WriteInt(0); _session.SendPacket(packet); }
public override void sendPong() { Packet packet = new Packet(); packet.WriteShort(0x39); packet.WriteShort(0); // Same as MSEA? packet.WriteInt(0); // 0 packet.WriteInt(0); // Random ? SendCheckedPacket(packet); }
public abstract void AC_OnPacketInbound(Packet pPacket);
private void SendCheckedPacket(Packet pPacket) { while (true) { ushort idx = BitConverter.ToUInt16(_session.EncryptIV, 0); if ((idx % 31) == 0) sendHSKey(CRC32.calcCrc32(_session.EncryptIV, 2)); else break; } _session.SendPacket(pPacket); }
public virtual void OnHandshakeInbound(Packet pPacket) { SendHandshake(_mapleVersion, _maplePatchLocation, _mapleLocale); }
public void handleWorld(Packet packet) { byte ID = packet.ReadByte(); if (ID == 0xFF) { HandleData(null); // Logger.WriteLine("Worlds: {0}; Channels: {1}; Channel load avg: {2}", iworlds, ichannels, (double)Program.mTotalOnline / (double)ichannels); gotData = true; iworlds = ichannels = 0; return; } iworlds++; string name = packet.ReadString(); byte ribbon = packet.ReadByte(); // Ribbon string eventMsg = packet.ReadString(); // Event message packet.ReadShort(); // EXP rate packet.ReadShort(); // DROP rate int channels = packet.ReadByte(); ichannels += channels; if (!gotData) DataBase.UpdateWorldData(ID, name, channels, ribbon, eventMsg); if (Config.Instance.SkipWorlds.Contains(ID)) return; List<Channel> channelList = new List<Channel>(); Channel chan; for (int i = 0; i < channels; i++) { chan = new Channel(); chan.ChannelName = packet.ReadString(); chan.Population = packet.ReadInt(); chan.World = packet.ReadByte(); chan.ID = packet.ReadByte(); chan.ID += 1; chan.SpecialValue = packet.ReadByte(); channelList.Add(chan); Program.Connection.AmountOnline += chan.Population; if (OldLoads.ContainsKey(chan.ChannelName) && OldLoads[chan.ChannelName] >= 10 && (chan.Population * 100 / OldLoads[chan.ChannelName]) <= 20) { Logger.WriteLine("{0} crashed, as it went from {1:N0} to {2:N0} people online.", chan.ChannelName, OldLoads[chan.ChannelName], chan.Population); DataBase.AddCrash(chan.World, chan.ID, OldLoads[chan.ChannelName], chan.Population); TweetCrash(chan); } if (chan.Population < 0) { Logger.WriteLine("Seems like Nexon didn't fix the negative bug: Channel {0} has {1} players online.", chan.ChannelName, chan.Population); chan.Population = Math.Abs(chan.Population); // Make it positive! } if (OldLoads.ContainsKey(chan.ChannelName)) { OldLoads[chan.ChannelName] = chan.Population; } else { OldLoads.Add(chan.ChannelName, chan.Population); } } HandleData(channelList); }
public string PrintPacket(Packet pPacket, string pWhat, bool ret = false) { return PrintPacket(pWhat, pPacket.ToArray(), false); }
public virtual void OnPacketInbound(Packet pPacket) { Console.WriteLine(TypeName + " No Handler for 0x{0:X4}", pPacket.ReadUShort()); }
public override void sendClientReady() { Packet packet = new Packet(); packet.WriteShort(0x14); packet.WriteByte(_locale); packet.WriteShort(version); packet.WriteShort(subversion); _session.SendPacket(packet); }
public void SendHandshake(ushort pVersion, string pPatchLocation, byte pLocale) { _encryptIV = new byte[4]; rnd.NextBytes(_encryptIV); _decryptIV = new byte[4]; rnd.NextBytes(_decryptIV); Packet packet = new Packet(); packet.WriteUShort(pVersion); packet.WriteString(pPatchLocation); packet.WriteBytes(_decryptIV); packet.WriteBytes(_encryptIV); packet.WriteByte(pLocale); SendPacket(packet); _mapleVersion = pVersion; _maplePatchLocation = pPatchLocation; _mapleLocale = pLocale; }
public override void sendPong() { Packet packet = new Packet(); if (HandlingVersion >= 153) packet.WriteShort(0x46); else if (HandlingVersion >= 145) packet.WriteShort(0x45); else if (HandlingVersion >= 143) packet.WriteShort(0x46); else if (HandlingVersion >= 118) packet.WriteShort(0x2D); else if (HandlingVersion >= 115) packet.WriteShort(0x2C); else if (HandlingVersion >= 101) packet.WriteShort(0x2E); else if (HandlingVersion >= 99) packet.WriteShort(0x1B); else if (HandlingVersion >= 86) packet.WriteShort(0x1A); else if (HandlingVersion >= 83) packet.WriteShort(0x19); else packet.WriteShort(0x18); if (HandlingVersion >= 143) packet.WriteInt(0); _session.SendPacket(packet); }
/// <summary> /// Used as IAsyncResult parser for ContinueReading(). /// </summary> /// <param name="pIAR">The result AsyncCallback makes</param> private void EndReading(IAsyncResult pIAR) { int amountReceived = 0; try { amountReceived = _socket.EndReceive(pIAR); } catch (Exception ex) { amountReceived = 0; Console.WriteLine(TypeName + " amountReceived == 0! " + ex.ToString()); } if (amountReceived == 0) { Console.WriteLine(TypeName + " amountReceived == 0! OnDisconnectInternal()"); // We got a disWvsBeta.Common.Sessions here! OnDisconnectINTERNAL(); return; } // Add amount of bytes received to _bufferpos so we know if we got everything. _bufferpos += amountReceived; try { // Check if we got all data. There is _no_ way we would have received more bytes than needed. Period. if (_bufferpos == _bufferlen) { // It seems we have all data we need // Now check if we got a header if (_header) { if (!_encryption && _receivingFromServer) { // Unencrypted packets have a short header with plain length. ushort length = (ushort)(_buffer[0] | _buffer[1] << 8); StartReading(length); } else { int length = GetHeaderLength(_buffer); StartReading(length); } } else { Packet packet; if (_encryption) { _buffer = Decrypt(_buffer); packet = new Packet(_buffer); DoAction((date) => { try { OnPacketInbound(packet); } catch (Exception ex) { Console.WriteLine("Handling Packet Error: {0}", ex.ToString()); } }); } else { _encryption = true; // First packet received or sent is unencrypted. All others are. packet = new Packet(_buffer); _mapleVersion = packet.ReadUShort(); _maplePatchLocation = _maplePatchLocation = packet.ReadString(); _encryptIV = packet.ReadBytes(4); _decryptIV = packet.ReadBytes(4); _mapleLocale = packet.ReadByte(); Console.WriteLine(TypeName + " MapleVersion: {0}; Patch Location: {1}; Locale: {2}", _mapleVersion, _maplePatchLocation, _mapleLocale); if (_mapleLocale == 8 && _mapleVersion >= 118) { SwitchAESByVersion(_mapleVersion); } packet.Reset(); DoAction((date) => { try { OnHandshakeInbound(packet); } catch (Exception ex) { Console.WriteLine("Handling Packet Error: {0}", ex.ToString()); } }); } StartReading(4, true); } } else { ContinueReading(); } } catch (SocketException socketException) { Console.WriteLine(TypeName + " Socket Exception while receiving data: {0}", socketException.Message); OnDisconnectINTERNAL(); } catch (Exception ex) { Console.WriteLine(TypeName + " [ERROR] EndReading(): {0}", ex.ToString()); OnDisconnectINTERNAL(); } }
public override void sendWorldListReRequest() { Packet packet = new Packet(); // packet.WriteShort(0x19); packet.WriteShort(0x1A); _session.SendPacket(packet); }