Valhalla Legends Forums Archive | Battle.net Bot Development | Disconnect after 0x3a?

AuthorMessageTime
Jaquio
I was wondering what would cause my bot to disconnect after sending the packet 0x3A, here is the code I am using.

[code]
Public Function Send_0x01()
Select Case UCase(DB.Product)
    Case "D2DV", "VD2D"
        DB.Product = "VD2D"
        VerByte = "09"
        Executable = "Game.EXE"
    Case Else
        AC vbRed, "Unknown Product"
        Form1.Winsock1.Close
        Exit Function
End Select
HashPath = App.Path & "\D2DV\"
Form1.Winsock1.SendData Chr(1)
AC &HFFFFC0, "Sent 0x01"
End Function

Public Function Send_0x50()
On Error Resume Next
Packet.InsertDWORD &H0
Packet.InsertNonNTString "68XI"
Packet.InsertNonNTString DB.Product
Packet.InsertDWORD "&H" & VerByte
Packet.InsertDWORD &H0
Packet.InsertDWORD &H0
Packet.InsertDWORD &H0
Packet.InsertDWORD &H0
Packet.InsertDWORD &H0
Packet.InsertNTString "USA"
Packet.InsertNTString "United States"
Packet.SendPacket &H50
AC &HFFFFC0, "Sent 0x50"
End Function

Public Function Send_0x51(Data As String)
Dim Hash As String, MPQName As String, TempData As String
Dim EXEInfo As String, version As Long, CheckSum As Long, Result As Long
Dim dblProdID As Double, dblValue1 As Double, dblValue2 As Double
Dim lngProdID As Long, lngValue1 As Long, lngValue2 As Long
Dim AccountHash As String, TempString As String, dblKey As Long
Dim Servers As String
Token = Mid(Data, 9, 4)
MPQName = Mid(Data, InStr(Data, "I"), 12)
Hash = Mid(Mid(Data, 34), InStr(Mid(Data, 34), Chr(0)) + 1, InStr(Mid(Mid(Data, 34), InStr(Data, Chr(0)) + 1), Chr(0)))
Hash = Replace(Hash, Chr(0), "")
EXEInfo = Space(256)
dblKey = GetTickCount()
If DB.Product = "VD2D" Then
    Result = z(HashPath & Executable, HashPath & "BNClient.DLL", HashPath & "D2Client.DLL", Hash, version, CheckSum, EXEInfo, MPQName)
Else
    Result = z(HashPath & Executable, HashPath & "Storm.DLL", HashPath & "Battle.SNP", Hash, version, CheckSum, EXEInfo, MPQName)
End If
NullTruncString EXEInfo
DecodeCDKey DB.CDKey1, dblProdID, dblValue1, dblValue2
lngProdID = CLng(dblProdID)
lngValue1 = CLng(dblValue1)
lngValue2 = CLng(dblValue2)
Servers = CLng(Val("&h" & StrToHex(StrReverse(Token))))
AccountHash = String(5 * 4, vbNullChar)
TempString = c(AccountHash, Servers, lngProdID, lngValue1, lngValue2, dblKey)
If Result = 0 Then
    AC vbRed, "Hashing Failed"
    Form1.Winsock1.Close
    Exit Function
End If
Packet.InsertDWORD dblKey
Packet.InsertDWORD version
Packet.InsertDWORD CheckSum
Packet.InsertDWORD &H1
Packet.InsertDWORD "&H0"
Packet.InsertDWORD Len(DB.CDKey1)
Packet.InsertDWORD CLng(dblProdID)
Packet.InsertDWORD CLng(dblValue1)
Packet.InsertDWORD &H0
Packet.InsertNonNTString AccountHash
Packet.InsertNTString EXEInfo
Packet.InsertNTString DB.Username
Packet.SendPacket &H51
AC &HFFFFC0, "Sent Username & Password. "
End Function

Public Sub Send_0x3A()
Dim PD As String
PD = String(7 * 4, vbNullChar)
Packet.InsertNonNTString PD
Packet.InsertNTString DB.Username
Packet.SendPacket &H3A
AC &HFFFFC0, "Sent 0x3A"
End Sub

