C # - Unable to get server response from UDP - Black Ops Rcon

I am building an RCON web application for Call of Duty Black Ops. COD uses the rcon and udp packages to send and receive information. Using the following code, I was able to send and receive information from the COD4 server. Now that COD7 is missing, I no longer get the answers.

Socket client = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
client.Connect(IPAddress.Parse(gameServerIP), gameServerPort);

string command;
command = password + " " + rconCommand;
byte[] bufferTemp = Encoding.ASCII.GetBytes(command);
byte[] bufferSend = new byte[bufferTemp.Length + 5];

//intial 5 characters as per standard
bufferSend[0] = byte.Parse("255");
bufferSend[1] = byte.Parse("255");
bufferSend[2] = byte.Parse("255");
bufferSend[3] = byte.Parse("255");
bufferSend[4] = byte.Parse("02");
int j = 5;

for (int i = 0; i < bufferTemp.Length; i++)
{
    bufferSend[j++] = bufferTemp[i];
}

//send rcon command and get response
IPEndPoint RemoteIpEndPoint = new IPEndPoint(IPAddress.Any, 0);
client.Send(bufferSend, SocketFlags.None);

//big enough to receive response
byte[] bufferRec = new byte[65000];
client.Receive(bufferRec);            

Does anyone have any ideas? Black Ops comes with its own Rcon tool, which I tried to use Wireshark to capture outgoing packets for copying. Outgoing packets between my application and their next to identical ones, except that I do not receive answers when I use mine.

+3
source share
4 answers

, .

: bufferSend [4] = byte.Parse( "02" );

: bufferSend [4] = byte.Parse( "00" );

, !

+3

, :

:

, , , .

      private IPEndPoint ipendpoint;
      private string command;
      private string response;

      private void worker()
      {
        UdpClient client = new UdpClient();
        var result1 = string.Empty;
        var result2 = string.Empty;
        bool sent = false;
        bool DoubleTrame = false;
        Byte[] bufferTemp = Encoding.ASCII.GetBytes(this.command);
        Byte[] bufferSend = new Byte[bufferTemp.Length + 5];
        Byte[] bufferRec;
        Byte[] bufferRec2;

        bufferSend[0] = Byte.Parse("255");
        bufferSend[1] = Byte.Parse("255");
        bufferSend[2] = Byte.Parse("255");
        bufferSend[3] = Byte.Parse("255");
        bufferSend[4] = Byte.Parse("00");

        for (int i = 0; i < bufferTemp.Length; i++)
        {
            bufferSend[i + 5] = bufferTemp[i];
        }

        while (!sent)
        {
            client.Send(bufferSend, bufferSend.Length, ipendpoint);
            Thread.Sleep(200);
            if (client.Available > 0)
            {
                sent = true;
                if (client.Available > 1200)
                {
                    DoubleTrame = true;
                }
            }
        }
        bufferRec = client.Receive(ref ipendpoint);
        if (DoubleTrame)
        {
            bufferRec2 = client.Receive(ref ipendpoint);
            result2 = Encoding.ASCII.GetString(bufferRec2);
            if (result2.Contains("\n\n"))
            {
                result2 = result2.Remove(result2.IndexOf("\n\n"));
            }
            result2 = result2.Substring(12);
        }
        result1 = Encoding.ASCII.GetString(bufferRec);
        this.response = result1 + result2;
      }
+1

, vb.net rcon- COD MW COD WW , ops.

0

, , , WireShark, , rconTool, Black Ops.

:

"status" , .

teamstatus, , .

, , , :

:

    byte[] bufferRec = new byte[65000];
    client.Receive(bufferRec);  

:

      byte[] bufferRec;
            while (client.Available == 0)
            {
                Thread.Sleep(10);
            }
        client.Receive(bufferRec);  
string response=Encoding.ASCII.GetString(bufferRec);
var list= response.Split('\n');

, , .

Btw: , ,

: oups, , teamstatus.

. , 1168 , , client.Avalaible > 1168, , client.receive.

In fact, there are only two possible numbers for the client. Available: 1168 and 2336 (yes, dual). I don’t know why, but they were not able to send the exact amount of data, the buffer is always full or empty.

I also noticed that the second trick () is like "pasting" into the first buffer.

You will have the opportunity to get additional information about the first Receive (), then about the "noise" of the old.

Just take a look, you will see what I mean.

I'm at work now, but tonight I will send my code to help.

0
source

Source: https://habr.com/ru/post/1774736/


All Articles