Valhalla Legends Forums Archive | Battle.net Bot Development | StarCraft BNLS logon packet sequence?

AuthorMessageTime
Tontow
  I've been looking around and have yet to find a complet documentation of the StarCraft/BroodWar BNLS logon packet sequence (or for any of the games for that matter).
  I have found:
http://bnetdocs.valhallalegends.com/sequence.php lays out the packet order quite nicely but makes no mention of the BNLS packet order...

https://davnit.net/bnet/vL/phpbbs/index.php?topic=8499.0
and

http://www.valhallalegends.com/yoni/BNLSProtocolSpec.txt gives the fist small portshion of the packet sequence.
 
  But, there is no complete documentation--(that I can find)--of the correct packet order.

edit: fixed incorrect url
June 24, 2005, 1:54 AM
Kp
Send your authorization first (if you bother to authorize at all), select your NLS version (if using NLS), and then send any messages you want in any order you choose.  Just beware that many NLS operations come in two parts, and you must perform the first part before the second.  Attempting to put the second one first will, at the least, return garbage data.  It may induce a server kill.
June 24, 2005, 2:06 AM
Myndfyr
You could have searched, I specified an algorithm that works in this thread.

[edit]I suppose that doesn't include BNLS packets.  But, you should be able to figure out what information you need from BNLS from that, and go from there.  So :P
June 24, 2005, 2:10 AM
KkBlazekK
Warcraft 3{ROC/TFT}

'BNLS CONNECT
'BNLS CONNECTED
'BNLS: Send 0x0E        Optional
'BNLS: Receive 0x0E    Optional
'BNLS: Send 0x0F        Optional
'BNLS: Receive 0x0F    Optional
'BNLS: Send 0x0D
'BNLS: Receive 0x0D
'BNET CONNECT
'BNET CONNECTED
'BNET: Send 0x50
'BNET: Recieve 0x50
'BNET: Recieve 0x25
'BNET: Send 0x25        Optional
'BNLS: Send 0x09
'BNLS: Receive 0x09
'BNLS: Send 0x01
'BNLS: Receive 0x01
'BNET: Send 0x51
'BNET: Recieve 0x51
'BNLS: Send 0x02
'BNLS: Receive 0x02
'BNET: Send 0x53
'BNET: Recieve 0x53
'BNLS: Send 0x03
'BNLS: Recieve 0x03
'BNET: Send 0x54
'BNET: Recieve 0x54
'BNET: Send 0x0A
'BNET: Recieve 0x0A

'Legacy Clients (STAR, SEXP, W2BN(Well, not really but :P), D2DV, D2XP)

