honeylab's blog

各種ハードウェアの改造、主にファミコンミニなどをやってます(ました)

NEOGEO Arcade Stick Pro cdkey file format for game unlocking.

・Unlock CD-Key system

Vendor already provided CD-Key files for unlocking two Games.
cdkey zip is contain cdkey/[GAME_TITLE].cdk file.
This hexdumps are METAL_SLUG.cdk and METAL_SLUG2.cdk.

f:id:honeylab:20200105230043p:plain

44 bytes from start are id and check header.Their two cdk file are same binary .

First 4bytes little endian 32-bit is length of least bytes = 0x 00 00 01 28 = 296(dec) bytes.
Next 32bit int is count for something 4byte values : and values[0]=0x00000100

least 0x20 =32(dec)bytes is MD5 encoded data from some data.

 value is [ e3251075554389fe91d17a794861d47b ]

least 0x100 bytes are encrypted cdk file.

openssl can decrypt this data stream.

because stock executable contains a secret key for decrypt them.

f:id:honeylab:20200105231527p:plain

snk $ openssl rsautl -decrypt -inkey snk.pem -in encrypted.dat -out decrypted.dat
snk $ cat decrypted.dat
[SN_NO]=<FFFFFFFFFFFFFF>
[CDKEY]
[ID]=<27>
[NAME]=<mslug>
[CDKEY/]
[ENCRYPT]=<850b405b3dcdaa1543309ad09e1a7f76>

this stream make order unlocking "mslug ,ID 27" to stock system.

openssl can re-generate public key for encrypt cdk file.
so in logically , we can generate cdkey file for unlock other games.