Created
May 10, 2016 22:01
-
-
Save abeaumont/b61c61e0e8507decf337382dfaa75d8f to your computer and use it in GitHub Desktop.
Solution for Catch Me challenge in ASIS CTF 2016 Quals
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int is_valid(unsigned char c) { | |
return c == 0 || c == 45 || c >= 48 && c <= 57 || c >= 65 && c <= 90 || c == 95 || c >= 97 && c <= 122; | |
} | |
int main () { | |
unsigned char h1[17] = {0x87, 0x29, 0x34, 0xC5, 0x55, 0xB0, 0xC2, 0x2D, 0xEE, 0x60, 0x34, 0xD4, 0x55, 0xEE, 0x80, 0x7C, 0}; | |
unsigned char h2[17] = {0xEE, 0x2F, 0x37, 0x96, 0x3D, 0xEB, 0x9C, 0x79, 0xEE, 0x2C, 0x33, 0x95, 0x78, 0xED, 0xC1, 0x2B, 0}; | |
unsigned char bytes[8] = {0xb1, 0x19, 0x4, 0xa1, 0, 0, 0, 0}; | |
for (int a = 0; a < 256; a++) { | |
for (int b = 0; b < 256; b++) { | |
for (int c = 0; c < 256; c++) { | |
for (int d = 0; d < 256; d++) { | |
bytes[4] = a; | |
bytes[5] = b; | |
bytes[6] = c; | |
bytes[7] = d; | |
for (int j = 0; j < 16; j++) { | |
h1[j] ^= bytes[j & 7]; | |
} | |
for (int j = 0; j < 16; j++) { | |
h2[j] ^= bytes[j & 7]; | |
} | |
int sum = 0; | |
for (int j = 0; j < 16; j++) { | |
sum += h1[j]; | |
sum += h2[j]; | |
} | |
if (sum == 2388) { | |
int ok = 1; | |
for (int j = 0; j < 16; j++) { | |
if (!is_valid(h1[j]) || !is_valid(h2[j])) { | |
ok = 0; break; | |
} | |
} | |
if (ok) { | |
printf("%s%s\n", h1, h2); | |
} | |
} | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment