Valhalla Legends Archive

Programming => Battle.net Bot Development => Topic started by: BaDDBLooD on March 04, 2004, 11:07 PM

Title: What do i do next?
Post by: BaDDBLooD on March 04, 2004, 11:07 PM
Some of you may have seen my earlier post about that BNLS connection.

I Finally got a Connection to BNLS Server, Sent my Username/Password.  Also got a Response saying that they were accepted.

What do i do next on my way to Connecting to bnet?
Title: Re:What do i do next?
Post by: Dark-Feanor on March 05, 2004, 06:53 AM
Download CleanSlateBot.ocx from www.valhallalegends.com/cuphead (http://www.valhallalegends.com/cuphead) and read the documentation on how to use it.
This is assuming that you already know Visual Basic.
Title: Re:What do i do next?
Post by: CrAz3D on March 05, 2004, 09:16 AM
Quote from: BaDDBLooD on March 05, 2004, 07:37 AM
i don't want to use Cleanslate bot...

i have WinsockBNLS, made a Connection to BNLS server.  Sent the ID/PASS to the bnls server, and got a response back.

What's the next step in Connecting to BNET?

Make a winsock for BNET & do:

winsockBNET.connect, SERVER (which is w/e), 6112


& then, upon the winsockBNET connecting, send x50 (basically location packet).
After this parse, or seperate, the data the battle.net sends back to you in the winsockBNET_DataArrival
Title: Re:What do i do next?
Post by: MyndFyre on March 05, 2004, 11:18 AM
Quote from: DaRk-FeAnOr on March 05, 2004, 08:23 AM
Shut up assbag. Check out http://www.valhallalegends.com/yoni/stuff/BNLSProtocolSpec.asp (http://www.valhallalegends.com/yoni/stuff/BNLSProtocolSpec.asp)

Don't be an ass.  If he bothers you that much just ignore him.  Damn.
Title: Re:What do i do next?
Post by: Eric on March 05, 2004, 12:47 PM
Quote from: BaDDBLooD on March 05, 2004, 12:24 PM
Please help me... What do i Send / Recieve next in My Login Sequence?

http://bnetdocs.valhallalegends.com/sequence.php

After logging into BNLS, the only purpose it serves is replacing the functions that are called in BnetAuth.dll along with the functions required for Warcraft III logon.

As I pointed out in your other post, if you don't understand BnetDocs, you probably won't understand the majority of this.  You should either study up on socket programming and packet creation/retrieval or use CleanSlateBot.
Title: Re:What do i do next?
Post by: hismajesty on March 05, 2004, 02:10 PM
Quote from: Myndfyre on March 05, 2004, 11:18 AM
Quote from: DaRk-FeAnOr on March 05, 2004, 08:23 AM
Shut up assbag. Check out http://www.valhallalegends.com/yoni/stuff/BNLSProtocolSpec.asp (http://www.valhallalegends.com/yoni/stuff/BNLSProtocolSpec.asp)

Don't be an ass.  If he bothers you that much just ignore him.  Damn.

He can't help being an ass; however, it WAS uncalled for.
Title: Re:What do i do next?
Post by: ChR0NiC on March 05, 2004, 05:56 PM
Quote from: BaDDBLooD on March 04, 2004, 11:07 PM
Some of you may have seen my earlier post about that BNLS connection.

I Finally got a Connection to BNLS Server, Sent my Username/Password.  Also got a Response saying that they were accepted.

What do i do next on my way to Connecting to bnet?

Well....next what you gotta do is tell BNLS what product you wish to use by doing this......


   Case &HF
       with Buffer
       .InsertDWORD GetBNLSByte()
       .SendBNLSPacket frmMain.sckBNLS, &H10
       End With



Public Function GetBNLSByte() As Long
Select Case varProduct
   Case "RATS"
       GetBNLSByte = &H1
   Case "PXES"
       GetBNLSByte = &H2
   Case "NB2W"
       GetBNLSByte = &H3
   Case "VD2D"
       GetBNLSByte = &H4
   Case "PX2D"
       GetBNLSByte = &H5
   Case Else
       AddChat vbRed, "Invalid Client version! Setting version as Starcraft!"
       GetBNLSByte = &H1
End Select
End Function


Anyways, that's what I use when receiving 0xF from BNLS......

Edit: This I believe is optional, you are only doing this I BELIEVE in which to request the verbyte in the response to 0x10, but it is a good thing to use, at least in my opinion


   Case &H10
       VerByte = GetDWORD(Mid(Data, 8, 4))
       WinSockBNET.Close
       WinSockBNET.Connect varServer, 6112


This is where you obtain the verbyte from BNLS, but you can use your own built in verbyte, you can get the current verbytes at BNET Docs.....(But I like getting the verbyte from BNLS because SkyWing usually figures out when a verbyte is changed before I do.)
Title: Re:What do i do next?
Post by: MyndFyre on March 06, 2004, 01:08 AM
Here's what I suggest:

Get EternalChat or StealthBot, and then Ethereal or BNCSMon.  Monitor your BNCS+BNLS connections from there, and watch the order of packets sent to and from each BNCS and BNLS.

If you're using ethereal, the filter I use is:

port 6112 or port 9367

That way, you can see which packet it being sent when, and what data it has to have before sending.  This info is SOMEWHAT contained in the BNLS docs, but if you do it this way, you get a really good idea of what's going on.  That's how I did.
Title: Re:What do i do next?
Post by: ChR0NiC on March 06, 2004, 01:35 PM
Quote from: BaDDBLooD on March 05, 2004, 09:54 PM
that's what i needed.. Thanks

Just for people who do not know what to do next, usually when starting your connection to BNET, the first thing you do is send 0x50....

And glad I could be of help BaddBlood. :)
Title: Re:What do i do next?
Post by: UserLoser. on March 06, 2004, 02:03 PM
Quote from: ChR0NiC on March 06, 2004, 01:35 PM
Quote from: BaDDBLooD on March 05, 2004, 09:54 PM
that's what i needed.. Thanks

Just for people who do not know what to do next, usually when starting your connection to BNET, the first thing you do is send 0x50....

And glad I could be of help BaddBlood. :)

The first thing you do is tell the server what type of client you are (1: Game client, 2: FTP, 3: Chat)
Title: Re:What do i do next?
Post by: ChR0NiC on March 06, 2004, 02:59 PM
Quote from: UserLoser. on March 06, 2004, 02:03 PM
The first thing you do is tell the server what type of client you are (1: Game client, 2: FTP, 3: Chat)

I assumed he knew that o.O
Title: Re:What do i do next?
Post by: ChR0NiC on March 06, 2004, 04:10 PM
Quote from: BaDDBLooD on March 06, 2004, 03:56 PM
k, What do i send to Tell Bnet what i am using, game, chat, or ftp?

And can i get a "Layout" for 0x50.. BNETDOC's Doesn't explain it very well, in my opinion that is...

Form1.WinsockBNET.SendData Chr(1) is using Game, I have not done Chat or FTP, but I am guessing they are similar.

0x50 is quite simple, but I won't do it for you.

(DWORD)       Protocol ID (0)
(DWORD)       Platform ID
(DWORD)       Program ID
(DWORD)       Version Byte
(DWORD)       Product language
(DWORD)       Local IP for NAT compatibility*
(DWORD)       Time zone bias*
(DWORD)       Locale ID*
(DWORD)       Language ID*
(STRING)       Country abreviation
(STRING)       Country

I can TRY walk you through this.....

