• Welcome to Valhalla Legends Archive.
 

Login &H1E Packet &H36 Help

Started by Elneroth, June 29, 2005, 05:21 PM

Previous topic - Next topic

Elneroth

Sorry for this being now the 3rd post I've made for help on different things.

During connection, I'm resulting in Invalid CdKey (W2BN - Cdkey works with Warcraft 2 acuall game)
I use the same hashing method on my &H50 connection and it works fine. And it has everything the BNETDocs specify.

http://bnetdocs.valhallalegends.com/content.php?Section=m&Code=88
(DWORD)       Spawn (0/1)
(DWORD)       Key Length
(DWORD)       CDKey Product
(DWORD)       CDKey Value1
(DWORD)       Server Token
(DWORD)       Client Token
(DWORD[5])    Hashed Data
(STRING)     Key owner

Packet &H36::
Public Sub SendP36()
    VarClientToken = GetTickCount()  ''VarClientToken = Long (Declared in module)
   
PB.InsertDWORD &H0                                                             '(DWORD)      Spawn (0/1)
PB.InsertDWORD Len(VarCdKey)                                            '(DWORD)      Key Length

    Call kd_init
    Dim vDecode As Long, vHashL As Long, vKeyH As String
    vDecode = kd_create(UCase(VarCdKey), Len(VarCdKey))
    vHashL = kd_calculateHash(vDecode, VarClientToken, VarServerToken)
    vKeyH = String$(vHashL, vbNullChar)
    Call kd_getHash(vDecode, vKeyH)
   
PB.InsertDWORD kd_product(vDecode)                                  '(DWORD)      CDKey Product
PB.InsertDWORD kd_val1(vDecode)                                        '(DWORD)      CDKey Value1
PB.InsertDWORD VarServerToken                                           '(DWORD)      Server Token
PB.InsertDWORD VarClientToken                                            '(DWORD)      Client Token
PB.InsertNonNTString vKeyH                                                   '(DWORD[5])   Hashed Data
    Call kd_free(vDecode)
   
    PB.InsertNTString VarCdKeyOwner                                      '(STRING)     Key owner
    PB.SendPacket &H36
End Sub



Here's when I retrieve my Server Token::.
Case &H1D
    VarServerToken = PB.GetDWORD(Mid(Data, 9))

Ringo

#1
0x36 cdkey hashing is hashed differntly to 0x51
If your adding all clients you wont need to use 0x36 at all, as war2 can logon with the 0x50 and 0x51 (same as sc, d2, w3)
All the older clients dont need a cdkey apart from SC Japan, witch sends the SC cdkey to the battle net chat server as raw text (in 0x30)
If you wanted to logon war2 useing 0x1E, 0x06, 0x07, 0x36 then i think you need to use the calchashbuf function, but im not sure how you would use it.

Hope that helps

Elneroth

Thanks, didn't know it was different hasing.
I was also just informed that W2BN can also use &H50. I was under the impression that it could only use &H1E, but I guess just the game itself uses that but it's capable of &H50.

Thanks,
Elneroth

Hdx

#3
Quote(DWORD)       Spawn (0/1)
(DWORD)       Key Length
(DWORD)       CDKey Product
(DWORD)       CDKey Value1
(DWORD)       Server Token
(DWORD)       Client Token
(DWORD[5])    Hashed Data
(STRING)     Key owner

Remarks:    This is only used by Warcraft II: BNE.

The data that should be hashed is:

Client Token
Server Token
Key Product (from decoded CD key)
Key Value1 (from decoded CD key)
Key Value2 (from decoded CD key)



            tmpBuff = MakeDWORD(GTC) 'client token
            tmpBuff = tmpBuff & MakeDWORD(Servers) 'server token
            tmpBuff = tmpBuff & MakeDWORD(kd_product(D)) 'product
            tmpBuff = tmpBuff & MakeDWORD(kd_val1(D)) 'value 1
            tmpBuff = tmpBuff & MakeDWORD(kd_val2(D)) 'value 2
            Dim Hash As String * 20
            Call calcHashBuf(tmpBuff, Len(tmpBuff), Hash) 'hash it.

            'from here on in it's just adding all the needed stuff for 0x36
            tmpBuff = MakeDWORD(Len(CDKey))
            tmpBuff = tmpBuff & MakeDWORD(kd_product(D))
            tmpBuff = tmpBuff & MakeDWORD(kd_val1(D))
            tmpBuff = tmpBuff & MakeDWORD(Servers)
            tmpBuff = tmpBuff & MakeDWORD(GTC)
            tmpBuff = tmpBuff & Hash

