2 Bytes - This is the Version of the protocol = 03 00 (Major, Minor)
2 Bytes - This is the Function code. The ones I know are listed below.
2 Bytes - First Sequence Code \ These are usually the same
2 Bytes - Second Sequence Code /
4 Bytes - This is the user ID of the client user
4 Bytes - These four bytes are ICQ's weak attempt at security:
to get these do the following:
check1 = ( data[8] << 24) | ( data[4] << 16 ) | ( data[2] << 8 ) | ( data[6] );
offs1 = Random % length; // offset into packet
offs2 = Random % 256; // offset into magic data
check2 = ( offs1 << 24 ) | !( data[offs1] << 16 ) | ( offs2 << 8) | !( magic[offs2] );
check = check1 ^ check2; // XOR the two checks
2 Bytes - Version Number (not Encrypted) = 04 00 (Major, Minor)
2 Bytes - Random number (Not Encrypted)
***** Everything from this point to the 1/4 mark is encrypted *****
2 Bytes - Always 00 00 un-encrypted
- Since the key is xored to encrypt - whatever numbers are here
are the first 2 bytes of the encryption Key.
2 Bytes - Command Code.
2 Bytes - First Sequence Code
2 Bytes - Second Sequence Code
4 Bytes - User ID Number
4 Bytes - This is a Checksum. It is calculated the same as above
- The packet is encrypted by XORing 1/4 of the packet with a key
- The Key is calculated by multiplying the length * 0x66756B65 and
adding the check value.
1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| 4 | 0 | RANDOM |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Everything below this point is encrypted
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| ZEROS | COMMAND |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| SEQUENCE | SECOND SEQUENCE |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| UIN |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| CHECK |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Source: https://habr.com/ru/post/315318/
All Articles