Quake 3 server modify incoming packet

Programming related discussions related to game research
navgg
Posts: 3
Joined: Thu Sep 21, 2017 11:46 am

Quake 3 server modify incoming packet

Post by navgg »

I was trying to modify name parameter in incoming connection packet to server of quake 3 protocol 43 with proxocket in myrecvfrom method.
Here is my code of myrecvfrom:

Code: Select all

int __cdecl myrecvfrom(SOCKET s, u_char *buf, int len, int flags, struct sockaddr *from, int *fromlen) {             

   if (buf[0] == 0xFF && buf[1] == 0xFF &&
      buf[4] == 'c' && buf[7] == 'n') {      
      buf = find_replace_string(buf, &len, "name\\TEST1", "name\\TEST2");
   }

    return(len);
}

But it seems server still receiving original packet. I wonder is it even possible, or maybe I'm doing something wrong? :?
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Quake 3 server modify incoming packet

Post by aluigi »

First you must be 100% sure that proxocket is loaded, if I remember correctly you have to set a registry key on Windows 7 and above.

Then the find_replace_string function reallocate the buffer if the new string is bigger than the original one, so "buf" will not be updated and there are probably also other downsides because the original buffer is freed as far as I remember.
navgg
Posts: 3
Joined: Thu Sep 21, 2017 11:46 am

Re: Quake 3 server modify incoming packet

Post by navgg »

I double checked and it seems proxocket works good. I think I understand what's the problem.
According to server log it received modified packet, however after connection it seems received once more info from client and changed it back.
Server log:

Code: Select all

ClientUserinfoChanged: 0 n\TEST2\t\2\model\sarge/blue\c1\4\hc\300\w\0\l\0
broadcast: print "TEST2 connected\n"
ClientUserinfoChanged: 0 n\TEST1\t\2\model\sarge/blue\c1\4\hc\300\w\0\l\0
broadcast: print "TEST1 entered the game\n"

Unfortunately after connection all info is not simply readable and encoded.
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Quake 3 server modify incoming packet

Post by aluigi »

Ah right the game commands. The name of the player is "updated" with the cl->userinfo string sent via SV_UpdateUserinfo_f, SV_DirectConnect and SV_UserinfoChanged.
Things that you can't change by using a raw socket solution.