-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
49 lines (37 loc) · 2.29 KB
/
main.c
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
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <time.h>
#define RAND_MAX 32767
static unsigned long int next = 1;
// ptzctf{67423e253c9b4d8a0d2ac8a33bd58467}
int t[7][7][7] = {{{48,199,108,83,71,61,86},{6,165,9,63,200,94,40},{193,256,39,191,75,103,211},{25,94,95,210,249,98,53},{139,170,196,241,19,123,35},{202,34,23,21,98,132,163},{84,195,41,83,22,62,18}},{{221,73,9,126,15,163,27},{230,249,31,131,2,201,85},{235,172,132,247,155,248,105},{173,29,31,35,237,220,163},{115,103,47,41,211,99,240},{155,107,58,239,116,217,127},{198,38,0,210,218,120,69}},{{80,207,176,212,168,251,43},{38,56,165,72,123,16,215},{142,110,169,50,200,79,206},{187,86,248,142,62,226,139},{54,44,44,139,155,130,38},{48,102,19,221,127,61,102},{206,190,171,162,37,98,140}},{{65,142,153,104,96,171,158},{95,142,2,212,197,237,19},{126,144,204,129,169,55,87},{179,255,216,162,226,11,116},{37,31,166,167,67,157,21},{152,200,198,93,238,154,213},{168,11,159,211,202,89,30}},{{64,103,129,76,219,214,210},{167,92,93,245,170,203,179},{218,191,43,112,16,15,106},{208,189,49,88,64,243,152},{21,214,207,43,173,20,42},{28,238,96,92,21,30,80},{163,184,193,25,32,99,252}},{{45,182,119,14,129,209,50},{66,54,8,198,67,199,6},{94,233,79,200,237,169,124},{18,63,169,26,226,243,42},{9,45,4,196,17,210,69},{10,193,84,136,213,36,26},{129,140,44,22,78,188,60}},{{76,84,31,50,44,254,234},{80,240,50,69,188,224,136},{224,247,190,3,153,92,13},{215,196,157,69,222,122,210},{236,208,89,83,136,58,68},{174,127,89,102,215,172,96},{67,203,79,151,182,65,102}}};
uint8_t c[40] = {0x76,0xdf,0x1d,0xe0,0x6a,0x06,0xf9,0x65,0x0a,0xe5,0xe5,0x35,0x27,0x6e,0xd8,0x47,0xcd,0x28,0x19,0xb0,0xea,0xf7,0xfb,0x02,0xc7,0xc1,0xab,0x90,0x66,0xbb,0x1f,0x29,0x02,0x2a,0x76,0xfc,0x02,0xbd,0x34,0x02};
int rand(void)
{
next = next * 1103515245 + 12345;
return (unsigned int)(next/65536) % (RAND_MAX + 1);
}
void srand(unsigned int seed)
{
next = seed;
}
uint8_t grb() {
return rand() % 256;
}
int main(int argc, char* argv[], char* envp[]) {
int seed = *(int*)"ptzc";
srand(seed);
uint8_t * out = malloc(40);
for (int i = 0; i < 40; i++) {
int x, y, z;
x = grb() % 7;
y = grb() % 7;
z = grb() % 7;
int xor_key = t[x][y][z];
out[i] = c[i] ^ xor_key;
}
printf("flag: %s\n", out);
return 0;
}