• Welcome to Valhalla Legends Archive.
 

Invalid CDKey.

Started by gentoolinux, April 23, 2005, 07:02 PM

Previous topic - Next topic

gentoolinux

Hello, I'm kind of new to this programing situation... I had a friend help me with a bot, i'm getting an invalid cdkey error and the cdkey is valid... I'm not sure why and my friend is in texas for 3 weeks so i cannot contact him, can anyone please help me?

Archangel

Maybe the cd-key decoding is wrong.

Show packet logs
I'm not an Addict.

gentoolinux

Quote from: Archangel on April 23, 2005, 07:06 PM
Maybe the cd-key decoding is wrong.

Show packet logs


1  Hide  Hide  67  Send 
0000  01 FF 50 3A 00 00 00 00 00 36 38 58 49 4E 42 32    ..P:.....68XINB2
0010  57 4F 00 00 00 00 00 00 00 00 00 00 00 00 00 00    WO..............
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 FF 25 08 00 00    ted States..%...
0040  00 00 00                                           ...

2  Hide  Hide  8  Recv 
0000  FF 25 08 00 B1 41 C2 9A                            .%...A..

3  Hide  Hide  98  Recv 
0000  FF 50 62 00 00 00 00 00 18 7C 9C 45 40 86 0F 00    .Pb......|.E@...
0010  00 AC 41 43 25 0B C5 01 49 58 38 36 76 65 72 32    ..AC%...IX86ver2
0020  2E 6D 70 71 00 41 3D 37 35 31 37 30 30 34 31 38    .mpq.A=751700418
0030  20 42 3D 39 38 31 32 39 30 37 38 35 20 43 3D 33     B=981290785 C=3
0040  34 37 37 32 37 38 34 20 34 20 41 3D 41 2D 53 20    4772784 4 A=A-S
0050  42 3D 42 2B 43 20 43 3D 43 2D 41 20 41 3D 41 5E    B=B+C C=C-A A=A^
0060  42 00                                              B.

4  Hide  Hide  112  Send 
0000  FF 51 70 00 00 00 00 00 00 02 00 02 05 B3 63 25    .Qp...........c%
0010  01 00 00 00 00 00 00 00 10 00 00 00 04 00 00 00    ................
0020  F0 B7 02 00 00 00 00 00 56 E6 E8 2B 8D 14 26 6D    ........V..+..&m
0030  9C 22 10 BB BF 97 20 17 E8 62 0A F6 57 61 72 63    .".... ..b..Warc
0040  72 61 66 74 20 49 49 20 42 4E 45 2E 65 78 65 20    raft II BNE.exe
0050  30 34 2F 32 32 2F 30 35 20 30 30 3A 30 34 3A 31    04/22/05 00:04:1
0060  37 20 37 31 32 37 30 34 00 57 65 62 42 6F 74 00    7 712704.WebBot.

5  Hide  Hide  9  Recv 
0000  FF 51 09 00 00 02 00 00 00                         .Q.......

6  Hide  Hide  12  Send 
0000  FF 14 08 00 74 65 6E 62 FF 2D 04 00                ....tenb.-..


Yegg

Rather than post packetlogs of your bot. Show us the cdkey decode function that you are using.

gentoolinux

Quote from: Yegg on April 23, 2005, 07:37 PM
Rather than post packetlogs of your bot. Show us the cdkey decode function that you are using.



Private Sub DecodeCDKey(ByVal sCDKey As String, ByRef dProductId As Double, ByRef dValue1 As Double, ByRef dValue2 As Double)
On Error Resume Next
    sCDKey = Replace(sCDKey, "-", "")
    sCDKey = Replace(sCDKey, " ", "")
    sCDKey = KillNull(sCDKey)
    If Len(sCDKey) = 13 Then
        sCDKey = DecodeStarcraftKey(sCDKey)
    ElseIf Len(sCDKey) = 16 Then
        sCDKey = DecodeD2Key(sCDKey)
    Else
        Exit Sub
    End If
    dProductId = Val("&H" & Left$(sCDKey, 2))
    If Len(sCDKey) = 13 Then
        dValue1 = Val(Mid$(sCDKey, 3, 7))
        dValue2 = Val(Mid$(sCDKey, 10, 3))
    ElseIf Len(sCDKey) = 16 Then
        dValue1 = Val("&H" & Mid$(sCDKey, 3, 6))
        dValue2 = Val("&H" & Mid$(sCDKey, 9))
    End If
End Sub

Private Function DecodeD2Key(ByVal key As String) As String
    Dim R As Double, n As Double, n2 As Double, v As Double, _
    v2 As Double, keyvalue As Double, c1 As Byte, c2 As Byte, _
    c As Byte, bValid As Boolean, i As Integer, aryKey(0 To 15) As String, _
    codevalues As String
    codevalues = "246789BCDEFGHJKMNPRTVWXZ"
    R = 1
    keyvalue = 0
    For i = 1 To 16
        aryKey(i - 1) = Mid$(key, i, 1)
    Next i
    For i = 0 To 15 Step 2
        c1 = InStr(1, codevalues, aryKey(i)) - 1
        If c1 = -1 Then c1 = &HFF
        n = c1 * 3
        c2 = InStr(1, codevalues, aryKey(i + 1)) - 1
        If c2 = -1 Then c2 = &HFF
        n = c2 + n * 8
        If n >= &H100 Then
            n = n - &H100
            keyvalue = keyvalue Or R
        End If
        n2 = n
        n2 = RShift(n2, 4)
        aryKey(i) = GetHexValue(n2)
        aryKey(i + 1) = GetHexValue(n)
        R = LShift(R, 1)
Cont:
    Next i
    v = 3
    For i = 0 To 15
        c = GetNumValue(aryKey(i))
        n = Val(c)
        n2 = v * 2
        n = n Xor n2
        v = v + n
    Next i
    v = v And &HFF
    For i = 15 To 0 Step -1
        c = Asc(aryKey(i))
        If i > 8 Then
            n = i - 9
        Else
            n = &HF - (8 - i)
        End If
        n = n And &HF
        c2 = Asc(aryKey(n))
        aryKey(i) = Chr$(c2)
        aryKey(n) = Chr$(c)
    Next i
    v2 = &H13AC9741
    For i = 15 To 0 Step -1
        c = Asc(UCase(aryKey(i)))
        aryKey(i) = Chr$(c)
        If Val(c) <= Asc("7") Then
            v = v2
            c2 = v And &HF
            c2 = c2 And 7
            c2 = c2 Xor c
            v = RShift(v, 3)
            aryKey(i) = Chr$(c2)
            v2 = v
        ElseIf Val(c) < Asc("A") Then
            c2 = CByte(i)
            c2 = c2 And 1
            c2 = c2 Xor c
            aryKey(i) = Chr$(c2)
        End If
    Next i
    DecodeD2Key = Join(aryKey, "")
    Erase aryKey()
End Function

Yegg

Ok, that code is correct. I've got another question, are you using the correct logon sequences for Warcraft2 or Diablo2? You can post code if you like so that we can maybe find an error for you or something else that you might be doing wrong.

gentoolinux

Quote from: Yegg on April 23, 2005, 08:56 PM
Ok, that code is correct. I've got another question, are you using the correct logon sequences for Warcraft2 or Diablo2? You can post code if you like so that we can maybe find an error for you or something else that you might be doing wrong.

I'm new to this, can you please explain what you need?

shout

Quote from: gentoolinux on April 23, 2005, 07:59 PM

codevalues = "246789BCDEFGHJKMNPRTVWXZ"


Doesnt there have to be spaces in there?

If the key values is '7', or 0x44 (&H44)[I think],  the value would be beyond the length of the string. I'm not sure how visual basic handles this, but I'm guessing it does not tell you.

MyndFyre

Quote from: Shout on April 23, 2005, 10:02 PM
Quote from: gentoolinux on April 23, 2005, 07:59 PM

codevalues = "246789BCDEFGHJKMNPRTVWXZ"


Doesnt there have to be spaces in there?


No spaces or non-alphanumeric characters appear in CD keys when they are presented for decoding.
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.

shout

#9
Quote from: MyndFyre on April 24, 2005, 02:44 AM
Quote from: Shout on April 23, 2005, 10:02 PM
Quote from: gentoolinux on April 23, 2005, 07:59 PM

codevalues = "246789BCDEFGHJKMNPRTVWXZ"


