Valhalla Legends Forums Archive | Battle.net Bot Development | cdkey generation

AuthorMessageTime
aton
not really a bot topic, but i think it fits here best.

does anyone have information about the algorithm thats used to create cdkeys for starcraft?
i'd like to write a complete generator+tester, so that you just supply a list of proxies and press generate, and after a few minutes you have a valid b.net cdkey. (does this already exist?)
October 19, 2005, 3:52 PM
LW-Falcon
Use search, its been covered on here at least 100 times.
October 19, 2005, 8:14 PM
iago
All information on keys can be found here:
http://www.javaop.com/javaop2/src/BNetLogin/src/cdkey/CDKeyDecode.java

The best way to BFI the problem is to use this algorithm I reversed [it's in Java, email me for a C one]:
[code]    protected boolean verify()
    {
        int accum = 3;
       
        for(int i = 0; i < (cdkey.length() - 1); i++)
            accum += ((cdkey.charAt(i) - '0') ^ (accum * 2));

        return ((accum % 10) == (cdkey.charAt(12) - '0'));
    }[/code]
But instead of comparing the last digit to the accumulator, just set the last digit to that value and go. 

However! There are some ways to streamline it a little.  For instance. decode the key, check the product, and make sure it's right.  If it's not, trash the key and try again. 
October 29, 2005, 12:16 AM
Kp
[quote author=iago link=topic=13077.msg132216#msg132216 date=1130545003][it's in Java, email me for a C one][/quote]

Allowing for use of STL-like string objects, the only part of that code that wouldn't be legal C++ is specifying the protection on the function directly.  Maybe you should've just left the protection keyword off so it could be both Java and C++ at once. :)
October 29, 2005, 1:29 AM
iago
[quote author=Kp link=topic=13077.msg132222#msg132222 date=1130549371]
[quote author=iago link=topic=13077.msg132216#msg132216 date=1130545003][it's in Java, email me for a C one][/quote]

Allowing for use of STL-like string objects, the only part of that code that wouldn't be legal C++ is specifying the protection on the function directly.  Maybe you should've just left the protection keyword off so it could be both Java and C++ at once. :)
[/quote]

Haha, I hadn't thought of that!  Good call.
November 1, 2005, 6:22 PM

Search