//Eventually move this out of socket public void Initialize(ushort version) { m_version = version; m_siv = new MapleIV(0xBADF00D); m_riv = new MapleIV(0XDEADBEEF); //m_siv = new MapleIV(0x52616A61); //Raja //m_riv = new MapleIV(0x6E523078); //nR0x using (var p = new COutPacket()) { p.Encode2(0x0E); p.Encode2((short)version); p.EncodeString("1"); p.Encode4((int)m_riv.Value); p.Encode4((int)m_siv.Value); p.Encode1(8); var buffer = p.ToArray(); SendRaw(buffer); } Receive(); }
public void Dispose() { if (!Disposed) { Disposed = true; try { m_socket.Shutdown(SocketShutdown.Both); } catch { /*Nothing*/ } try { m_socket.Dispose(); } catch { /*Nothing*/ } m_buffer = null; m_offset = 0; m_siv = null; m_riv = null; OnDisconnected?.Invoke(); } }
//Eventually move this out of socket public void Initialize(ushort version, string subversion, byte locale) { m_version = version; m_siv = new MapleIV((uint)IVRand.Next()); m_riv = new MapleIV((uint)IVRand.Next()); using (var p = new COutPacket()) { p.Encode2(0x0E); p.Encode2((short)version); p.EncodeString(subversion); p.Encode4((int)m_riv.Value); p.Encode4((int)m_siv.Value); p.Encode1(locale); var buffer = p.ToArray(); SendSync(buffer, 0, buffer.Length); } Receive(); }
/// <summary> /// Performs Maplestory's AES algo /// </summary> private void Transform(byte[] buffer) { int remaining = buffer.Length, length = 0x5B0, start = 0, index; byte[] realIV = new byte[sizeof(int) * 4], IVBytes = MapleIV.Bytes; while (remaining > 0) { for (index = 0; index < realIV.Length; ++index) { realIV[index] = IVBytes[index % 4]; } if (remaining < length) { length = remaining; } for (index = start; index < (start + length); ++index) { if (((index - start) % realIV.Length) == 0) { Transformer.TransformBlock(realIV); } buffer[index] ^= realIV[(index - start) % realIV.Length]; } start += length; remaining -= length; length = 0x5B4; } MapleIV.Shuffle(); }