Doesnt there have to be spaces in there?


No spaces or non-alphanumeric characters appear in CD keys when they are presented for decoding.

I hope that is not the cdkey. Why would you have the cdkey hardcoded into a bot? That makes no sense at all.

I was talking about the strange lack of this array:

private static int[] map = new int[]
{
-1  , -1  , -1  , -1  , -1  , -1  , -1  , -1  , -1  ,
-1  , -1  , -1  , -1  , -1  , -1  , -1  , -1  , -1  ,
-1  , -1  , -1  , -1  , -1  , -1  , -1  , -1  , -1  ,
-1  , -1  , -1  , -1  , -1  , -1  , -1  , -1  , -1  ,
-1  , -1  , -1  , -1  , -1  , -1  , -1  , -1  , -1  ,
-1  , -1  , -1  , -1  , -1  , 0x00, -1  , 0x01, -1  ,
0x02, 0x03, 0x04, 0x05, -1  , -1  , -1  , -1  , -1  ,
-1  , -1  , -1  , 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B,
0x0C, -1  , 0x0D, 0x0E, -1  , 0x0F, 0x10, -1  , 0x11,
-1  , 0x12, -1  , 0x13, -1  , 0x14, 0x15, 0x16, -1  ,
0x17, -1  , -1  , -1  , -1  , -1  , -1  , -1  , 0x06,
0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, -1  , 0x0D, 0x0E,
-1  , 0x0F, 0x10, -1  , 0x11, -1  , 0x12, -1  , 0x13,
-1  , 0x14, 0x15, 0x16, -1  , 0x17, -1  , -1  , -1  ,
-1  , -1  , -1  , -1  , -1  , -1  , -1  , -1  , -1  ,
-1  , -1  , -1  , -1  , -1  , -1  , -1  , -1  , -1  ,
-1  , -1  , -1  , -1  , -1  , -1  , -1  , -1  , -1  ,
-1  , -1  , -1  , -1  , -1  , -1  , -1  , -1  , -1  ,
-1  , -1  , -1  , -1  , -1  , -1  , -1  , -1  , -1  ,
-1  , -1  , -1  , -1  , -1  , -1  , -1  , -1  , -1  ,
-1  , -1  , -1  , -1  , -1  , -1  , -1  , -1  , -1  ,
-1  , -1  , -1  , -1  , -1  , -1  , -1  , -1  , -1  ,
-1  , -1  , -1  , -1  , -1  , -1  , -1  , -1  , -1  ,
-1  , -1  , -1  , -1  , -1  , -1  , -1  , -1  , -1  ,
-1  , -1  , -1  , -1  , -1  , -1  , -1  , -1  , -1  ,
-1  , -1  , -1  , -1  , -1  , -1  , -1  , -1  , -1  ,
-1  , -1  , -1  , -1  , -1  , -1  , -1  , -1  , -1  ,
-1  , -1  , -1  , -1  , -1  , -1  , -1  , -1  , -1  ,
-1  , -1  , -1  , -1
};


In BnetAuth.cpp it is called codevalues.

The alpha-numeric cdkey needs to be changed to hex before it can be decoded. Thats what that array is for. Each of the values corroposnds with one of the characters present in alpha-numeric cdkeys,  so '2' would be 0x00, and so fourth. If you ever get -1, thats one way you can tell the key is invalid.

gentoolinux

That's not my CDKey.... So does anyone know what the problem is?

Yegg

I believe that the codevalues variable contains all of the characters that a warcraft2 or diablo2 cdkey can contain.

gentoolinux

Quote from: Yegg on April 24, 2005, 10:37 AM
I believe that the codevalues variable contains all of the characters that a warcraft2 or diablo2 cdkey can contain.

anybody have any ideas? .....

UserLoser.

Quote from: gentoolinux on April 24, 2005, 02:42 PM
Quote from: Yegg on April 24, 2005, 10:37 AM
I believe that the codevalues variable contains all of the characters that a warcraft2 or diablo2 cdkey can contain.

anybody have any ideas? .....

Show us how you're hashing the cdkey data.

Yegg

UserLoser, that might not be possible. Assuming he's new to bot developement (not the website), he may be using something like bnetauth.dll for that task.