Results 1 to 4 of 4

Thread: CoD 2 Encryption

  1. #1
    Private
    Join Date
    Nov 2013
    Posts
    16
    Thanks
    2
    Thanked 17 Times in 6 Posts

    CoD 2 Encryption

    Hello again...
    i'm having problems with decrypting cod2 data. Actually its not a problem. I simply don't know the encryption key.

    Okey here is what i've done so far (Language: Python):

    I got 2 Computers connected together on LAN.

    On the first one i've written the server script ( how the original cod server would responde )
    Code:
    Code:
    import socket #importing module
    
    IP = "192.168.1.119" #my Local IP
    PORT = 28960 #Port of server
    
    sock = socket.socket(socket.AF_INET, # Internet
    					socket.SOCK_DGRAM) # UDP
    					
    sock.bind((IP, PORT)) #Creating the server ( opening the IP and PORT)
    
    while True:
    	data, addr = sock.recvfrom(7000) #listening for data to come
    	print "received message:", data, addr #printing what i got
    	if 'connec' in data: # if i get connect request from a client send him following:
    		sock.sendto('\xff\xff\xff\xffconnectResponse', addr)
    	if 'chal' in data: # if i get challange request from client send him following:
    		sock.sendto('\xff\xff\xff\xffchallengeResponse 1253163161', addr)

    And on the 2. computer i just started CoD2 and connected to 192.168.1.119:28960 (server created)

    i get the following:

    Code:
    Code:
    getchallenge 0 "2d0ac480dfee724400cbf515d4003c45"
    connect "\cl_anonymous\0\cl_punkbuster\1\cl_voice\1\cl_wwwDownload\1\rate\5000\snaps\20\name\stEvo\protocol\118\challenge\1253163161\qport\2096"
       0         2$TZRguu	AǏaAu
    ^)Z^UWkţu|i⦄y#
       0         2$TZRguu	AǏaAu
    ^)Z^UWkţu|i⦄y#
       0         D$TZRguu	AǏaAu
    ^)Z^UWkţu|i⦄y#$no2
       0         D$TZRguu	AǏaAu
    ^)Z^UWkţu|i⦄y#$no2
       0         D$TZRguu	AǏaAu
    ^)Z^UWkţu|i⦄y#$no2
    getstatus
    first 2 lines i do get, but what is this rest stuff that is constantly sending ?
    how do i see what are the requests that 2. computer is asking for ?
    how do i decrypt this ?

    ~ thanks for taking your time to reads this.
    Last edited by stevomitric; 4th March 2015 at 19:54.

  2. #2
    Assadministrator kung foo man's Avatar
    Join Date
    Jun 2012
    Location
    trailerpark
    Posts
    2,011
    Thanks
    2,102
    Thanked 1,084 Times in 753 Posts
    It's probably some Huffman encoded client initialisation.

    http://fabiensanglard.net/quake3/network.php

    Might help: http://aluigi.altervista.org/papers/q3huff.h

    You should become familiar with the Quake 3 network model (e.g. implement a simple Q3 client in python) and then you can try connecting to CoD2 and see where it differs (e.g. some different encryption).

    Doing C structs in Python is gonna be aids though, so probably it would be easier to do it in C, because all the source code is available. But for faster testing you could still write a Python plugin for this.
    timescale 0.01

  3. The Following User Says Thank You to kung foo man For This Useful Post:

    serthy (5th March 2015)

  4. #3
    Brigadier General
    Join Date
    Oct 2012
    Posts
    994
    Thanks
    20
    Thanked 588 Times in 388 Posts
    Quote Originally Posted by kung foo man View Post
    It's probably some Huffman encoded client initialisation.

    http://fabiensanglard.net/quake3/network.php

    Might help: http://aluigi.altervista.org/papers/q3huff.h

    You should become familiar with the Quake 3 network model (e.g. implement a simple Q3 client in python) and then you can try connecting to CoD2 and see where it differs (e.g. some different encryption).

    Doing C structs in Python is gonna be aids though, so probably it would be easier to do it in C, because all the source code is available. But for faster testing you could still write a Python plugin for this.
    Huffman is a compression algorithm - not an encryption algorithm. According to the link you provided to the network model, Quake 3 uses a Pre Shared Key encryption, which is in turn a symmetric key cryptographic algorithm. I have no idea what that key is, but it certainly isn't Huffman.
    Last edited by Tally; 5th March 2015 at 09:14.

  5. #4
    Assadministrator kung foo man's Avatar
    Join Date
    Jun 2012
    Location
    trailerpark
    Posts
    2,011
    Thanks
    2,102
    Thanked 1,084 Times in 753 Posts
    Yup, hence I said "encoding" in context of "Huffman encoded client initialisation". It is using a pre-defined table for best compression (optimized for the common data the game will send):

    http://www.elho.net/games/q3/q3dspecs.htm#_Toc49066736

    PHP Code:
    //
    // pre-defined frequency counts for all bytes [0..255]
    //
    static int huffCounts[256] = {
           
    0x3D1CB0x0A0E90x018940x01BC20x00E920x00EA60x017DE0x05AF3,
           
    0x082250x01B260x01E9E0x025F20x024290x0436B0x00F6D0x006F2,
           
    0x020600x006440x006360x0067F0x0044C0x004BD0x004D60x0046E,
           
    0x006D50x004230x004DE0x0047D0x004F90x011860x00AF50x00D90,
           
    0x0553B0x004870x006860x0042A0x004130x003F40x0041D0x0042E,
           
    0x006BE0x003780x0049C0x003520x003C00x0030C0x006D80x00CE0,
           
    0x029860x011A20x016F90x00A7D0x0122A0x00EFD0x0082D0x0074B,
           
    0x00A180x0079D0x007B40x003AC0x0046E0x006FC0x006860x004B6,
           
    0x016570x017F00x01C360x019FE0x00E7E0x00ED30x005D40x005F4,
           
    0x008A70x004740x0054B0x003CB0x008840x004E00x005300x004AB,
           
    0x006EA0x004360x004F00x004F20x004900x003C50x004830x004A2,
           
    0x005430x004CC0x005F90x006400x00A390x008000x009F20x00CCB,
           
    0x0096A0x00E010x009C80x00AF00x00A730x018020x00E4F0x00B18,
           
    0x037AD0x00C5C0x008AD0x006970x00C880x00AB30x00DB80x012BC,
           
    0x00FFB0x00DBB0x014A80x00FB00x01F010x0178F0x014F00x00F54,
           
    0x0131C0x00E9F0x011D60x012C70x016DC0x019000x018510x02063,
           
    0x05ACB0x01E9E0x01BA10x022E70x0153D0x011830x00E390x01488,
           
    0x014C00x014D00x014FA0x00DA40x0099A0x0069E0x0071D0x00849,
           
    0x0077C0x0047D0x005EC0x005570x004D40x004050x004EA0x00450,
           
    0x004DD0x003EE0x0047D0x004010x004D90x003B80x005070x003E5,
           
    0x006B10x003F10x004A30x0036F0x0044B0x003A10x004360x003B7,
           
    0x006780x003A20x004810x004060x004EE0x004260x004BE0x00424,
           
    0x006550x003A20x004520x003900x0040A0x0037C0x004860x003DE,
           
    0x004970x003520x004610x003870x0043F0x003980x004780x00420,
           
    0x00D860x008C00x0112D0x02F680x01E4E0x005410x0051B0x00CCE,
           
    0x0079E0x003760x003FF0x004580x004350x004120x004250x0042F,
           
    0x005CC0x003E90x004480x003930x0041C0x003E30x0042E0x0036C,
           
    0x004570x003530x004230x003250x004580x0039B0x0044F0x00331,
           
    0x0076B0x007500x003D00x003490x004670x003BC0x004870x003B6,
           
    0x01E6F0x003BA0x005090x003A50x004670x00C870x003FC0x0039F,
           
    0x0054B0x003000x004100x002E90x003B80x003250x004310x002E4,
           
    0x003F50x003250x003F00x0031C0x003E40x004210x02CC10x034C0
    }; 
    I actually never saw any encryption code in Q3 source, so maybe he is really referring to this table as "encryption key"... then the terminology of the article is wrong of course.

    Edit:

    Quite nice article: http://trac.bookofhook.com/bookofhoo...ake3Networking

    Compression, Encryption, and Packets

    He has done some half-hearted work on encryption, but basically app/stream-level encryption is pointless because of the sophistication of hackers. In the future he'll probably rely on higher level inspection (a la Punkbusters for Counter-Strike) instead of cute bit-twiddling.

    Last edited by kung foo man; 5th March 2015 at 11:05. Reason: Add article
    timescale 0.01

  6. The Following User Says Thank You to kung foo man For This Useful Post:

    serthy (5th March 2015)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •