Valhalla Legends Forums Archive | Battle.net Bot Development | 0x51 Help

AuthorMessageTime
Spilled[DW]
Hey everyone, need some help with building 0x51.
Ok when i recieve 0x50 i get the mpqname, hash, and ServerToken from it and then i call this sub

[code]
Public Sub SendPacket51()
    Dim CheckRev As Long
    Dim ClientToken As Long
    Dim ProductID As Double
    Dim Val1 As Double
    Dim Val2 As Double
    Dim cRev As Long
   
   
    Select Case strProduct
        Case "PX2D" 'D2:LOD Not supported yet.
            Exit Sub
        Case "VD2D"
            Hashing.ExeInfo = Space(256)
            Hash = String(20, vbNullChar)
            CheckRev = z(Files & "Game.exe", Files & "Bnclient.dll", Files & "D2Client.dll", Hashing.Hash, Hashing.VersionID, Hashing.Checksum, Hashing.ExeInfo, Hashing.MpqName)
                If CheckRev = 0 Then
                    AddChat vbRed, "CheckRevion Failed!"
                        CloseConnection
                    Exit Sub
                Else
                    NullTruncString (Hashing.ExeInfo)
                End If
                    ClientToken = GetTickCount
                   
                InsertDWORD ClientToken
                InsertDWORD Hashing.VersionID
                InsertDWORD Hashing.Checksum
                        If strProduct = "PX2D" Then
                            InsertDWORD &H2
                        Else
                            InsertDWORD &H1
                        End If
                InsertDWORD &H0
                Call Connection.DecodeCDKey(strKey, ProductID, Val1, Val2)
                cRev = C(Outbuf, Hashing.ServerToken, ProductID, Val1, Val2, clientoken)
                InsertDWORD (Len(strKey))
                InsertDWORD ProductID
                InsertDWORD Val1
                InsertDWORD &H0
                InsertNonNTString Hashing.Hash
                InsertNTString Hashing.ExeInfo
                InsertNTString "SomeNewb"
                    SendPacket &H51
    End Select
End Sub
[/code]

First d2 connection and first time working with 0x50 and 0x51 any help is appreciated thanks :D

Edit: ProductID is highlighting also, "ByRef Arguement Type Mismatch"
February 23, 2005, 3:58 PM
UserLoser.
Probably because you have it declared as a Long, yet the local variable in that function is a Double.
February 23, 2005, 8:31 PM
Spilled[DW]
yea after studying that i found that out thx userloser i appreciate it but im still getting disconnected now when i send it, heres my sub take a look:

[code]
Public Sub SendPacket51()
    Dim CheckRev As Long
    Dim ClientToken As Long
    Dim ProductID As Double
    Dim Val1 As Double
    Dim Val2 As Double
    Dim cRev As Long
   
    Select Case strProduct
        Case "PX2D" 'D2:LOD Not supported yet.
            Exit Sub
        Case "VD2D"
            Hashing.ExeInfo = Space(256)
            Hash = String(20, vbNullChar)
            CheckRev = z(Files & "Game.exe", Files & "Bnclient.dll", Files & "D2Client.dll", Hashing.Hash, Hashing.VersionID, Hashing.Checksum, Hashing.ExeInfo, Hashing.MpqName)
                If CheckRev = 0 Then
                    AddChat vbRed, "CheckRevion Failed!"
                        CloseConnection
                    Exit Sub
                End If
                    Connection.NullTruncString Hashing.ExeInfo
                    ClientToken = GetTickCount()
                   
                InsertDWORD ClientToken
                InsertDWORD Hashing.VersionID
                InsertDWORD Hashing.Checksum
                        If strProduct = "PX2D" Then
                            InsertDWORD &H2
                        Else
                            InsertDWORD &H1
                        End If
                InsertDWORD &H0
                Call Connection.DecodeCDKey(strKey, ProductID, Val1, Val2)
                cRev = C(Outbuf, Hashing.ServerToken, ProductID, Val1, Val2, ClientToken)
                InsertDWORD (Len(strKey))
                InsertDWORD "&H" & ProductID
                InsertDWORD CLng(Val1)
                InsertDWORD &H0
                InsertNonNTString Hashing.Hash
                InsertNTString Hashing.ExeInfo
                InsertNTString "SomeNewb"
                    SendPacket &H51
    End Select