~-~(HDX)~-~

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

Elneroth

Where is your variable D coming from?

Hdx

Public Function GetCDKeyHash(Index As Integer, CDKey As String, GTC As Long, Servers As Long, EXP As Boolean, Optional W2 As Boolean = False) As String
        Dim D As Long, KeyHash As String, HashSize As Long, P1 As Boolean
        D = kd_create(CDKey, Len(CDKey))
        If (kd_isValid(D) = 0) Then GoTo err
        P1 = True
       
        If Not W2 Then
            HashSize = kd_calculateHash(D, GTC, Servers)
            If (HashSize <= 0) Then GoTo err
   
            KeyHash = String$(HashSize, vbNullChar)
            kd_getHash D, KeyHash
           
            Dim tmpBuff As String
            tmpBuff = MakeDWORD(Len(CDKey))
            tmpBuff = tmpBuff & MakeDWORD(kd_product(D))
            tmpBuff = tmpBuff & MakeDWORD(kd_val1(D))
            tmpBuff = tmpBuff & MakeDWORD(&H0)
            tmpBuff = tmpBuff & KeyHash
        Else
            tmpBuff = MakeDWORD(GTC)
            tmpBuff = tmpBuff & MakeDWORD(Servers)
            tmpBuff = tmpBuff & MakeDWORD(kd_product(D))
            tmpBuff = tmpBuff & MakeDWORD(kd_val1(D))
            tmpBuff = tmpBuff & MakeDWORD(kd_val2(D))
            Dim Hash As String * 20
            Call calcHashBuf(tmpBuff, Len(tmpBuff), Hash)
            tmpBuff = MakeDWORD(Len(CDKey))
            tmpBuff = tmpBuff & MakeDWORD(kd_product(D))
            tmpBuff = tmpBuff & MakeDWORD(kd_val1(D))
            tmpBuff = tmpBuff & MakeDWORD(Servers)
            tmpBuff = tmpBuff & MakeDWORD(GTC)
            tmpBuff = tmpBuff & Hash
        End If
       
            kd_free D
        GetCDKeyHash = tmpBuff
Exit Function
err:
    kd_free D
    AddChat Index, vbRed, "[BNET] Failed to hash " & IIf(EXP, "Exp", "Orig") & "." & IIf(P1, vbNullString, " Key is invalid.")
    GetCDKeyHash = vbNullString
End Function

As you can see, D comes from kd_create()
~-~(HDX)~-~

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

Elneroth

Alright, thank you very much.
That definatally helped,
but I did notice one thing in your coding.

        If Not W2 Then
            HashSize = kd_calculateHash(D, GTC, Servers)
            If (HashSize <= 0) Then GoTo err
   
            KeyHash = String$(HashSize, vbNullChar)
            kd_getHash D, KeyHash
           
            Dim tmpBuff As String
            tmpBuff = MakeDWORD(Len(CDKey))
            tmpBuff = tmpBuff & MakeDWORD(kd_product(D))
            tmpBuff = tmpBuff & MakeDWORD(kd_val1(D))
            tmpBuff = tmpBuff & MakeDWORD(&H0)
            tmpBuff = tmpBuff & KeyHash
        Else


The way that's made doesn't work with any client, but your W2BN coding, "ELSEIF", works with all clients. (STAR/SEXP/W2BN), so you didn't need to make the above coding.

Thanks for the help,
-Elneroth

Hdx

What? The 1st part is the required hashing for 0x51, and the 2nd is the method thats required for 0x36.
Also, no where in there does it have elseif.
~-~(HDX)~-~

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

Elneroth

Oh, didn't catch that.
Thought they both were &H36, one being for only W2BN and one being for all other ones, and I meant to say "ELSE" not "ELSEIF".