https://bf2tech.uturista.pt/index.php?title=RCon_Protocol&feed=atom&action=historyRCon Protocol - Revision history2024-03-29T10:19:01ZRevision history for this page on the wikiMediaWiki 1.40.1https://bf2tech.uturista.pt/index.php?title=RCon_Protocol&diff=65&oldid=prevPireax: Created page with "== Basics == This document describes the RCON ("Remote Console") protocol spoken by the Battlefield 2 server; RCON is run as a TCP service, operating on port 4711 by default..."2018-05-04T13:18:51Z<p>Created page with "== Basics == This document describes the RCON ("Remote Console") protocol spoken by the Battlefield 2 server; RCON is run as a TCP service, operating on port 4711 by default..."</p>
<p><b>New page</b></p><div>== Basics ==<br />
<br />
This document describes the RCON ("Remote Console") protocol spoken by the Battlefield 2 server; RCON is run as a TCP service, operating on port 4711 by default. The BF2 server implements the TCP listener and RCON protocol completely in Python, in the administrative module. A description of how the administrative module handles RCON can be found [[Admin_Module#RCon|here]]. <br />
<br />
== Banner ==<br />
<br />
Upon connecting, the client is sent a header from the server, ending with /n/n (two 0x0A characters). One of the lines is prefixed with the text (sans quotes), "### Digest seed: ". The value after the colon and space needs to be stored for the login sequence. An example banner:<br />
<br />
<pre><br />
### Battlefield 2 default RCON/admin ready.<br />
### Digest seed: dOrdNsTRDWSvPWXi<br />
</pre><br />
<br />
== Commands ==<br />
<br />
All commands sent by the client have /n (0x0A) appended to indicate the end-of-line. An optional 0x02 character can be prefixed to the command - this instructs the server to append a 0x04 character on the output generated by the command to indicate the end of the data. However, its worth noting that the server does not send a 0x0A (newline) after the 0x04 (EOT) character, so you'll have to make sure your program can handle this. This is an optional part of the protocol that can be implemented if returning all of the output is important to your environment.<br />
<br />
The sample remoteconsole.py script included with BF2 uses the 0x02 character on all commands by default. All examples below are shown without the 0x02 and 0x04 characters. <br />
<br />
=== login ===<br />
<br />
A digest of the password using the [http://en.wikipedia.org/wiki/MD5 MD5 algorithm] is calculated with the seed obtained from the banner and is represented in hexadecimal format (e.g. 106c9f3b52c173dc210e7ee612e689bb). Note that the seed isnt used in the "normal" seed manner. To get a working digest, you take the seed returned in the banner, concatenated with the password, and then send the returned digest to the server. For example lets say the returned seed is <tt>PXYHKqLrFfENvONV</tt> and the RCON password is <tt>password</tt>, the string to return the digest of would be <tt>PXYHKqLrFfENvONVpassword</tt>, which is this case whould yield a digest of bc3d874909af1404eec2765ef3613b19.<br />
<br />
A login command may look like:<br />
<br />
<pre><br />
6c 6f 67 69 6e 20 62 64 32 39 39 37 39 30 64 64 login b d299790dd<br />
33 37 37 34 36 62 32 31 66 32 32 33 65 33 34 37 37746b2 1f223e347<br />
39 66 63 33 63 31 0a 9fc3c1.<br />
</pre><br />
<br />
Possible responses on the standard BF2 RCON server are:<br />
<br />
<pre><br />
41 75 74 68 65 6e 74 69 63 61 74 69 6f 6e 20 66 Authenti cation f<br />
61 69 6c 65 64 2e 0a ailed..<br />
</pre><br />
<br />
<pre><br />
41 75 74 68 65 6e 74 69 63 61 74 69 6f 6e 20 73 Authenti cation s<br />
75 63 63 65 73 73 66 75 6c 2c 20 72 63 6f 6e 20 uccessfu l, rcon<br />
72 65 61 64 79 2e 0a ready..<br />
</pre><br />
<br />
You must have authenticated successfully before other commands are unlocked, or you will be met with:<br />
<br />
<pre><br />
65 72 72 6f 72 3a 20 6e 6f 74 20 61 75 74 68 65 error: n ot authe<br />
6e 74 69 63 61 74 65 64 3a 20 79 6f 75 20 63 61 nticated : you ca<br />
6e 20 6f 6e 6c 79 20 69 6e 76 6f 6b 65 20 27 6c n only i nvoke 'l<br />
6f 67 69 6e 27 0a ogin'.<br />
</pre><br />
<br />
=== exec ===<br />
<br />
This runs a command (such as a PB command) or gets/sets a value of a setting on the server. For example:<br />
<br />
<pre><br />
65 78 65 63 20 73 76 2e 74 69 63 6b 65 74 72 61 exec sv .ticketra<br />
74 69 6f 0a tio.<br />
</pre><br />
<br />
Response:<br />
<br />
<pre>31 30 30 0a 100. </pre><br />
<br />
Example PB command:<br />
<br />
<pre><br />
65 78 65 63 20 70 62 5f 73 76 5f 70 6c 69 73 74 exec pb _sv_plist<br />
0a <br />
</pre><br />
<br />
PunkBuster commands will not return any text due to a bug (or 'feature') in BF2/PB integration. Their output will be shown on the server console itself, or in the PB log files if required.<br />
<br />
=== users ===<br />
<br />
This shows the active users logged into the RCON system. Request:<br />
<br />
<pre>75 73 65 72 73 0a users. </pre><br />
<br />
I believe the response varies depending on which RCON method people are using (i.e. standalone client, in-game etc). Here is an example, with two remote standalone clients:<br />
<br />
<pre><br />
61 63 74 69 76 65 20 72 63 6f 6e 20 75 73 65 72 active r con user<br />
73 3a 0a 74 63 70 3a 20 31 32 2e 33 34 2e 35 36 s:.tcp: 12.34.56<br />
2e 37 38 3a 36 32 33 35 32 0a 74 63 70 3a 20 38 .78:6235 2.tcp: 8<br />
37 2e 36 35 2e 34 33 2e 32 31 3a 36 32 32 34 38 7.65.43. 21:62248<br />
0a <br />
</pre><br />
<br />
=== Notes ===<br />
<br />
If a command does not exist, you will receive this:<br />
<br />
<pre><br />
75 6e 6b 6e 6f 77 6e 20 63 6f 6d 6d 61 6e 64 3a unknown command:<br />
20 27 62 6c 61 68 27 0a 'blah'.<br />
</pre></div>Pireax