C# Packet Send to Game Client

33 Views Asked by At

I want to send packets to the game like WPE but use my specific packet and my own interfaces

so i try send packet example : Byte[] data = { 0x20, 0x00, 0x00, 0x00, 0x8D, 0x45, 0x06, 0x00, 0x3F, 0x1B, 0x82, 0x14, 0x7F, 0x34, 0xD3, 0x59, 0xB5, 0xF3, 0x7F, 0xD9, 0x63, 0x4F, 0x8F, 0x5C, 0x1B, 0x19, 0x13, 0xCE, 0x2E, 0x05, 0x55, 0xE7 };

I tried to send a packet but in the game, nothing happened, so I tried to sniff my connection using wireshark or another it's correct the same result was sent like using WPE but in the game client nothing happened.

Does anyone know why? Does anyone have a source packet sending using C#?

public static void Connect(String server, String message)
{
    try
    {
        // Create a TcpClient.
        // Note, for this client to work you need to have a TcpServer 
        // connected to the same address as specified by the server, port
        // combination.
        Int32 port = 1818;
        TcpClient client = new TcpClient(server, port);

        // Translate the passed message into ASCII and store it as a Byte array.
        Byte[] data = { 0x20, 0x00, 0x00, 0x00, 0x8D, 0x45, 0x06, 0x00, 0x66, 0x41, 0x00, 0x94, 0xC6, 0xF1, 0xB9, 0xF2, 0x67, 0xBD, 0x02, 0x00, 0x29, 0x3A, 0x2D, 0x36, 0xDE, 0x1B, 0xB6, 0x94, 0xE8, 0x97, 0x19, 0xB2 };

        // Get a client stream for reading and writing.
        //  Stream stream = client.GetStream();

        NetworkStream stream = client.GetStream();

        // Send the message to the connected TcpServer. 
        stream.Write(data, 0, data.Length);

        Console.WriteLine("Sent: {0}", message);

        // Receive the TcpServer.response.

        // Buffer to store the response bytes.
        data = new Byte[256];

        // String to store the response ASCII representation.
        String responseData = String.Empty;

        // Read the first batch of the TcpServer response bytes.
        Int32 bytes = stream.Read(data, 0, data.Length);
        responseData = System.Text.Encoding.ASCII.GetString(data, 0, bytes);
        Console.WriteLine("Received: {0}", responseData);

        // Close everything.
        stream.Close();
        client.Close();
    }
    catch (ArgumentNullException e)
    {
        Console.WriteLine("ArgumentNullException: {0}", e);
    }
    catch (SocketException e)
    {
        Console.WriteLine("SocketException: {0}", e);
    }

    Console.WriteLine("\n Press Enter to continue...");
    Console.Read();
}
0

There are 0 best solutions below