viewing paste Unknown #6601 | C

Posted on the
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
#include <stdio.h>
 
int main() {
    unsigned int cryptKey[3] = {0,0,0};
    unsigned int sdcryptKey, prevKey = 0;
    int i = 0;
#   define packetKeys(a,b,c) { cryptKey[0] = a; cryptKey[1] = b; cryptKey[2] = c; }
#ifndef PACKETVER
#   define PACKETVER 20120418
#endif
#   include "src/map/packets.h"
    sdcryptKey = (( cryptKey[0] * cryptKey[1] ) + cryptKey[2]) & 0xFFFFFFFF;
    do {
        if (sdcryptKey == prevKey) {
            printf("Packetver %d repeats key %08x after %d iterations.\n", PACKETVER, sdcryptKey, i);
            return 1;
        }
        i++;
        prevKey = sdcryptKey;
        sdcryptKey = (( sdcryptKey * cryptKey[1] ) + cryptKey[2]) & 0xFFFFFFFF;
    } while (i < 1000000);
    printf("Packetver %d is safe for at least %d iterations\n", PACKETVER, i);
    return 0;
}
 
Viewed 785 times, submitted by Guest.