Valhalla Legends Archive

Programming => Battle.net Bot Development => Topic started by: aton on October 19, 2005, 10:52 AM

Title: cdkey generation
Post by: aton on October 19, 2005, 10:52 AM
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?)
Title: Re: cdkey generation
Post by: Falcon[anti-yL] on October 19, 2005, 03:14 PM
Use search, its been covered on here at least 100 times.
Title: Re: cdkey generation
Post by: iago on October 28, 2005, 07:16 PM
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]:
    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'));
    }

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. 
Title: Re: cdkey generation
Post by: Kp on October 28, 2005, 08:29 PM
Quote from: iago on October 28, 2005, 07:16 PM[it's in Java, email me for a C one]

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. :)
Title: Re: cdkey generation
Post by: iago on November 01, 2005, 12:22 PM
Quote from: Kp on October 28, 2005, 08:29 PM
Quote from: iago on October 28, 2005, 07:16 PM[it's in Java, email me for a C one]

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. :)

Haha, I hadn't thought of that!  Good call.