Public Function Send_0x14()
Packet.InsertNonNTString "tenb"
Packet.SendPacket &H14
AC &HFFFFC0, "Sent 0x14"
End Function

Public Function Send_0x0A()
Packet.InsertNTString DB.Username
Packet.InsertBYTE 0
Packet.SendPacket &HA
AC &HFFFFC0, "Sent 0x0A"
Packet.InsertNonNTString DB.Product
Packet.SendPacket &HB
AC &HFFFFC0, "Sent 0x0B"
Packet.InsertDWORD 2
Packet.InsertNTString DB.Home
Packet.SendPacket &HC
AC &HFFFFC0, "Sent 0x0C"
AC &HC0FFFF, "Attempting To Flood Channel [", False, False, vbWhite, DB.Home, False, False, &HC0FFFF, "]"
End Function

Public Function ParsePacket(Data As String)
Dim PacketID As String
PacketID = Asc(Mid(Data, 2, 1))
Select Case PacketID
    Case &H25
        Form1.Winsock1.SendData Data
    Case &H1
        AC &HC0FFC0, "Received 0x01"
    Case &H50
        AC &HC0FFC0, "Received 0x50"
        Send_0x51 Data
    Case &H51
        AC &HC0FFC0, "Received 0x51"
        Send_0x3A
    Case &H3A
        AC &HC0FFC0, "Received 0x3A"
        'Send_0x14
        Send_0x0A
    'Case &H14
        'AC &HC0FFC0, "Received 0x14"
        'Send_0x0A
    Case &HA
        AC &HC0FFC0, "Received 0x0A"
    Case &HF
        DispatchMessage Data
End Select
End Function
[/code]

