#include #include #include #include #include #define PART_LENGTH 6 #define FLAG_LENGTH (4 + 1 + (PART_LENGTH + 1 + PART_LENGTH + 1 + PART_LENGTH) + 1) int stage0(char *flag, char **parts) { char *content = &flag[5]; if (memcmp(flag, "595g{", 4 + 1)) { return 0; } if (flag[FLAG_LENGTH - 1] != '}') { return 0; } if (content[PART_LENGTH] != '-' || content[PART_LENGTH + 1 + PART_LENGTH] != '-') { return 0; } parts[0] = content; parts[1] = &content[PART_LENGTH + 1]; parts[2] = &content[PART_LENGTH + 1 + PART_LENGTH + 1]; parts[0][PART_LENGTH] = 0; parts[1][PART_LENGTH] = 0; parts[2][PART_LENGTH] = 0; return 1; } int stage1(char *part) { for (int i = 0; i < PART_LENGTH; i++) { for (int j = 0; j < part[i]; j++) { time(NULL); } putchar('\n'); } return 1; } int stage2(char *part) { for (int i = 0; i < PART_LENGTH; i++) { for (int j = 0; j < 8; j++) { if (part[i] & (1 << j)) { tmpnam(NULL); } else { rand(); } } } return 1; } int stage3(char *part) { union { uint64_t num; char bytes[8]; } data; data.num = 0; for (int i = 0; i < PART_LENGTH; i++) { data.bytes[((i + 6) ^ 5) % 8] = part[i]; } printf("%lu\n", data.num); } int main() { char flag[FLAG_LENGTH + 1]; char *parts[3]; if (fread(flag, FLAG_LENGTH, 1, stdin) != 1) { return 1; } flag[FLAG_LENGTH] = 0; if (!stage0(flag, parts)) { return 2; } if (!stage1(parts[0])) { return 3; } if (!stage2(parts[1])) { return 4; } if (!stage3(parts[2])) { return 5; } return 0; }