PHP Server Info

Everything todo with programming goes HERE.
Post Reply
User avatar
Light
Reverse Outside Corner Grinder
Posts: 1667
Joined: Thu Oct 20, 2011 2:11 pm

PHP Server Info

Post by Light »

I was just playing around seeing how easy it would be to make a server info script, and seem to have come across an odd (at least to me) issue. The response comes back scrambled, while when the game client makes the request, the response is clean.

My jumbled response is the comment in the bottom.

Code: Select all

<?php

function serverInfo($server, $port)
{
	if ($sock = @stream_socket_client("udp://{$server}:{$port}", $errno, $errstr, 1))
	{
		fwrite($sock, "\x00\x0c\x00\x00\x00\x04\x00\x00\x00\x00\x00\x16\x00\x00\x00\x35\x00\x00\x00\x00\x00\x00");
		
		$h = fread($sock, 2048);
		echo $h;
		
		fclose($sock);
	}
}

serverInfo("lightron.org", "4535");

/*
ilhgrtnoo.gr�x0881166iLx0ffffffhg0t8x1861'6x0ffffff sx00e06000Tex8000i00gexa000h0 tx00e0c00oDx00e0e000gexc000f0x00e0a000iex8000g00hex6000t00 9x9999E9sa tSUA
                                                                  '.0.2-9ts+ytca_plahr_87 8nuxid decitade
                x0881166iLx0ffffffhg0t8x1861'6x0ffffff sx00e06000Tex8000i00gexa000h0 tx00e0c00oDx00e0e000gexc000f0x00e0a000iex8000g00hex6000t0x09259ffthpt/:l/githor.nrog����	0����q�*
*/

?>
Does anyone have any ideas or knowledge as to what I've done wrong?
User avatar
Jip
Round Winner
Posts: 397
Joined: Sat Sep 26, 2009 5:32 pm

Re: PHP Server Info

Post by Jip »

Have you seen this script?
http://bazaar.launchpad.net/~armagetron ... client.php
Take a look how wrtlprnft reads the response.
User avatar
Light
Reverse Outside Corner Grinder
Posts: 1667
Joined: Thu Oct 20, 2011 2:11 pm

Re: PHP Server Info

Post by Light »

Is it how he reads it or what he's sending is different? Not really sure what his outcome of packing 0x35 like that would be. I stole the message straight from wireshark, assuming it uses a standard message and not unique to clients for some reason?

I ask that because looking at wireshark, the response was normal for the client. That is captured before the client handles the response, so it was returned to the client in the normal order, right?

This was so much easier with other games. lol
User avatar
Z-Man
God & Project Admin
Posts: 11587
Joined: Sun Jan 23, 2005 6:01 pm
Location: Cologne
Contact:

Re: PHP Server Info

Post by Z-Man »

Yep, we garble strings in the network packets. That is so the NSA cannot rely on simple word filters and has to include "obbm" and stuff. And totally not because I just wrote the reading and writing functions with the sole goal of reading back in what is written. It's really best to use wrtl's pre-made packet parser, or whatever it is the server list generators use. (I have not looked at either myself, mind.)
User avatar
/dev/null
Shutout Match Winner
Posts: 819
Joined: Sat Sep 04, 2004 6:28 pm
Location: Chicago-ish

Re: PHP Server Info

Post by /dev/null »

Z-Man wrote:Yep, we garble strings in the network packets. That is so the NSA cannot rely on simple word filters and has to include "obbm" and stuff. And totally not because I just wrote the reading and writing functions with the sole goal of reading back in what is written. It's really best to use wrtl's pre-made packet parser, or whatever it is the server list generators use. (I have not looked at either myself, mind.)
Lulz, a damn fine response.
Post Reply