BNET's protocol ID = SID_NULL or in VB terms &H0
Platform ID = A DWORD specifying the client's platform (Macintosh, PC, etc).  "6X8I" is usually used for this and the Program ID is your product EG: "PXES"
Version Byte =  the verbyte which you retrieved from BNLS using a DWORD.
Product language = can be ignored by using SID_NULL (&H0)
Local IP for NAT compatibility* = can be ignored by using SID_NULL (&H0
Time zone bias* = can be ignored by using SID_NULL (&H0)
Locale ID* = can be ignored by using SID_NULL (&H0)
Language ID* = can be ignored by using SID_NULL (&H0)
Country abreviation = "USA" or the country of your choice's abbreviated
Country = "United States" or the country of your choice.
Then  of course you once you combine all the data together you send it with the Packet ID of 0x50.
Buffer.SendPacket &H50

well.....I said I wouldn't do it for you, but it looks like I pretty much did lol....
There are ways to to do Time Zone, Locale ID, Language ID and other ones, but since you are just trying to get connected there is no use on trying to figure those out until you learn more.
Title: Re:What do i do next?
Post by: ChR0NiC on March 06, 2004, 04:39 PM
Quote from: BaDDBLooD on March 06, 2004, 04:27 PM
ok.. doing good.

What does (STRING) Mean, and Which String do i use?  There is like 5 in the Packetbuffer..

if you could explain what each does, and when to use them, that'd be Great!

Well for Country Abbrev and Country, you gotta use Null Terminated Strings.
should be in your packetbuffer under InsertNTString

A Null Terminated String is a string that is terminated (ended) with a null character. EG: vbNullChar aka Chr(0)
Title: Re:What do i do next?
Post by: ChR0NiC on March 06, 2004, 04:50 PM
Wait for your responses then act of them.
Next you will receive 0x25 and then followed by 0x50.
You usually respond to 0x25 but it is not ESSENTIAL to respond to it.
You respond to 0x50 by sending 0x51, which is usually extremely hard but BNLS makes it pretty easy to do for you. I want you to figure out 0x25 (if you choose to do it) on your own.
Title: Re:What do i do next?
Post by: ChR0NiC on March 06, 2004, 04:56 PM

Public Sub ParseBNET(Data As String)
Select Case Asc(Mid(Data, 2, 1))
Case &H50
End Select


Just to make a little correction
Title: Re:What do i do next?
Post by: ChR0NiC on March 06, 2004, 05:03 PM
Quote from: BaDDBLooD on March 06, 2004, 05:01 PM
nm, i don't send 0x25

So i don't NEED to Respond to 0x25, but i need to Recieve it?

Well once you send 0x50, you will first receive 0x25 then 0x50.
It is not essential to respond to 0x25 but you always receive it whether you like it or not. It is essential to respond to 0x50 otherwise you won't connect.

Instead of making....2nd posts just edit your post please....

Perhaps we should talk on AIM or MSN because this is filling up the forum and I'm sure it would be appreciated if we kept this off the forums, because I am basically holding your hand through the BNET connection.
Title: Re:What do i do next?
Post by: Eric on March 06, 2004, 08:36 PM
Quote from: BaDDBLooD on March 06, 2004, 08:30 PM
Forum admin's, you can Remove this topic now ;p

Admin's don't delete topics that could provide someone with help later on, but since not many people know how to use or even where to find the 'Search' button, it won't help much in a month or so.
Title: Re:What do i do next?
Post by: ChR0NiC on March 06, 2004, 09:19 PM
No offense to badd blood, but it seems like he is on purposely posting alot of replies instead of editing on purpose in order to increase his number of posts. Well, not that I even give a !@$&, but it's something I noticed.  ;D
Title: Re:What do i do next?
Post by: UserLoser. on March 06, 2004, 10:53 PM
Quote from: ChR0NiC on March 06, 2004, 04:10 PM
Quote from: BaDDBLooD on March 06, 2004, 03:56 PM
k, What do i send to Tell Bnet what i am using, game, chat, or ftp?

And can i get a "Layout" for 0x50.. BNETDOC's Doesn't explain it very well, in my opinion that is...

Form1.WinsockBNET.SendData Chr(1) is using Game, I have not done Chat or FTP, but I am guessing they are similar.

0x50 is quite simple, but I won't do it for you.

(DWORD)       Protocol ID (0)
(DWORD)       Platform ID
(DWORD)       Program ID
(DWORD)       Version Byte
(DWORD)       Product language
(DWORD)       Local IP for NAT compatibility*
(DWORD)       Time zone bias*
(DWORD)       Locale ID*
(DWORD)       Language ID*
(STRING)       Country abreviation
(STRING)       Country

I can TRY walk you through this.....

BNET's protocol ID = SID_NULL or in VB terms &H0
Platform ID = A DWORD specifying the client's platform (Macintosh, PC, etc).  "6X8I" is usually used for this and the Program ID is your product EG: "PXES"
Version Byte =  the verbyte which you retrieved from BNLS using a DWORD.
Product language = can be ignored by using SID_NULL (&H0)
Local IP for NAT compatibility* = can be ignored by using SID_NULL (&H0
Time zone bias* = can be ignored by using SID_NULL (&H0)
Locale ID* = can be ignored by using SID_NULL (&H0)
Language ID* = can be ignored by using SID_NULL (&H0)
Country abreviation = "USA" or the country of your choice's abbreviated
Country = "United States" or the country of your choice.
Then  of course you once you combine all the data together you send it with the Packet ID of 0x50.
Buffer.SendPacket &H50

well.....I said I wouldn't do it for you, but it looks like I pretty much did lol....
There are ways to to do Time Zone, Locale ID, Language ID and other ones, but since you are just trying to get connected there is no use on trying to figure those out until you learn more.

You seem to be confused on what exactly SID_NULL is
Title: Re:What do i do next?
Post by: Adron on March 07, 2004, 07:29 AM
SID_NULL is obviously a different version of the C/C++ NULL value, suitable for use in battle.net applications. You have to use the right one always.
Title: Re:What do i do next?
Post by: BaDDBLooD on March 07, 2004, 09:09 AM
Yeah... now i have a new problem

Parse BNET:



Public Sub ParseBNET(data As String)

Dim PacketID As String
   PacketID = Asc(Mid(data, 2, 1))

Select Case PacketID
   
   Case &H25
       With buffer
           .InsertNonNTString Mid(data, 5, 4)
           .SendPacket &H25
       End With

   Case &H50
       Servers = Val("&h" & StrToHex(StrReverse(Mid(data, 9, 4))))
       MPQName = Mid(data, 25, 12)
       ExeHash = Mid(data, 38, Len(data) - 2)
       MPQName2 = Val(Mid(MPQName, 8, 1))
           With buffer
               .InsertDWORD GetBNLSByte()
               .InsertDWORD CLng(MPQName2)
               .InsertNTString ExeHash
               .SendBNLSPacket &H9
           End With
           
   Case &H51
       Select Case GetWORD(Mid(data, 5, 2))
       
           Case &H0
               AddChat vbGreen, "BNET: ", vbYellow, "Version and CDKeys Passed."
               
           Case &H101
               AddChat vbRed, "BNET: ", vbYellow, "Incorrect Game Version."
               
           Case &H200
               AddChat vbRed, "BNET: ", vbYellow, "Incorrect Cdkey(s)"
               
           Case &H100
               AddChat vbRed, "BNET: ", vbYellow, "Incorrect Game Version"
               
           Case &H203
               AddChat vbRed, "BNET: ", vbYellow, "Incorrect Cdkey for this product."
               
           Case &H202
               AddChat vbRed, "BNET: ", vbYellow, "Current Cdkey is banned from battle.net"
               
           Case &H201
               AddChat vbYellow, "BNET: ", vbYellow, "Current cdkey is in use by: " & Mid(data, 9, Len(data) - 9)
               
       End Select

   End Select

End Sub



PACKET: 0x50



Public Sub Packet0x50()

With buffer
   .InsertDWORD &H0
   .InsertNonNTString "68XI" & Product()
   .InsertDWORD VerByte
   .InsertDWORD &H0
   .InsertDWORD &H0
   .InsertDWORD &H0
   .InsertDWORD &H0
   .InsertDWORD &H0
   .InsertNTString "USA"
   .InsertNTString "United States"
   .SendPacket &H50
End With

AddChat vbGreen, "BNET: Sent Packet: 0x50!"
   
End Sub



PACKET: 0x51



Public Sub Packet0x51()

AddChat vbGreen, "BNET: ", vbYellow, "Sending.. Cdkey, Checksum, Version..."

With buffer
   .InsertDWORD Token
   .InsertDWORD ExeVersion
   .InsertDWORD ExeChecksum
   .InsertDWORD &H1
   .InsertDWORD &H0
   .InsertNonNTString CdkeyHash
   .InsertNTString ExeInfo
   .InsertNTString BnetBot.Username
   .SendPacket &H51
End With

AddChat vbGreen, "BNET: Sent Packet: 0x51"
   
End Sub



Parse BNLS:



Public Sub ParseBNLS(data As String)

Select Case Asc(Mid(data, 3, 1))
   
       Case &HE
           AddChat vbYellow, "BNLS: Sending Authorization"
           Dim key As Long, key2 As Long
               key2 = GetDWORD(Mid(data, 4, 4))
               key = BNLSChecksum("Secret", key2)
                   With buffer
                       .InsertDWORD key
                       .SendBNLSPacket &HF
                   End With
                       
       Case &HF
           AddChat vbGreen, "BNLS: Autorization Accepted"
           With buffer
               .InsertDWORD GetBNLSByte()
               .SendBNLSPacket &H10
           End With
       
       Case &H10
           VerByte = GetDWORD(Mid(data, 8, 4))
           Main.WinsockBNET.Close
           Main.WinsockBNET.Connect BnetBot.Server, 6112
           AddChat vbYellow, "BNET: Connecting To Server: " & BnetBot.Server & ":6112"
           
       Case &H9
           ExeVersion = Val("&H" & StrToHex(StrReverse(Mid(data, 8, 4))))
           ExeVersion = CLng(ExeVersion)
           ExeChecksum = Val("&H" & StrToHex(StrReverse(Mid(data, 12, 4))))
           ExeChecksum = CLng(Checksum)
           ExeInfo = Mid(data, 16, Len(data) - 16)
               With buffer
                   .InsertDWORD Servers
                   .InsertNTString BnetBot.Cdkey
                   .SendBNLSPacket &H1
               End With
           
       Case &H1
           CdkeyHash = Mid(data, 12)
           Token = Val("&H" & StrToHex(StrReverse(Mid(data, 8, 4))))
           Token = CLng(Token)
           Packet0x51
       
   End Select
   
End Sub



DECLARES:



Public buffer As New PacketBuffer
Public Version As String
Public VarProduct As String
Public VerByte As Long
Public MPQName As String
Public MPQName2 As Long
Public ExeInfo As String
Public ExeVersion As Long
Public ExeHash As String
Public Token As Long
Public Servers As Long
Public ExeChecksum As Long
Public CdkeyHash As String





Public Type BotData
   Username As String
   Password As String
   HomeChannel As String
   Cdkey As String
   Server As String
   BNLSServer As String
   Product As String
End Type
Public BnetBot As BotData



I Get a Invalid Game Version Response from 0x51... not sure what is wrong!



Title: Re:What do i do next?
Post by: MyndFyre on March 07, 2004, 02:48 PM
What are you sending as the game version, and for which product?
Title: Re:What do i do next?
Post by: BaDDBLooD on March 07, 2004, 02:57 PM
i am sending RATS, for starcraft..



Private Function Product() As String

Select Case BnetBot.Product

   Case "0"
       Product = "RATS"
   Case "1"
       Product = "PXES"
   Case "2"
       Product = "NB2W"
   Case "3"
       Product = "VD2D"
   Case "4"
       Product = "PX2D"
   Case "5"
       Product = "3RAW"
End Select

End Function





Public Function GetBNLSByte() As Long
Select Case BnetBot.Product
   Case "0"
       GetBNLSByte = &H1
   Case "1"
       GetBNLSByte = &H2
   Case "2"
       GetBNLSByte = &H3
   Case "3"
       GetBNLSByte = &H4
   Case "4"
       GetBNLSByte = &H5
   Case "5"
       GetBNLSByte = &H7
   Case Else
       AddChat vbRed, "Invalid Client version! Setting version as Starcraft!"
       GetBNLSByte = &H1
End Select
End Function