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 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
| #include <stdio.h>
#define ROR5(n) ( (n >> 5) & 0x7 ) | ( (n << 3) & 0xF8 )
int main(void) { unsigned char encFlag[] = { 0xC8, 0x34, 0x59, 0x4E, 0xC0, 0xD5, 0xAD, 0x08, 0xC9, 0x2B, 0x4C, 0xDA, 0xE6, 0xC0, 0x9A, 0x19, 0xB5, 0x10, 0x55, 0x7D, 0xE8, 0xF5, 0x83, 0xFF, 0x74, 0x8B, 0xE3, 0xD4, 0x6A, 0x7D, 0x44, 0x58 }; unsigned char orgFlag[32] = { 0 }; unsigned char input[32]; int i, j, x, y; for ( x = 0; x < 4; x++ ) { for ( i = 0; i < 8; i++ ) { for ( j = 0; j < 8; j++ ) { if ( (encFlag[j + x * 8] & (0x80 >> i)) ) orgFlag[i + x * 8] |= (0x80 >> j); } } for ( y = 0; y < 8; y++ ) { orgFlag[y + x * 8] = ROR5(orgFlag[y + x * 8]);
} } for ( i = 0; i < 4; i++ ) { __int64 t = *((__int64 *)&orgFlag[i * 8]);
for ( j = 0; j < 64; j++ ) { if ( t & 1 ) { t = ((unsigned __int64)t ^ 0x2EF20D07161E85F7) / 2; t |= 0x8000000000000000; } else t = (unsigned __int64)t / 2; } for ( j = 7; j >= 0; j-- ) { input[j + i * 8] = (char)t; t >>= 8; } }
for ( i = 0; i < 4; i++ ) { for ( j = i * 8; j < (6 + i * 8); j += 3 ) { printf("%c", input[j] ^ input[j + 1] ^ input[j + 2]); printf("%c", input[j] ^ input[j + 2]); printf("%c", input[j + 1] ^ input[j + 2]); } printf("%c", input[i * 8 + 6]); printf("%c", input[i * 8 + 7]); } return 0; }
|