End Sub
[/code]

Any help is appreciated, thanks for the help in advance guys!
February 23, 2005, 8:43 PM
Quarantine
Are you sending the CDKey data for both CDKeys?  (Assuming its LOD)
February 23, 2005, 8:55 PM
Spilled[DW]
[quote author=Spilled[DW] link=topic=10681.msg101230#msg101230 date=1109191402]
[code]

    Select Case strProduct
        Case "PX2D" 'D2:LOD Not supported yet.
            Exit Sub
        Case "VD2D"

[/code]
[/quote]

right now im jsut working on d2 connection, LOD will come later
February 23, 2005, 8:57 PM
Quarantine
[code]
InsertDWORD "&H" & ProductID
[/code]

You can send &H as a string?
February 23, 2005, 8:58 PM
Spilled[DW]
hrmm, im not sure could that be why im being disconnected? should it just be InsertDWORD ProductID or would it be insertDWORD clng(ProductID)?
February 23, 2005, 10:30 PM
Quarantine
your ProdID isn't a long, it's a double. Try .InsertDWORD ProdID
February 23, 2005, 10:31 PM
R.a.B.B.i.T
[quote author=Warrior link=topic=10681.msg101235#msg101235 date=1109192333]
[code]
InsertDWORD "&H" & ProductID
[/code]

You can send &H as a string?
[/quote]That should be [code]InsertDWORD Val("&H" & ProductID)[/code]but that way sucks, you should just declare ProductID as a long and not deal with converting strings to longs.
February 23, 2005, 10:33 PM
tA-Kane
Answer me this, Spilled: Are you still declaring ProductID as a double, even after we've hinted at that being incorrect at least twice? When you said to UserLoser that you had noticed that and posted updated code, it was still being declared as a double.

In either case, ProductID is not a string. You cannot use "&H" & ProductID nor Val("&H" & ProductID) and expect to get any decent results. Use Val("&H" & Hex(ProductID)).
February 23, 2005, 11:01 PM
Spilled[DW]
Yes, kane i realize that and i tried what userloser told me and thats where i am now, i changed productid to a long, now im getting another error when i call decodecdkey, productid highlights and says byref mismatch, same error because decodecdkey is expecting a double, let me try that and ill get back to u
February 23, 2005, 11:11 PM
tA-Kane
DecodeCDKey expects a double? Why? ProductIDs aren't doubles...
February 23, 2005, 11:28 PM
Spilled[DW]
I have no idea, but my decode was expecting a double, fixed that thx for your help on that.
February 23, 2005, 11:34 PM
Spilled[DW]
Ok, after making the changes, heres what i got:

[code]
Public Sub SendPacket51()
    Dim CheckRev As Long
    Dim ClientToken As Long
    Dim ProductID As Long
    Dim Val1 As Long
    Dim Val2 As Long
    Dim cRev As Long
   
    Select Case strProduct
        Case "PX2D" 'D2:LOD Not supported yet.
            Exit Sub
        Case "VD2D"
            Hashing.ExeInfo = Space(256)
            Hash = String(20, vbNullChar)
            CheckRev = z(Files & "Game.exe", Files & "Bnclient.dll", Files & "D2Client.dll", Hashing.Hash, Hashing.VersionID, Hashing.Checksum, Hashing.ExeInfo, Hashing.MpqName)
                If CheckRev = 0 Then
                    AddChat vbRed, "CheckRevion Failed!"
                        CloseConnection
                    Exit Sub
                End If
                    Connection.NullTruncString Hashing.ExeInfo
                    ClientToken = GetTickCount()
                   
                InsertDWORD ClientToken
                InsertDWORD Hashing.VersionID
                InsertDWORD Hashing.Checksum
                        'If strProduct = "PX2D" Then
                        '    InsertDWORD &H2
                        'Else
                            InsertDWORD &H1
                        'End If
                InsertDWORD &H0
                Call Connection.DecodeCDKey(strKey, ProductID, Val1, Val2)
                cRev = C(Outbuf, Hashing.ServerToken, ProductID, Val1, Val2, ClientToken)
                InsertDWORD Len(strKey)
                InsertDWORD Val("&H" & Hex(ProductID))
                InsertDWORD Val1
                InsertDWORD &H0
                InsertNonNTString Hashing.Hash
                InsertNTString Hashing.ExeInfo
                InsertNTString "SomeNewb"
                    SendPacket &H51
    End Select
End Sub
[/code]

Its still disconnecting me when i send packet 0x51 and resulting in ipb, ideas?

Edit: Sry about double post
February 23, 2005, 11:54 PM
tA-Kane
A packetlog would be nice. For now, I'm going to assume that you're sending invalid CD key data.
February 24, 2005, 2:31 AM
UserLoser.
Yes, packet log(s) would be nice since more than half the time when people post code, they do not show how the variable is set, what this function does, and stuff like that.  Seeing a packet log of your bot interacting with Battle.net would really help us figure it out and help you towards success
February 24, 2005, 2:46 AM
Spilled[DW]
Hrmm i packet logged it, came up with some weird stuff... here it is

[code]
1  Hide  Hide  59  Send 
0000  01 FF 50 3A 00 00 00 00 00 36 38 58 49 56 44 32    ..P:.....68XIVD2
0010  44 0A 00 00 00 00 00 00 00 00 00 00 00 00 00 00    D...............
0020  00 00 00 00 00 00 00 00 00 55 53 41 00 55 6E 69    .........USA.Uni
0030  74 65 64 20 53 74 61 74 65 73 00                   ted States.

2  Hide  Hide  106  Recv 
0000  FF 25 08 00 1E 90 13 E8 FF 50 62 00 00 00 00 00    .%.......Pb.....
0010  05 E2 DC A7 A0 1F 29 00 00 AC 41 43 25 0B C5 01    ......)...AC%...
0020  49 58 38 36 76 65 72 32 2E 6D 70 71 00 41 3D 32    IX86ver2.mpq.A=2
0030  31 32 37 38 30 37 30 20 42 3D 36 36 37 35 37 30    1278070 B=667570
0040  35 37 38 20 43 3D 33 30 32 30 38 34 30 35 30 20    578 C=302084050
0050  34 20 41 3D 41 5E 53 20 42 3D 42 2D 43 20 43 3D    4 A=A^S B=B-C C=
0060  43 2B 41 20 41 3D 41 2B 42 00                      C+A A=A+B.

3  Hide  Hide  153  Send 
0000  FF 25 08 00 1E 90 13 E8 FF 51 91 00 C0 46 EC 23    .%.......Q...F.#
0010  00 0A 00 01 25 4A 89 32 01 00 00 00 00 00 00 00    ....%J.2........
0020  10 00 00 00 06 00 00 00 C8 77 9B 00 00 00 00 00    .........w......
0030  41 3D 32 31 32 37 38 30 37 30 20 42 3D 36 36 37    A=21278070 B=667
0040  35 37 30 35 37 38 20 43 3D 33 30 32 30 38 34 30    570578 C=3020840
0050  35 30 20 34 20 41 3D 41 5E 53 20 42 3D 42 2D 43    50 4 A=A^S B=B-C
0060  20 43 3D 43 2B 41 20 41 3D 41 2B 42 00 47 61 6D     C=C+A A=A+B.Gam
0070  65 2E 65 78 65 20 30 32 2F 32 33 2F 30 35 20 32    e.exe 02/23/05 2
0080  30 3A 33 39 3A 33 33 20 31 31 39 38 38 35 37 00    0:39:33 1198857.
0090  53 6F 6D 65 4E 65 77 62 00                         SomeNewb.
[/code]


Edit:
[code]
FF 25 08 00 1E 90 13 E8 FF 51 91 00 C0 46 EC 23 
[/code]
its like they put together, hrmm... ideas?
February 24, 2005, 3:13 AM
HdxBmx27
Why are you echoing back the hashstring?
It isn't sapost be sent to b.net it is saposto be used in the CheckRevishion function, with the hash files, Currently the Z() function in BNetAuth.dll
~-~(HDX)~-~
February 24, 2005, 3:16 AM
Spilled[DW]
I dont get what you mean by echoing, can you be more specific, thx for the help.
February 24, 2005, 3:17 AM
HdxBmx27
You recive
2  Hide  Hide  106  Recv
.A=21278070 B=667570578 C=302084050 4 A=A^S B=B-C C=C+A A=A+B.
in S->C 0x50

Then you send it back in 0x51.
Take out the InsertNonNTString Hashing.Hash in your sub, that should fix it..
Also for them being bunched together, dont worry, the server can pick them apart using the Packet header
~-~(HDX)~-~
February 24, 2005, 3:19 AM
Spilled[DW]
ahh, there we go, thx HDX and Userloser for your help, much appreciated :)
February 24, 2005, 3:21 AM
Spilled[DW]
Ok, ran into anohter problem here and i thought i would be more appropriate to just post it here instead of starting a new topic so sry about the double post everyone, but heres my Code:

Variable Declares:
[code]
Public Hashing As HashingShit
Private Type HashingShit
    Checksum As Long
    ClientToken As Long
    ServerToken As Long
    VersionID As Long
    ExeInfo As String
    Hash As String
    HashedData As String
    MpqName As String
End Type
[/code]

heres the case where i recieve 0x50:
[code]
        Case &H50
            Hashing.ServerToken = Val("&H" & Connection.StrToHex(StrReverse(Mid(strData, 9, 4))))
            Hashing.Hash = Mid(strData, 38, Len(strData) - 2)
            Hashing.MpqName = CStr(Mid(Mid(strData, InStr(1, strData, "IX86ver"), Len(strData)), 1, 12))
                SendPacket51
[/code]

And heres where my problem is, in this sub where it sends 0x50, i was getting it back as bad game version, (HDX tried to help me on PM's but we didnt finish), i think the problem is:

[code]
cRev = C(Hashing.HashedData, Hashing.ServerToken, ProductID, Val1, Val2, ClientToken)
[/code]

Because i put a break there and Hashing.HashedData is an empty string variable.

Any ideas anybody? HDX's help got it to send now its just responding as bad game version and i think this may be the problem, thanks in advance...
February 24, 2005, 5:05 AM
tA-Kane
[quote author=Spilled[DW] link=topic=10681.msg101341#msg101341 date=1109221500]And heres where my problem is, in this sub where it sends 0x50, i was getting it back as bad game version, (HDX tried to help me on PM's but we didnt finish), i think the problem is:

[code]
cRev = C(Hashing.HashedData, Hashing.ServerToken, ProductID, Val1, Val2, ClientToken)
[/code]

Because i put a break there and Hashing.HashedData is an empty string variable.[/quote]Put a break after that code (or step over once) and see if it's still an empty string variable. When you put a break on something, it stops before executing the code, not after.
February 24, 2005, 6:16 AM
Spilled[DW]
If i put the break after that line of code, vb crashes but if before it doesnt, any ideas kane?

[code]
Public Hashing As HashingShit
Private Type HashingShit
    Checksum As Long
    ClientToken As Long
    ServerToken As Long
    VersionID As Long
    ExeInfo As String
    Hash As String
    HashedData As String
    MpqName As String
End Type

[/code]

Heres my case &H50 where it calls for sending of 0x51
[code]
        Case &H51
                Select Case Connection.GetDWORD(Mid(strData, 5, 2))
                    Case &H0
                        AddChat vbGreen, "Authorization Passed!"
                    Case &H101
                        AddChat vbRed, "Bad game version."
                            CloseConnection
                    Case &H200
                        AddChat vbRed, "Invalid cd-key!"
                            CloseConnection
                    Case &H203
                        AddChat vbRed, "Bad Product!"
                            CloseConnection
                    Case &H202
                        AddChat vbRed, "Cd-Key Banned!"
                            CloseConnection
                    Case &H201
                        AddChat vbRed, "Cd-Key in use by: ", vbWhite, Mid(strData, 9, Len(strData) - 9)
                            CloseConnection
                    Case &H210
                        AddChat vbRed, "LOD Cd-Key is invalid."
                            CloseConnection
                    Case &H211
                        AddChat vbRed, "LOD Cd-Key in use by: " & Mid(strData, 9, Len(strData) - 9) & "!"
                            CloseConnection
                    Case &H212
                        AddChat vbRed, "LOD Cd-Key is banned!"
                            CloseConnection
                End Select
[/code]

Heres the sub where i send 0x51:

[code]
Public Sub SendPacket51()
    Dim CheckRev As Long
    Dim ClientToken As Long
    Dim ProductID As Long
    Dim Val1 As Long
    Dim Val2 As Long
    Dim cRev As Long
   
    Select Case strProduct
        Case "PX2D" 'D2:LOD Not supported yet.
            Exit Sub
        Case "VD2D"
            Hashing.ExeInfo = Space(256)
            Hash = String(20, vbNullChar)
            CheckRev = z(Files & "Game.exe", Files & "Bnclient.dll", Files & "D2Client.dll", Hashing.Hash, Hashing.VersionID, Hashing.Checksum, Hashing.ExeInfo, Hashing.MpqName)
                If CheckRev = 0 Then
                    AddChat vbRed, "CheckRevion Failed!"
                        CloseConnection
                    Exit Sub
                End If
                    Connection.NullTruncString Hashing.ExeInfo
                    ClientToken = GetTickCount()
                   
                InsertDWORD ClientToken
                InsertDWORD Hashing.VersionID
                InsertDWORD Hashing.Checksum
                        'If strProduct = "PX2D" Then
                        '    InsertDWORD &H2
                        'Else
                            InsertDWORD &H1
                        'End If
                InsertDWORD &H0
                Call Connection.DecodeCDKey(strKey, ProductID, Val1, Val2)
                cRev = C(Hashing.HashedData, Hashing.ServerToken, ProductID, Val1, Val2, ClientToken)
                InsertDWORD Len(strKey)
                InsertDWORD ProductID
                InsertDWORD Val1
                InsertDWORD &H0
                InsertNonNTString Hashing.HashedData
                InsertNTString Hashing.ExeInfo
                InsertNTString "SomeNewb"
                    SendPacket &H51
    End Select
End Sub
[/code]

I think its a problem with the Hashing.HashedData, can anyone spot my error? Thanks in advance everyone.

February 24, 2005, 6:28 AM
tA-Kane
[quote author=Spilled[DW] link=topic=10681.msg101346#msg101346 date=1109226512]If i put the break after that line of code, vb crashes but if before it doesnt, any ideas kane?[/quote]Breakpoint C?

If it's a library call (eg, you're using SomeGuysBnetUtilities.dll or somesuch), then make sure you're passing your data correctly; make sure your data types and their values are correct.
February 24, 2005, 6:43 AM
Spilled[DW]
Thats what i was doing, putting breakpoints and checking my values in my variables, all seems appropriate but Hashing.hasheddata was empty. Ideas?
February 24, 2005, 7:08 AM
HdxBmx27
Feel like posting the values of some vareables?
I have a hunch that Hashing.HashedData = vbNullstring.
And THAT is what is causing your error: to fix it place: Hashing.HashedData = String(20, vbNullChar) right befor you call c()
Also you can deleat Hash = String(20, vbNullChar)
Oh and ADD [code]OPTION EXPLICIT[/code] TO THE VARRY TOP OF YOU MOD!
If its not already there >.<

~-~(HDX)~-~
[Edit]
Haha I was right You need to fix your vareable.
I've noticed that BnetAuth has NO handeling of empty parameters, causing major crashing.
[/Edit]
February 24, 2005, 7:10 AM
Spilled[DW]
yea, i just added that and the erroring stopped, now its sending 0x51 and im recieving the response of bad game version again, i checked if Hashing.HashedData had a value and it does now, i packetlogged this:

[code]
1  Hide  Hide  59  Send 
0000  01 FF 50 3A 00 00 00 00 00 36 38 58 49 56 44 32    ..P:.....68XIVD2
0010  44 0A 00 00 00 00 00 00 00 00 00 00 00 00 00 00    D...............
0020  00 00 00 00 00 00 00 00 00 55 53 41 00 55 6E 69    .........USA.Uni
0030  74 65 64 20 53 74 61 74 65 73 00                  ted States.

2  Hide  Hide  107  Recv 
0000  FF 25 08 00 F7 3C 36 5E FF 50 63 00 00 00 00 00    .%...<6^.Pc.....
0010  95 0C 27 D5 59 ED 32 00 00 AC 41 43 25 0B C5 01    ..'.Y.2...AC%...
0020  49 58 38 36 76 65 72 35 2E 6D 70 71 00 41 3D 38    IX86ver5.mpq.A=8
0030  36 39 36 30 30 34 32 38 20 42 3D 33 38 38 32 38    69600428 B=38828
0040  34 31 30 32 20 43 3D 36 30 30 30 32 30 35 35 38    4102 C=600020558
0050  20 34 20 41 3D 41 2B 53 20 42 3D 42 2D 43 20 43    4 A=A+S B=B-C C
0060  3D 43 2D 41 20 41 3D 41 5E 42 00                  =C-A A=A^B.

3  Hide  Hide  112  Send 
0000  FF 25 08 00 F7 3C 36 5E FF 51 68 00 B0 62 C8 24    .%...<6^.Qh..b.$
0010  00 0A 00 01 83 3E 98 D0 01 00 00 00 00 00 00 00    .....>..........
0020  10 00 00 00 06 00 00 00 C8 77 9B 00 00 00 00 00    .........w......
0030  54 F7 AC 90 21 27 D2 4B 90 FD DF C1 D8 7F EB A0    T...!'.K........
0040  E3 C1 3D 0E 47 61 6D 65 2E 65 78 65 20 30 32 2F    ..=.Game.exe 02/
0050  32 33 2F 30 35 20 32 30 3A 33 39 3A 33 33 20 31    23/05 20:39:33 1
0060  31 39 38 38 35 37 00 53 6F 6D 65 4E 65 77 62 00    198857.SomeNewb.

4  Hide  Hide  9  Recv 
0000  FF 51 09 00 01 01 00 00 00                        .Q.......

[/code]
February 24, 2005, 7:15 AM
HdxBmx27
Well, Just by the packt log I can tell that your not using the right hashes. last edit time should be: 10/13/03 not 02/23/05
Use these: http://hdx.no-ip.org/Files/D21.10.zip
~-~(HDX)~-~
February 24, 2005, 7:36 AM
Spilled[DW]
Yes, Authorization passed thank you once again HDX, much appreciated :)
February 24, 2005, 7:41 AM
HdxBmx27
NP, Work on the other packets, If you need any help ask, I wont be able to help tonight i'm going to bed.
~-~(HDX)~-~
February 24, 2005, 7:43 AM
tA-Kane
[quote author=HdxBmx27 link=topic=10681.msg101349#msg101349 date=1109229029]I've noticed that BnetAuth has NO handeling of empty parameters, causing major crashing.[/quote]When you pass empty VB strings to a DLL, Visual Basic passes them... well, empty... So when the DLL tried to use that empty string, it probably got a memory protection fault. Don't blame the DLL, you're the one that passed a variable pointing to insufficient buffer space!
February 24, 2005, 8:04 AM
HdxBmx27
[quote author=tA-Kane link=topic=10681.msg101355#msg101355 date=1109232246]
When you pass empty VB strings to a DLL, Visual Basic passes them... well, empty... So when the DLL tried to use that empty string, it probably got a memory protection fault. Don't blame the DLL, you're the one that passed a variable pointing to insufficient buffer space!
[/quote]
True this is. I was mearly stating this because it was relevent, he was getting an error, An error that i myself have gotten sevrail time due to my hasty coding. I wanted to pass on the info that if you pass a empty parameter to a function it tends to cause the eintire program to crash with no spacific reason.  And hopefully he won't pass any more empty strings. Anywho I was just stating that, I didn't mean to 'blame' the DLL.
~-~(HDX)~-~
February 24, 2005, 8:29 AM

Search