BF server protocol

Chris Noble cr_noble at msn.com
Mon Feb 16 18:28:58 EST 2004


Hey guys

I was shown this mailing list as a possible place to ask for information 
about how to communicate with the bf server so that admin commands could be 
sent to changemap, kick players etc.

currently i am at the stage of trying to get the server to accept the 
username and passoword.

it is working like this so far:

establish connection to server using winsock
the server then sends the 10 byte code key
i then xor the username and pass
i then send the lengh of the username as a 4 byte int
i then send the username string
i then send the length of the password as a 4 byte int
i then send the password string
the server sends a 1 byte data. (not sure what it is)
server hangs up

now from what i have managed to piece together this means it recieved the 
username and pass but they were not correct and so the server hung up

Or if the username as pass are correct i get the 1 byte ack data and the 
connection remains for more info to be sent.

now there are 2 problems i think that may be causing the username and 
password not to work.

1. the username and password strings, I am writing the program in vb and 
according to the packet snifer prog the string size is 5 bytes for the user 
and 6 for the pass, but in remote console that ships with BF its 6 and 7 
respectfully. I believe this is because of the null terminating char '0'. I 
have tried adding this to the 2 strings and it does make the lengths correct 
but the server still does not accept this. however i am adding the char to 
the strings before they are being XOR'ed. Is this right or should it be 
added after the string has been XOR'ed?

2. The XOR encription method is wrong. however i have implemented a method 
that a friend is using and it works for him. however i have had to convert 
it from C++ to VB. here it is:


Public Function XOREncryption(CodeKey As String, DataIn As String) As String

Dim i As Integer, strDateOut As String, KeyPos As Integer, XOR1 As Integer, 
XOR2 As Integer

KeyPos = 1

For i = 1 To Len(DataIn)
  If KeyPos = 10 Then KeyPos = 1
  XOR1 = Asc(Mid$(CodeKey, KeyPos, 1))
  XOR2 = Asc(Mid$(DataIn, i, 1))
  strDataOut = strDataOut + Chr(XOR2 Xor XOR1)
  KeyPos = KeyPos + 1
Next i

XOREncryption = strDataOut

End Function

the MID function is to pick an indvidual char from the string and the ASC 
function converts the char to a number for the XOR'ing process. and then 
finally the CHR function converts the XOR'ed number back to a char and adds 
itv to the new outputted string to be sent.

that is all i can think of being wrong.

also i have an ongoing thread about it here: 
http://bf1942.lightcubed.com/forum/viewtopic.php?t=745

any help or experience ppl have had with this would be greatly appreciated

thanks

col mugworth

_________________________________________________________________
Express yourself with cool emoticons - download MSN Messenger today! 
http://www.msn.co.uk/messenger




More information about the Bf1942 mailing list