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
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
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"
Probably because you have it declared as a Long, yet the local variable in that function is a Double.
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:
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
Any help is appreciated, thanks for the help in advance guys!
Are you sending the CDKey data for both CDKeys? (Assuming its LOD)
Quote from: Spilled[DW] on February 23, 2005, 02:43 PM
Select Case strProduct
Case "PX2D" 'D2:LOD Not supported yet.
Exit Sub
Case "VD2D"
right now im jsut working on d2 connection, LOD will come later
InsertDWORD "&H" & ProductID
You can send &H as a string?
hrmm, im not sure could that be why im being disconnected? should it just be InsertDWORD ProductID or would it be insertDWORD clng(ProductID)?
your ProdID isn't a long, it's a double. Try .InsertDWORD ProdID
Quote from: Warrior on February 23, 2005, 02:58 PM
InsertDWORD "&H" & ProductID
You can send &H as a string?
That should be
InsertDWORD Val("&H" & ProductID)
but that way sucks, you should just declare ProductID as a long and not deal with converting strings to longs.
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)).
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
DecodeCDKey expects a double? Why? ProductIDs aren't doubles...
I have no idea, but my decode was expecting a double, fixed that thx for your help on that.
Ok, after making the changes, heres what i got:
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
Its still disconnecting me when i send packet 0x51 and resulting in ipb, ideas?
Edit: Sry about double post
A packetlog would be nice. For now, I'm going to assume that you're sending invalid CD key data.
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
Hrmm i packet logged it, came up with some weird stuff... here it is
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.
Edit:
FF 25 08 00 1E 90 13 E8 FF 51 91 00 C0 46 EC 23
its like they put together, hrmm... ideas?
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)~-~
I dont get what you mean by echoing, can you be more specific, thx for the help.
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)~-~
ahh, there we go, thx HDX and Userloser for your help, much appreciated :)
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:
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
heres the case where i recieve 0x50:
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
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:
cRev = C(Hashing.HashedData, Hashing.ServerToken, ProductID, Val1, Val2, ClientToken)
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...
Quote from: Spilled[DW] on February 23, 2005, 11:05 PMAnd 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:
cRev = C(Hashing.HashedData, Hashing.ServerToken, ProductID, Val1, Val2, ClientToken)
Because i put a break there and Hashing.HashedData is an empty string variable.
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.
If i put the break after that line of code, vb crashes but if before it doesnt, any ideas kane?
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
Heres my case &H50 where it calls for sending of 0x51
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
Heres the sub where i send 0x51:
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
I think its a problem with the Hashing.HashedData, can anyone spot my error? Thanks in advance everyone.
Quote from: Spilled[DW] on February 24, 2005, 12:28 AMIf i put the break after that line of code, vb crashes but if before it doesnt, any ideas kane?
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.
Thats what i was doing, putting breakpoints and checking my values in my variables, all seems appropriate but Hashing.hasheddata was empty. Ideas?
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 OPTION EXPLICIT
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]
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:
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.......
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 (http://hdx.no-ip.org/Files/D21.10.zip)
~-~(HDX)~-~
Yes, Authorization passed thank you once again HDX, much appreciated :)
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)~-~
Quote from: HdxBmx27 on February 24, 2005, 01:10 AMI've noticed that BnetAuth has NO handeling of empty parameters, causing major crashing.
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 from: tA-Kane on February 24, 2005, 02:04 AM
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!
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)~-~