• Welcome to Valhalla Legends Archive.
 

[VB6] Decoding and hashing the D2XP Cd-key

Started by Racial, June 27, 2008, 03:30 PM

Previous topic - Next topic

Racial

Do i decode it and hash it the same way as every other key? I'm using BNCSUtil and i'm doing this and receiving a Invalid Key error, then i get iped :(.

Private Sub Send0x51()
   
    InsertDWORD lngTick
    InsertDWORD Version
    InsertDWORD Checksum
   
    If Product = "D2XP" Then
        InsertDWORD &H2 'Send 2 cd-keys
    Else
        InsertDWORD &H1 'Send 1 cd-key
    End If
   
    HashCdkey1 Cdkey, hash, lngProductID, lngValueNum1
    dblProductID = CLng(lngProductID)
    dblValueNum1 = CLng(lngValueNum1)
   
    '1st cd-key
    InsertDWORD &H0
    InsertDWORD Len(Cdkey)
    InsertDWORD CLng(dblProductID)
    InsertDWORD CLng(dblValueNum1)
    InsertDWORD &H0
    InsertNonNTString hash
   
    'Still need to hash 2nd cd-key then send
    If Product = "D2XP" Then
            HashCdkey1 CDKeyXP, hash2, lngProductID2, lngValueNum2
            dblProductID2 = CLng(lngProductID2)
            dblValueNum2 = CLng(lngValueNum2)
           
        InsertDWORD Len(CDKeyXP)
        InsertDWORD CLng(dblProductID2)
        InsertDWORD CLng(dblValueNum2)
        InsertDWORD &H0
        InsertNonNTString hash2
    End If
   
    InsertNTString EXEInfo
    'I send the rest after
end sub



Private Function HashCdkey1(ByVal Cdkey As String, ByRef H As String, ByRef productVal As Long, ByRef publicVal As Long) As Boolean
    On Error GoTo hErr
    Dim kd As Long, HashLength As Long, hash As String
    kd = kd_create(Cdkey, Len(Cdkey))
    If (kd = -1) Then
        AddChat vbRed, "Cannot initialize cdkey decoder!"
        Form1.BNCS.Disconnect
        Exit Function
    End If
    HashLength = kd_calculateHash(kd, lngTick, ServerToken)
    If (HashLength = 0) Then
        AddChat vbRed, "Cannot calculate cdkey hash length!"
        Form1.BNCS.Disconnect
        Exit Function
    End If
    If kd_isValid(kd) = 0 Then
        AddChat vbRed, "Cdkey did not pass installer check!"
        Form1.BNCS.Disconnect
        Exit Function
    End If
    hash = Space$(HashLength)
    kd_getHash kd, hash
    H = hash
    productVal = kd_product(kd)
    publicVal = kd_val1(kd)
    kd_free kd
    Exit Function
hErr:
    AddChat vbRed, "Error: Bot, HashCdkey"
End Function


Barabajagal

That's some trippy code you got there... why the long to double to long?

First things to check: Is the CDKey coming in correctly (no dashes or spaces or anything?). What's the Product Value return for the key?

Racial

Quote from: Andy on June 27, 2008, 06:30 PM
That's some trippy code you got there... why the long to double to long?

First things to check: Is the CDKey coming in correctly (no dashes or spaces or anything?). What's the Product Value return for the key?
Thanks for commenting lol, i'm not very well at coding yet but thats how i did my hashing and sending, it works so i didn't feel like changing it.
As for the CDKey comign in correctly it does infact go into the decoding process with no spaces or dashes and same with hashing but i will be sure to paste the product value for both d2dv and d2xp keys

Racial

Ok i did it, when i debug it i get 6 for the Diablo II key and 10 for the Diablo II Lord of Destruction cd-key

Racial


Barabajagal

Uh, no... D2 is supposed to be 6, D2XP is supposed to be 10. You were right before.