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 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
| #include <stdio.h> #include <stdint.h> static char Base64Code[] = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/', '=' };
void decrypt (uint32_t* v, uint32_t* k) { uint32_t v0=v[0], v1=v[1], i; uint32_t delta=0x79B99E37; uint32_t sum = delta * 32; uint32_t k0=k[0], k1=k[1], k2=k[2], k3=k[3]; for (i=0; i<32; i++) { v1 += ((v0>>5) + k2) ^ (v0 + sum) ^ ((v0<<4) + k3); v0 += ((v1>>5) + k0) ^ (v1 + sum) ^ ((v1<<4) + k1); sum -= delta; } v[0]=v0; v[1]=v1; } int main() { uint32_t v[]={0x5C15754C, 0xD1D781E7, 0x501BF173, 0xCB4DB222, 0x215D61F5, 0x3FCA9EE7, 0x7C76B5C7, 0xC7DD8CB9, 0x990D23FA, 0x0BAB1AD3, 0x8E12C932, 0xD307BAF2, 0xE52DD123, 0xFBB68F2C, 0xBDD853E3, 0x892E1E4E, 0x39DD66FA, 0x87FEEC65, 0x307C5E60, 0x340C6C00},k[4]={0xDEADBEEF, 0xBABEC0FE, 0xDEADC0DE, 0xFACEB00C}; int i, j; unsigned char reflag[40] = { 0 }; for ( i = 0; i < 10; i++ ) { decrypt(v + i * 2, k); printf("%X, %X ", v[i * 2], v[i * 2 + 1]); unsigned char * p = (unsigned char *)(v + i * 2); for (j = 0; j < 4; j++) { reflag[i * 4 + j] = p[j * 2] + p[j * 2 + 1]; printf("%c, ", reflag[i * 4 + j]); } puts("\n"); } for ( i = 0; i < 20; i++ ) { unsigned char t = reflag[i]; reflag[i] = reflag[39 - i]; reflag[39 - i] = t; } for ( i = 0; i < 40; i++ ) { for ( j = 0; j < 64; j++ ) { if ( reflag[i] == Base64Code[j] ) { reflag[i] = j;
break; } } } unsigned char flag[30] = { 0 }; for ( i = 0, j = 0; j < 40; i += 3, j +=4 ) { flag[i] = (reflag[j] << 2) | ((reflag[j + 1] & 0x30) >> 4); flag[i + 1] = ((reflag[j + 1] & 0xF) << 4) | ((reflag[j + 2] & 0x3C) >> 2); flag[i + 2] = ((reflag[j + 2] & 0x3) << 6) | reflag[j + 3] ;
} for ( i = 0; i < 15; i++ ) printf("%c", flag[i * 2]); for ( i = 0; i < 15; i++ ) printf("%c", flag[29 - i * 2]);
return 0; } # flag{Emp0wer_F1utter_w1th_C!!}
|