• Welcome to Valhalla Legends Archive.
 

Disconnect after 0x3a?

Started by Jaquio, July 19, 2005, 01:08 AM

Previous topic - Next topic

Jaquio

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


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


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?

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.

Jaquio

And I should be looking for what? Could be a little more help rabbit,  :(.

PaiD

Hm your making a floodbot also. Good luck getting help

AC &HC0FFFF, "Attempting To Flood Channel [", False, False, vbWhite, DB.Home, False, False, &HC0FFFF, "]"

MyndFyre

Quote from: Jaquio on July 19, 2005, 01:15 AM
And I should be looking for what? Could be a little more help rabbit,  :(.

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.
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.

Jaquio

#5
Quote from: DueL on July 19, 2005, 01:15 AM
Hm your making a floodbot also. Good luck getting help

AC &HC0FFFF, "Attempting To Flood Channel [", False, False, vbWhite, DB.Home, False, False, &HC0FFFF, "]"



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


Quote from: MyndFyre on July 19, 2005, 01:30 AM
Quote from: Jaquio on July 19, 2005, 01:15 AM
And I should be looking for what? Could be a little more help rabbit,  :(.

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.


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? >.<

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?

MyndFyre

Quote from: Jaquio on July 19, 2005, 02:17 AM
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?

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?
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.

Jaquio

Quote from: MyndFyre on July 19, 2005, 02:27 AM
Quote from: Jaquio on July 19, 2005, 02:17 AM
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?

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?


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.

Hdx

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)~-~

Proud host of the JBLS server www.JBLS.org.
JBLS.org Status:
JBLS/BNLS Server Status

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?

Archangel

Theres a TestBNCS Forums, go check them :D.
I'm not an Addict.

Warrior

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.
Quote from: effect on March 09, 2006, 11:52 PM
Islam is a steaming pile of fucking dog shit. Everything about it is flawed, anybody who believes in it is a terrorist, if you disagree with me, then im sorry your wrong.

Quote from: Rule on May 07, 2006, 01:30 PM
Why don't you stop being American and start acting like a decent human?

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.

Warrior

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.
Quote from: effect on March 09, 2006, 11:52 PM
Islam is a steaming pile of fucking dog shit. Everything about it is flawed, anybody who believes in it is a terrorist, if you disagree with me, then im sorry your wrong.

Quote from: Rule on May 07, 2006, 01:30 PM
Why don't you stop being American and start acting like a decent human?