Valhalla Legends Forums Archive | Battle.net Bot Development | CDKey Checks

AuthorMessageTime
Barabajagal
Is there a checksum value for D2/W2 and W3 keys like the last digit of SC keys? Just wondering...
April 29, 2008, 1:14 AM
iago
They are verified in some way, yes.
April 29, 2008, 2:46 PM
Barabajagal
That's not what I asked...
April 29, 2008, 2:52 PM
Ringo
[quote author=Andy link=topic=17474.msg177991#msg177991 date=1209480741]
That's not what I asked...
[/quote]
Looked like it was to me.
IIRC, the install valid algorithm check is the same for SC cdkeys, but just remmber d2 keys are not numeric like SC keys.
See the 1st few steps of a decode d2 cdkey function (which you should have looked at already, unless you use BNCSutli for everything)
April 29, 2008, 3:10 PM
Barabajagal
No, I only use BNCSUtil for NLS... And I don't see any validation checksum in it.

I asked if there was a checksum like SC, not if they're "validated in some way".
April 29, 2008, 3:19 PM
Ringo
[quote author=Andy link=topic=17474.msg177993#msg177993 date=1209482363]
No, I only use BNCSUtil for NLS... And I don't see any validation checksum in it.

I asked if there was a checksum like SC, not if they're "validated in some way".
[/quote]
They are the same thing.. the algorithm validates the cdkey for install

[code]
    R = 3
    For i = 0 To 15
        R = R + (iff(IsNumeric(Key(i)), Asc(Key(i)) - &H30, Asc(Key(i)) - &H37) Xor (R * 2))
    Next i
    If Not ((R And &HFF) = tmpByte) Then
        'Cdkey is shit
[/code]
tmpByte is or'ed if the 0x100 bit is set from the hex value of the cdkey (derived from the key codes)
See the 1st few steps of the cdkey decode function, its right there.
April 29, 2008, 3:27 PM
Barabajagal
Oh... I sort of don't have that part in my decode function:

[code]FUNCTION DecodeD2W2Key(BYVAL key AS STRING) AS STRING
DIM N              AS DWORD
DIM N2              AS DWORD
DIM v              AS DWORD
DIM V2              AS DWORD
DIM KeyValue        AS DWORD
DIM C1              AS BYTE
DIM C2              AS BYTE
DIM C              AS BYTE
DIM I              AS INTEGER
DIM aryKey(0 TO 15) AS STRING
DIM CodeValues      AS STRING
    CodeValues = "246789BCDEFGHJKMNPRTVWXZ"
    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
        SHIFT RIGHT N2, 4
        aryKey(I) = GetHexValue(N2)
        aryKey(I + 1) = GetHexValue(N)
        SHIFT LEFT R, 1
    NEXT I
    v = 3
    FOR I = 0 TO 15
        C = GetNumValue(aryKey(I))
        N = 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 C <= &H37 THEN
            v = V2
            C2 = v AND &HF
            C2 = C2 AND 7
            C2 = C2 XOR C
            SHIFT RIGHT V, 3
            aryKey(I) = CHR$(C2)
            V2 = v
        ELSEIF C < &H41 THEN
            C2 = CBYT(I)
            C2 = C2 AND 1
            C2 = C2 XOR C
            aryKey(I) = CHR$(C2)
        END IF
    NEXT I
    FUNCTION = JOIN$(aryKey(), "")
    ERASE aryKey()
END FUNCTION[/code]
April 29, 2008, 3:31 PM
iago
[quote author=Andy link=topic=17474.msg177991#msg177991 date=1209480741]
That's not what I asked...
[/quote]
Ok, I'll answer the question you asked: No.
April 30, 2008, 3:32 PM
UserLoser
[quote author=Andy link=topic=17474.msg177995#msg177995 date=1209483106]
Oh... I sort of don't have that part in my decode function:

[code]FUNCTION DecodeD2W2Key(BYVAL key AS STRING) AS STRING
DIM N               AS DWORD
DIM N2              AS DWORD
DIM v               AS DWORD
DIM V2              AS DWORD
DIM KeyValue        AS DWORD
DIM C1              AS BYTE
DIM C2              AS BYTE
DIM C               AS BYTE
DIM I               AS INTEGER
DIM aryKey(0 TO 15) AS STRING
DIM CodeValues      AS STRING
    CodeValues = "246789BCDEFGHJKMNPRTVWXZ"
    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
        SHIFT RIGHT N2, 4
        aryKey(I) = GetHexValue(N2)
        aryKey(I + 1) = GetHexValue(N)
        SHIFT LEFT R, 1
    NEXT I
    v = 3
    FOR I = 0 TO 15
        C = GetNumValue(aryKey(I))
        N = 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 C <= &H37 THEN
            v = V2
            C2 = v AND &HF
            C2 = C2 AND 7
            C2 = C2 XOR C
            SHIFT RIGHT V, 3
            aryKey(I) = CHR$(C2)
            V2 = v
        ELSEIF C < &H41 THEN
            C2 = CBYT(I)
            C2 = C2 AND 1
            C2 = C2 XOR C
            aryKey(I) = CHR$(C2)
        END IF
    NEXT I
    FUNCTION = JOIN$(aryKey(), "")
    ERASE aryKey()
END FUNCTION[/code]
[/quote]

where is R defined at? that's some odd looking vb
April 30, 2008, 9:22 PM
Barabajagal
Top of the module(I dunno why, maybe I was half asleep)... and it's not VB.

[code]FUNCTION IsNumeric(BYVAL Value AS STRING) AS LONG
    FUNCTION = RETAIN$(Value, ANY CHR$(48 TO 57)) = Value
END FUNCTION

FUNCTION GetHexValue(BYVAL lVAL AS DOUBLE) AS STRING
    lVAL = lVAL AND &HF
    IF lVAL < 10 THEN
        FUNCTION = CHR$(lVAL + &H30)
    ELSE
        FUNCTION = CHR$(lVAL + &H37)
    END IF
END FUNCTION

FUNCTION GetNumValue(BYVAL lVAL AS STRING) AS BYTE
    lVAL = UCASE$(lVAL)
    IF IsNumeric(lVAL) THEN
        FUNCTION = ASC(lVAL) - &H30
    ELSE
        FUNCTION = ASC(lVAL) - &H37
    END IF
END FUNCTION

FUNCTION DecodeD2W2Key(BYVAL key AS STRING) AS STRING
DIM R              AS DWORD
DIM N              AS DWORD
DIM N2              AS DWORD
DIM v              AS DWORD
DIM V2              AS DWORD
DIM KeyValue        AS DWORD
DIM C1              AS BYTE
DIM C2              AS BYTE
DIM C              AS BYTE
DIM I              AS INTEGER
DIM aryKey(0 TO 15) AS STRING
DIM 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
        SHIFT RIGHT N2, 4
        aryKey(I) = GetHexValue(N2)
        aryKey(I + 1) = GetHexValue(N)
        SHIFT LEFT R, 1
    NEXT I
    v = 3
    FOR I = 0 TO 15
        C = GetNumValue(aryKey(I))
        N = 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 C <= &H37 THEN
            v = V2
            C2 = v AND &HF
            C2 = C2 AND 7
            C2 = C2 XOR C
            SHIFT RIGHT V, 3
            aryKey(I) = CHR$(C2)
            V2 = v
        ELSEIF C < &H41 THEN
            C2 = CBYT(I)
            C2 = C2 AND 1
            C2 = C2 XOR C
            aryKey(I) = CHR$(C2)
        END IF
    NEXT I
    FUNCTION = JOIN$(aryKey(), "")
    ERASE aryKey()
END FUNCTION[/code] better?
April 30, 2008, 9:36 PM
UserLoser
well it looks like vb, idk what of that syntax lets you declare something as DWORD
April 30, 2008, 9:49 PM
Barabajagal
It's PowerBASIC. It looks like a BASIC language because it is.
April 30, 2008, 10:13 PM
Barabajagal
Alright, got that one done, thanks Ringo. What about W3 keys? [s]I don't even seem to have what the Product values are supposed to be; is it 0x0E for WAR3 and 0x12 for W3XP?

Edit: I just did a run through of a lot of keys, and I got some Product values I'd like to have double-checked:
NYVXXMMC9P6VDYBY48F67RCZZW got 0xCE2
QXK0QNOKK6CFHZ8JI4PEHG3RIH got 0x0F
FXDB9GZYWVFD7R698W2P42C7YC got 0x36AF
DXY268ZRBVTEBNKP8P6MB4NKYN got 0x16B6
H2V49NTMCE778CY77KXXCN6NMC got 0x2A00

Are they just illegal keys, are those products valid, or is there something wrong with my decoder functions?[/s] Nevermind, tested them myself.
May 2, 2008, 10:07 PM

Search