After it sends 0x3A I get disconnected and ipbanned, it sucks lol. I did the result thing and it gave me "1" meaning the account don't exist but it does because I just logged onto it. Any idea, why?
July 19, 2005, 6:08 AM
R.a.B.B.i.T
Yes.  Aside from that, you should use BnetDocs a bit more.  It seems you don't know how to debug either.  Google is a great resource.
July 19, 2005, 6:10 AM
Jaquio
And I should be looking for what? Could be a little more help rabbit,  :(.
July 19, 2005, 6:15 AM
PaiD
Hm your making a floodbot also. Good luck getting help
[code]
AC &HC0FFFF, "Attempting To Flood Channel [", False, False, vbWhite, DB.Home, False, False, &HC0FFFF, "]"
[/code]
July 19, 2005, 6:15 AM
Myndfyr
[quote author=Jaquio link=topic=12268.msg121204#msg121204 date=1121753707]
And I should be looking for what? Could be a little more help rabbit,  :(.
[/quote]

I don't know... maybe an invalid packet sequence or structure?  That's a possible cause of a disconnect (protocol violation).

On that note, it looks like you are entirely off on the structure of 0x3a.  Just throwin' that out there.
July 19, 2005, 6:30 AM
Jaquio
[quote author=DueL link=topic=12268.msg121205#msg121205 date=1121753734]
Hm your making a floodbot also. Good luck getting help
[code]
AC &HC0FFFF, "Attempting To Flood Channel [", False, False, vbWhite, DB.Home, False, False, &HC0FFFF, "]"
[/code]
[/quote]


Kinda.. I am thinking about having it as an option to my bot. It will  be a chat/ops/flood bot.


[quote author=MyndFyre link=topic=12268.msg121207#msg121207 date=1121754600]
[quote author=Jaquio link=topic=12268.msg121204#msg121204 date=1121753707]
And I should be looking for what? Could be a little more help rabbit,  :(.
[/quote]

I don't know... maybe an invalid packet sequence or structure? That's a possible cause of a disconnect (protocol violation).

On that note, it looks like you are entirely off on the structure of 0x3a. Just throwin' that out there.
[/quote]


Umm, ok thanks. I will look around and try to figure out how to fix it I guess... Oh yea, one question I am kinda new to all this wtf is a server token and client token? >.<
July 19, 2005, 6:49 AM
Jaquio
Doulbe-posting not allowed I know but the modify button isn't working now, I have my client token thanks to bnet docs. But I don't know how to get my server token, can someone help me on this? Then how do I get my password hash for 0x3A also?
July 19, 2005, 7:17 AM
Myndfyr
[quote author=Jaquio link=topic=12268.msg121210#msg121210 date=1121757436]
Doulbe-posting not allowed I know but the modify button isn't working now, I have my client token thanks to bnet docs. But I don't know how to get my server token, can someone help me on this? Then how do I get my password hash for 0x3A also?
[/quote]

So, pretty much what you're saying is that, you have this code from someone else's work, and you want us to make it work for you?
July 19, 2005, 7:27 AM
Jaquio
[quote author=MyndFyre link=topic=12268.msg121211#msg121211 date=1121758044]
[quote author=Jaquio link=topic=12268.msg121210#msg121210 date=1121757436]
Doulbe-posting not allowed I know but the modify button isn't working now, I have my client token thanks to bnet docs. But I don't know how to get my server token, can someone help me on this? Then how do I get my password hash for 0x3A also?
[/quote]

So, pretty much what you're saying is that, you have this code from someone else's work, and you want us to make it work for you?
[/quote]


No I only took send_0x3A and send_0x51 I am trying to get help to make it work. If you don't want to help me that is fine. I am just trying to learn all I can and find out what everything does and how to do it so I can someday make my own bot really. I am just trying to get the hang of it one day I will rewrite it all and them 2 functions won't be someone elses.
July 19, 2005, 7:35 AM
HdxBmx27
What I suggest. Is you get rid of any sources you currently have. And start everything with a clean slate. Then get testBNCS, and use that server to go packet by packet building your bot. Also Read ALL of BnetDocs.
If you would notice, the Client and Server tokens are blue, place your mouse over them to get s short description.

poke S->C0x50 is where you get the Server token.

DO NOT use anycode that you did not write yourself and then 'rewrite it', I've done this, and it's jsut caused nothing but confussion.
Anyways:
Server Token: A 32-bit value determined by the server, used to inproved the security of the hashing functions. Can be retriend from 0x50, or 0x1D.
Client Token: A 32-Bit value determined by the client, used to inproved security of the hashing functions. Can be anything but 0 (I'm pretty sure). Many programmers use the Windows GetCurrentTime() API to get a valid value.
~-~(HDX)~-~
July 19, 2005, 11:31 AM
Jaquio
Alright, I guess I can start fully from scratch considering I know I won't get very far with a bot anyways. This TestBNCS how exactly do I get it working? I followed the instructions but when it came to the part to use "bncsctl getfiles" it didn't because it said that command wasn't valid. Am I doing something wrong or what?
July 19, 2005, 6:57 PM
Archangel
Theres a TestBNCS Forums, go check them :D.
July 19, 2005, 7:18 PM
Quarantine
The ServerToken is the second DWORD in SID_AUTH_INFO.

You also can't expect to get far withought _parsing_ the packets.
It seems you just recieve them and call the next packet in order.
July 19, 2005, 7:24 PM
Jaquio
Thanks, but after  I get TestBNCS up and going. What do I do, packetlog a bot connecting to that server so I know what to do. Or write me back and get as far as I on connecting to my TestBNCS server? I am confused >.<, I had help from my friend John getting my bot now as far as it is.
July 19, 2005, 7:26 PM
Quarantine
BnetDocs has all the packet structures availible for you. You're going to need to write (or borrow an existing) class to store the contents of the packets in a buffer and send them in a specific order.

I usually only packetlog when I am stumped on something since BnetDocs is a great resource.

Np.
July 19, 2005, 7:43 PM
Jaquio
I have a packet buffer, Then I am gonna have to rewrite the Send Packet codes and then maybe I will be able to do it. I am still kinda stumped on how to obtain the server and client token.. lol.
July 19, 2005, 7:47 PM
KkBlazekK
Maybe you should learn more about packets before you make a bot then..
July 19, 2005, 7:48 PM
Jaquio
Meh! If I could just get past the connection code I could do just fine with the rest of it. I have no idea where to learn about BNet Packets or nothing, it sucks I have looked on google and only place I found was BNetDocs which has helped me alot already. Just I am missing 3 things to connect.. Password Hash,Client Token and Server Token. But I guess I can sit here for awhile at my computer until I get it.
July 19, 2005, 7:51 PM
KkBlazekK
Study this:

https://davnit.net/bnet/vL/phpbbs/index.php?topic=9278.0
July 19, 2005, 7:55 PM
Jaquio
Alright, thanks I found that very helpful I am gonna look at it some more and read alot of stuff on it. I guess I will be back here if I get stuck on something else, or the same damn thing. Thanks everyone for the help.
July 19, 2005, 8:00 PM
Myndfyr
[quote author=Jaquio link=topic=12268.msg121238#msg121238 date=1121802713]
If I could just get past the connection code I could do just fine with the rest of it.
[/quote]
Generally, you'll find people here who are willing to help if you want to learn how that works.  However, you won't find people who are particularly willing to just give it to you.  I believe that attitude is because, once you get it, it's *really* easy.

Look at it as an opportunity to learn something new.
July 19, 2005, 10:51 PM
Jaquio
[quote author=MyndFyre link=topic=12268.msg121261#msg121261 date=1121813468]
[quote author=Jaquio link=topic=12268.msg121238#msg121238 date=1121802713]
If I could just get past the connection code I could do just fine with the rest of it.
[/quote]
Generally, you'll find people here who are willing to help if you want to learn how that works.  However, you won't find people who are particularly willing to just give it to you.  I believe that attitude is because, once you get it, it's *really* easy.

Look at it as an opportunity to learn something new.
[/quote]

Well yea I want to learn how it works, and I guess everyone is right you won't learn much about it if you take it from someone elses source or something. Maybe someone would be willing to give me a lot of hints to help me with this. Because right now I have no clue on some of these, right now this is what my bot looks like...

[code]
Public Username As String, Password As String, Server As String
Public Product As String, CDKey As String, CDKeyEXP As String
Public Trigger As String, HomeChannel As String, BotMaster As String
Private VerByte As String, Executable As String, HashPath As String
Private CToken As String, SToken As String

Public Function Send_0x01()
'0x01 Stuff Here
End Function

Public Function Send_0x14()
'0x14 Stuff Here
End Function

Public Function Send_0x50()
'0x50 Stuff Here
End Function

Public Function Send_0x51()
'0x51 Stuff Here
End Function

Public Function Send_0x0A()
'0x0A Stuff Here
End Function

Public Function Send_0x3A()
'0x3A Stuff Here
End Function

Public Function ParsePacket(Data As String)
Dim PacketID As String
PacketID = Asc(Mid(Data, 2, 1))
Select Case PacketID
'Gotta work on this once everything else is done
End Select
End Function
[/code]

I am still working on it I am just now going to bnet docs to get the packet information. However I feel I will be stuck on the Client Token and Server Token again.. As well as the Password Hash if anyone wants to give me hints on this..
July 19, 2005, 11:37 PM
KkBlazekK
There are other datatypes other then string you know. ;)

Also everyone one of those "Functions" should be Subs.
July 19, 2005, 11:54 PM
Jaquio
[quote author=Blaze link=topic=12268.msg121270#msg121270 date=1121817282]
There are other datatypes other then string you know. ;)
[/quote]

Yea I know.. I am just not to sure what each of them strings are gonna end up to be until I debug it and choose the right datatype..

[quote author=Blaze link=topic=12268.msg121270#msg121270 date=1121817282]
Also everyone one of those "Functions" should be Subs.
[/quote]

Even in a class file? I wasn't sure so I left them as functions..
July 20, 2005, 12:07 AM
Quarantine
My rule for Functions/Subs, if it isn't returning a value then make it a Sub.
July 20, 2005, 12:21 AM
Myndfyr
[quote author=Warrior link=topic=12268.msg121274#msg121274 date=1121818908]
My rule for Functions/Subs, if it isn't returning a value then make it a Sub.
[/quote]

Isn't that the point of the difference between functions and subroutines?
July 20, 2005, 12:56 AM
R.a.B.B.i.T
[quote author=MyndFyre link=topic=12268.msg121283#msg121283 date=1121820975]
[quote author=Warrior link=topic=12268.msg121274#msg121274 date=1121818908]
My rule for Functions/Subs, if it isn't returning a value then make it a Sub.
[/quote]

Isn't that the point of the difference between functions and subroutines?
[/quote]Yep.
July 20, 2005, 1:47 AM

Search