#######################################################################

Title:  Online cd-key verifier for games that use the Gamespy cd-key
        SDK
Author: Luigi Auriemma
        e-mail: aluigi@autistici.org
        web:    aluigi.org

#######################################################################

============
Introduction
============

This tool does only one simple thing: it contacts the Gamespy master
server asking if a specific cd-key for a specific game is valid or, if
not, why not.

It is useful because the Gamespy cd-key authorization is all server
side so is not possible for a client (who has the cd-key) to know the
details of why his cd-key has not been accepted, it can only know what
the server tells to it.
However it can be used also for many other reasons like, for example,
to know if you doubt that someone else is using your cd-key or just
for curiosity.

All the details about the mechanism used by the cd-key SDK to verify
if cd-keys are valid or not is described here:

  http://aluigi.org/papers/gskey-auth.txt

In short the authorization (and what my tool does) is composed by the
following steps:
- server sends a random text string to the client
- the client sends the MD5 hash of his cd-key plus another random text
  string generated by it and the MD5 hash of a string calculated using
  the cd-key and the two random strings
- the server sends all the stuff to the master server
- the master server verifies if the data received is correct (that's
  the reason of the random text strings)
- the master server searches in the database of that specific game if
  exists the MD5 hash received in the query
- the master server sends a reply to the server


#######################################################################

============
Requirements
============

- a game that supports the Gamespy cd-key SDK, a list of some games is
  available here:

    http://aluigi.org/papers/gshlist.txt

  Exist also other ways to know if a game uses the Gamespy cd-key SDK:
  - the presence of the Gamespy logo in the game naturally
  - the presence of some patterns in the game executable like %s%d%s
    and %.8x or the assembly instructions used to handle the encoded
    packets exchanged with the master server (usually games use
    encrypted executables so these things must be searched in the no-cd
    executables)
  - the capturing of the authorization packets exchanged with the
    master server:
    you need to set a server and a client and to use my sniffer:
      http://aluigi.org/papers/gshsniff.zip
  - others?

- the list of Gamespy PIDs, needed to identify the game of which you
  want to check the cd-key, is available here:

    http://aluigi.org/papers/gspids.txt

- naturally a cd-key for that specific game


#######################################################################

==========
How to use
==========

You can double-click on the executable and then insert the needed
parameters: game PID and cd-key.
This is probably the simpled way for people without experience with the
command-line.
Remember that the cd-key must be typed just as it is used by the game,
usually is necessary to use also the chars '-' but in some games like
Battlefield 2 you must use the cd-key without the separators.

But you can also specify these parameters through the command-line
like:

  gskeycheck 541

    541 is the PID of Battlefield 1942, the cd-key will be requested
    when the tool starts

  gskeycheck 541 1111-2222-3333-4444

    PID 541 and cd-key 1111-2222-3333-4444

The tool is very verbose so will ever show any information about the
status of the verification and about the reply received from the master
server.

While the following is an example for Battlefield 2 where you need to
remove the separators:

  gskeycheck 1059 ABCD1234EFGH5678IJKL

From version 0.1.1 I have introduced also the specifying of a file
containing all the keys to check.
Example:

  gskeycheck 1059 keyfile.txt

And you can also specify an output file where will be written if a key
is valid (VALID!!!) or not (NOT VALID):

  gskeycheck 1059 keyfile.txt result.txt


#######################################################################

=====================================
How to build the file with the cdkeys
=====================================

Simple: one cdkey per line
Note that for me is impossible to know if the cdkey for a specific
game must be inserted with or without dashes (the - char), I know only
that the game Gore wants them.

Example:

1111-2222-3333-4444
1111-2222-3333-4444
1111-2222-3333-4444
 1111-2222-3333-4444
   1111-2222-3333-4444
1111-2222-3333-4444      
    1111-2222-3333-4444        
1111-2222-3333-4444
  1111-2222-3333-4444
1111-2222-3333-4444
1111-2222-3333-4444
1111-2222-3333-4444
1111-2222-3333-4444
1111-2222-3333-4444


#######################################################################
