private void Recv(TransferBuffer raw_buffer)
        {
            try
            {
                Packet p = null;
                if (raw_buffer.Size >= 10)
                {
                    var d_bytes = Crypto.UDPCrypto.Decrypt(raw_buffer.Buffer.Skip(3).ToArray());
                    p = new Packet(d_bytes[0x02], d_bytes[0x03]);
                    p.WriteUInt8Array(raw_buffer.Buffer.Take(2).ToArray());
                    p.WriteUInt8Array(d_bytes.Skip(7).ToArray());
                }
                else
                {
                    p = new Packet(0x00, 0x00, raw_buffer.Buffer);
                }

                p.Lock();

                p.ReadUInt8Array(0x02);
                m_incoming.Add(p);
            } catch (Exception ex)
            {
                Console.WriteLine("@@@@@@@@@@@@@@@@@@@@@@@@@@");
                Utility.Hexdump(raw_buffer.Buffer);
                Console.WriteLine(ex.Message + "\n" + ex.StackTrace);
                Console.WriteLine("@@@@@@@@@@@@@@@@@@@@@@@@@@");
            }
        }
Exemplo n.º 2
0
        private void SimulateTownTeleports(Packet packet, Context context, Context remote_context, Context local_context)
        {
            DNSecurityAPI.Packet fakePacket = new DNSecurityAPI.Packet(0x02, 0x01);
            fakePacket.WriteUInt8Array(packet.ReadUInt8Array(0x04));          //World server ID probably?
            fakePacket.WriteUInt8Array(Encoding.ASCII.GetBytes("127.0.0.1")); //remote IP to connect to
            string remIP = Encoding.ASCII.GetString(packet.ReadUInt8Array(14));

            fakePacket.WriteUInt8Array(new byte[23]); //IP padding
            packet.ReadUInt8Array(18);
            ushort remPort    = packet.ReadUInt16();
            int    _localPort = FreeTcpPort();

            fakePacket.WriteUInt16(_localPort);                    //remote port
            fakePacket.WriteUInt8Array(packet.ReadUInt8Array(14)); //Rest of the packet.
            Utility.Hexdump(fakePacket, true);
            Console.WriteLine($"Should connect to {remIP}:{remPort}");
            new Thread(() => Program.Proxy(remIP, remPort, _localPort)).Start();
            Thread.Sleep(1000);
            context.RelaySecurity.Send(fakePacket);
        }