'BNLS: CONNECT
'BNLS: CONNECTED
'BNLS: Send 0x0E        Optional
'BNLS: Receive 0x0E    Optional
'BNLS: Send 0x0F        Optional
'BNLS: Receive 0x0F    Optional
'BNET: CONNECT
'BNET: CONNECTED
'BNET: Send 0x50
'BNET: Receive 0x50
'BNET: Recieve 0x25
'BNET: Send 0x25        Optional
'BNLS: Send 0x09
'BNLS: Receive 0x09
'BNLS: Send 0x01
'BNLS: Receive 0x01
'BNET: Send 0x51
'BNET: Receive 0x51
'BNLS: Send 0x0B
'BNLS: Receive 0x0B
'BNET: Send 0x3A
'BNET: Receive 0x3A
'BNET: Send 0x0A
'BNET: Receive 0x0A
June 24, 2005, 2:27 AM
UserLoser.
[quote author=Kp link=topic=11941.msg117144#msg117144 date=1119578810]
Send your authorization first (if you bother to authorize at all), select your NLS version (if using NLS), and then send any messages you want in any order you choose.  Just beware that many NLS operations come in two parts, and you must perform the first part before the second.  Attempting to put the second one first will, at the least, return garbage data.  It may induce a server kill.
[/quote]

To my knowledge Sky fixed that where you must send one message before the other, so I don't think the server would die :P.  When I first got garbage data back from BNLS I told him immediately and he fixed the issue.
June 24, 2005, 4:08 AM
Quarantine
It's pretty straight forward, use BNLS "as needed". When you need to send a password hash, thats when you send that packet. And so on.
June 24, 2005, 4:11 AM
Tontow
  "common sense" told be to make a post and ask people who already knew rather then taking a week or 2 trying to use common sense to figure out what went where; thus benefiting from the knowledge of others and an increased chance of getting it right the first time. ;D

and

  I think its more of a use "as required" because there are packets that you must send and receive packets before other packets can be sent and/or received; at least, that is what I concluded while i was trudging my way though the BNLSProtocolSpec.txt--
  Very useful and detailed information, but it defeats itself with the lack of cleanly presented packet order documentation like bnetdocs has.

  A web page that is formatted like bnetdocs would be very useful.
IE:
C>S (packet name) (packet id) (requires data from (packet name) (packet id)
  Like Shout laid out in the last part of his post, but with each packet name/id being a link to documentation on that particular packet; it would make it easier for new people (like me) who want to start using BLNS.
June 24, 2005, 5:59 PM
LivedKrad
[quote author=Blaze link=topic=11941.msg117155#msg117155 date=1119580059]
Warcraft 3{ROC/TFT}

'BNLS CONNECT
'BNLS CONNECTED
'BNLS: Send 0x0E        Optional
'BNLS: Receive 0x0E    Optional
'BNLS: Send 0x0F        Optional
'BNLS: Receive 0x0F    Optional
'BNLS: Send 0x0D
'BNLS: Receive 0x0D
'BNET CONNECT
'BNET CONNECTED
'BNET: Send 0x50
'BNET: Recieve 0x50
'BNET: Recieve 0x25
'BNET: Send 0x25        Optional
'BNLS: Send 0x09
'BNLS: Receive 0x09
'BNLS: Send 0x01
'BNLS: Receive 0x01
'BNET: Send 0x51
'BNET: Recieve 0x51
'BNLS: Send 0x02
'BNLS: Receive 0x02
'BNET: Send 0x53
'BNET: Recieve 0x53
'BNLS: Send 0x03
'BNLS: Recieve 0x03
'BNET: Send 0x54
'BNET: Recieve 0x54
'BNET: Send 0x0A
'BNET: Recieve 0x0A

'Legacy Clients (STAR, SEXP, W2BN(Well, not really but :P), D2DV, D2XP)

'BNLS: CONNECT
'BNLS: CONNECTED
'BNLS: Send 0x0E        Optional
'BNLS: Receive 0x0E    Optional
'BNLS: Send 0x0F        Optional
'BNLS: Receive 0x0F    Optional
'BNET: CONNECT
'BNET: CONNECTED
'BNET: Send 0x50
'BNET: Receive 0x50
'BNET: Recieve 0x25
'BNET: Send 0x25        Optional
'BNLS: Send 0x09
'BNLS: Receive 0x09
'BNLS: Send 0x01
'BNLS: Receive 0x01
'BNET: Send 0x51
'BNET: Receive 0x51
'BNLS: Send 0x0B
'BNLS: Receive 0x0B
'BNET: Send 0x3A
'BNET: Receive 0x3A
'BNET: Send 0x0A
'BNET: Receive 0x0A
[/quote]

I've never successfully received 0x0A without first sending 0x0C.
June 24, 2005, 6:06 PM
KkBlazekK
LivedKrad: Don't you have to be in the chat before you can join a channel?
June 24, 2005, 8:13 PM
Kp
[quote author=UserLoser link=topic=11941.msg117179#msg117179 date=1119586093][quote author=Kp link=topic=11941.msg117144#msg117144 date=1119578810]Send your authorization first (if you bother to authorize at all), select your NLS version (if using NLS), and then send any messages you want in any order you choose.  Just beware that many NLS operations come in two parts, and you must perform the first part before the second.  Attempting to put the second one first will, at the least, return garbage data.  It may induce a server kill.[/quote]To my knowledge Sky fixed that where you must send one message before the other, so I don't think the server would die :P.  When I first got garbage data back from BNLS I told him immediately and he fixed the issue.[/quote]

"Server kill" refers to the server killing you (i.e. immediate and forcible termination of connection), not to the server dying. :)
June 24, 2005, 10:39 PM
QwertyMonster
Thanks blaze for that information.
June 24, 2005, 10:42 PM
Quarantine
Not really Tontow, as you're writing your battle.net connection send/recv BNLS packets as needed.
I don't see what's so hard about that as opposed to someone spoon feeding it to you.
June 24, 2005, 10:56 PM
Tontow
What are the advantages of sending 0x3A instead of 0x29 ? - bnetdocs has 0x29 listed in the logon sequences.
June 25, 2005, 12:05 AM
shout
3A has additional error codes.

Apologies for my last post. It was out of line.
June 25, 2005, 3:38 AM
Tontow
ok, let me see if I'm understanding what is used where.  I also have a few questions.


BNLS - connect
BNLS - connected

I need to skip sending 0x0e and 0x0f for anonomyse logon.

BNET -  connect
BNET -  connected

BNET - send 0x50 ,  I don't think that there is anything too special being done, just system information gathering.
BNET - recieve 0x25 , I can just ignore this.
BNET - recieve 0x50, I need to grap the second DWORD in this for later use.
BNET - send 0x25 (optional) , If I don't bother sending this will my lag be displaed to other clients as 0 bars?

  BNLS - send 0x09 ,  :-\
  BNLS - recieve 0x09 , My best guess is that this is a replacement for CheckRevision() that is used with BNET 0x51 because of a mention of lX86Ver, BUT I have no idea what the String and 2 DWORDs are.  Are the two DWORDs the EXE Version and EXE Hash with the string being the Exe Information???
  BNLS - send 0x01 , Need the second DWORD from BNET 0x50.
  BNLS - recieve 0x01 , I know that the DWORDs are for BNET 0x51, but I can't figure out where thay go. - there is no mention of a "Client session key" or a "(9 DWORDs) CD-key data" on bnetdocs documentation of 0x51

BNET - send 0x51 , Use data gathered from BNLS 0x09 and 0x01
BNET - recieve 0x51 , Tells me weather or not I passed SID_AUTH_CHECK.

  BNLS - send 0x0b , Send password for hashing.
  BNLS - recieve 0x0b , Grab hashed password.

  BNET - send 0x3a , Need password that has be hashed by BNLS.
  BNET - recieve 0x3a , Tells me weather or not my logon was correct.
  BNET - send 0x14 , Do I really need to send this?
  BNET - send 0x0a , and this and the rest has nothing to do with BNLS?


June 25, 2005, 4:53 AM
HdxBmx27
[quote author=Tontow link=topic=11941.msg117350#msg117350 date=1119675239]
BNET - recieve 0x50, I need to grap the second DWORD in this for later use.
  BNLS - send 0x09 ,  :-\
  BNLS - recieve 0x09 , My best guess is that this is a replacement for CheckRevision() that is used with BNET 0x51 because of a mention of lX86Ver, BUT I have no idea what the String and 2 DWORDs are.  Are the two DWORDs the EXE Version and EXE Hash with the string being the Exe Information???
  BNLS - send 0x01 , Need the second DWORD from BNET 0x50.
  BNLS - recieve 0x01 , I know that the DWORDs are for BNET 0x51, but I can't figure out where thay go. - there is no mention of a "Client session key" or a "(9 DWORDs) CD-key data" on bnetdocs documentation of 0x51
[/quote]
[quote](DWORD) Logon Type
(DWORD) Server Token
(DWORD) UDPValue**
(FILETIME) MPQ filetime
(STRING) IX86ver filename
(STRING) ValueString[/quote]
The bolded parts are the important parts.

[quote](DWORD) Product ID.
(DWORD) Version DLL digit
(STRING) Checksum formula.

Valid ProductIDs are:
0x01: Starcraft
0x02: Starcraft: Broodwar
0x03: Warcraft II: BNE
0x04: Diablo II
0x05: Diablo II: LoD
0x06: Starcraft: Japanese
0x07: Warcraft III
0x08: Warcraft III: The Frozen Throne[/quote]
The quote explains the Prod ID, and the 2nd DWORD is the number found in the "IX86ver filename". EXA: IX86ver1.mpq, So the 2nd DWORD would be 0x01. And the string is the "ValueString" from 0x50.

[quote](DWORD) Client Token
(DWORD) EXE Version
(DWORD) EXE Hash
(DWORD) Number of keys in this packet
(BOOLEAN) Using Spawn (32-bit)

For Each Key:
(DWORD) Key Length
(DWORD) CD key's product value
(DWORD) CD key's public value
(DWORD) Unknown (0)
(DWORD[5]) Hashed Key Data


(STRING) Exe Information
(STRING) CD Key owner name [/quote]
Client token in BNLS:0x01 corrosponds to client token in BNET:0x51, And note the bolded area. 5 DWORDS +4 others = 9DWORDS, Thats where the "(DWORD[9]) CD key data" comes in.

[quote author=Tontow link=topic=11941.msg117350#msg117350 date=1119675239]
BNET - send 0x51 , Use data gathered from BNLS 0x09 and 0x01 'Correct.
BNET - recieve 0x51 , Tells me weather or not I passed SID_AUTH_CHECK. 'Correct

  BNLS - send 0x0b , Send password for hashing. 'Yup
  BNLS - recieve 0x0b , Grab hashed password. 'yup

  BNET - send 0x3a , Need password that has be hashed by BNLS. 'yup
  BNET - recieve 0x3a , Tells me weather or not my logon was correct. 'yup
  BNET - send 0x14 , Do I really need to send this? 'No you don't this is what tells BNET to give you the Lag plug or not.
  BNET - send 0x0a , and this and the rest has nothing to do with BNLS? 'You sir, are againn correct.
[/quote]
~-~(HDX)~-~
June 25, 2005, 6:39 AM
Tontow
BLNS documentation says "Session key", BnetDocs says "Token". - I'm gessing that these are the same thing?  It would have been alot less confuseing if thay where to have used the same termenolgy....
June 25, 2005, 5:26 PM
Kp
[quote author=Tontow link=topic=11941.msg117444#msg117444 date=1119720399]BLNS documentation says "Session key", BnetDocs says "Token". - I'm gessing that these are the same thing?  It would have been alot less confuseing if thay where to have used the same termenolgy....[/quote]

Your posts would be a lot more readable if you spelled correctly, but we don't always get what we want.  BnetDocs and the BNLS documentation were written by different sets of authors.  To the best of my knowledge, the documents do not conflict on any data points, so it should be fairly simple to match up naming discrepancies.
June 25, 2005, 5:32 PM
KkBlazekK
Tokens/SessionKeys are for identifying individual requests.
June 25, 2005, 6:30 PM
Tontow
Ok, I think I've got it now; please correct me if I have anything wrong. (btw, this would be a good thred to put in the Battle.net Bot Development References forum after all is said and done)


BNET: (send) Protocol byte (01);
value for games: 0x01

BNET: (send) SID_AUTH_INFO 0x50, Gathering of client system information;
(DWORD)  Protocol ID - (0)
(DWORD)  Platform ID - IX86
(DWORD)  Product ID - STAR or SEXP
(DWORD)  Version Byte - 0xCB for STAR or 0xCB for SEXP
(DWORD)  Product language - 0
(DWORD)  Local IP for NAT compatibility - Client IP , What is NAT?
(DWORD)  Time zone bias* - determined by Client
(DWORD)  Locale ID - 0
(DWORD)  Language ID - can be retrieved using the GetUserDefaultLangID API.
(STRING)  Country abreviation - can be retrieved using the GetLocaleInfo API
(STRING)  Country - can be retrieved using the GetLocaleInfo API

BNET: (receive) SID_PING 0x25, ignored

BNET: (receive) SID_AUTH_INFO 0x50, It seems I need 3 values from this packet?
(DWORD)  Logon Type
(DWORD)  Server Token - Need this session Key From battle.net for use in BNLS 0x01
(DWORD)  UDPValue**
(FILETIME)  MPQ filetime
(STRING)  IX86ver filename - Need this for the vershion DLL digit for use in BNLS 0x09
(STRING)  ValueString - Checksum formula to be used in BNLS 0x09

BNET: (send) SID_PING  0x25, ignored

= Start building data for BNET 0x51, Are BLNS 0x01 & 0x09 always used together?  If so, then why arn't thay just one packet?- I know that there shouldn't be more than 2 keys and even then, the way 0x01 is it could be made to have 2 cdkey strings with the second being null if there is only one key.

BNLS: (send) BNLS_VERSIONCHECK 0x09
(DWORD) Product ID. - 0x01 for SC or 0x02 for BW
(DWORD) Version DLL digit in the range 0-7. (For example, for IX86Ver1.mpq this is 1) -  Need the IX86ver filename from BNET: (receive) SID_AUTH_INFO 0x50 for this value.
(String) Checksum formula. - ValueString from BNET: (receive) SID_AUTH_INFO 0x50

BLNS: (receive) BNLS_VERSIONCHECK 0x09
(BOOL) Success (TRUE if successful, FALSE otherwise). If this is FALSE, there is no more data in this message.
(DWORD) Version. - BNET: (send) SID_AUTH_CHECK 0x51 's EXE Vershion
(DWORD) Checksum. - BNET: (send) SID_AUTH_CHECK 0x51 's EXE Hash
(String) Version check stat string. - BNET: (send) SID_AUTH_CHECK 0x51 's EXE Information

BNLS: (send) BNLS_CDKEY 0x01
(DWORD) Session key (Server Token) from Battle.net. This is the second DWORD in SID_AUTH_INFO (0x50).
(String) CD-key. No dashes or spaces.

BLNS: (receive) BNLS_CDKEY 0x01
(BOOL) Success (TRUE if successful, FALSE otherwise). If this is FALSE, there is no more data in this message.
(DWORD) Client session key. - SID_AUTH_CHECK 0x51 's Client Token
(9 DWORDs) CD-key data. - data needed for each key in SID_AUTH_CHECK 0x51, I'm assumeing that this is already in the correct order to be sent to BNET?

=

BNET: (send) SID_AUTH_CHECK 0x51
(DWORD) Client Token - BNLS_CDKEY 0x01 's Client session key.
(DWORD) EXE Version - BNLS_VERSIONCHECK 0x09 's Version.
(DWORD) EXE Hash - BNLS_VERSIONCHECK 0x09 's Checksum.
(DWORD) Number of keys in this packet - 1, Would "1" or "one" be the correct value?
(BOOLEAN) Using Spawn (32-bit) - True or False depending on the client.
--For Each Key:-- BNLS_CDKEY 0x01 's CD-key data.
(DWORD) Key Length
(DWORD) CD key's product value
(DWORD) CD key's public value
(DWORD) Unknown (0)
(DWORD[5]) Hashed Key Data
----
(STRING) Exe Information - BNLS_VERSIONCHECK 0x09 's Version check stat string.
(STRING) CD Key owner name

BNET: (receive) SID_AUTH_CHECK 0x51 etc...
June 26, 2005, 8:41 PM
UserLoser.
[quote]
(DWORD)       Number of keys in this packet - 1, Would "1" or "one" be the correct value?
[/quote]

Um, 0x00000001.
June 27, 2005, 5:47 AM
Tontow
What typo?


I seem to be haveing a problem with the protocol byte.  I connect then send
[code]sckbnet.SendData &H1[/code]
and then the socket goses to state 8 (Peer is closing the connection)

Should it be chr(1) instead of &H1 ?  Because I send [code]sckbnet.SendData &H3 [/code] for chat and it works.....
June 27, 2005, 9:01 PM
R.a.B.B.i.T
I've always used Chr(&H1).
June 27, 2005, 9:10 PM
UserLoser.
For chat:

[code]
Call sckBnet.SendData("c")
[/code]
- or -
[code]
Call sckBnet.SendData(Chr(3))
[/code]

For game:
[code]
Call sckBnet.SendData(Chr(1))
[/code]
June 27, 2005, 9:31 PM
Tontow
hmm, If you send Chr(&H1) and fail to follow it with 0x50, will you get an ip ban?
Because I tryed logging on with BW (the game, not the bot) and it said that bnet wasnt responding...
June 28, 2005, 4:31 AM

Search